From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 59E2A3952008; Fri, 6 May 2022 18:11:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 59E2A3952008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Remove init_raw_breakpoint_without_location X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 3101e4a1c5a9f14dd6860e439bbefdce00adc9f6 X-Git-Newrev: 73063f5180a07b9c8042887cd4cada0b89388556 Message-Id: <20220506181117.59E2A3952008@sourceware.org> Date: Fri, 6 May 2022 18:11:17 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 May 2022 18:11:17 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D73063f5180a0= 7b9c8042887cd4cada0b89388556 commit 73063f5180a07b9c8042887cd4cada0b89388556 Author: Tom Tromey Date: Sun May 1 11:20:34 2022 -0600 Remove init_raw_breakpoint_without_location =20 This removes init_raw_breakpoint_without_location, replacing it with a constructor on 'breakpoint' itself. The subclasses and callers are all updated. Diff: --- gdb/ada-lang.c | 8 ++-- gdb/break-catch-exec.c | 7 +++- gdb/break-catch-fork.c | 8 ++-- gdb/break-catch-load.c | 8 ++-- gdb/break-catch-sig.c | 8 ++-- gdb/break-catch-syscall.c | 7 ++-- gdb/break-catch-throw.c | 12 ++++-- gdb/breakpoint.c | 95 ++++++++++++++++++++++++-------------------= ---- gdb/breakpoint.h | 24 +++++++++--- 9 files changed, 105 insertions(+), 72 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b11808acb71..8333671c48b 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12122,8 +12122,10 @@ public: =20 struct ada_catchpoint : public base_breakpoint { - explicit ada_catchpoint (enum ada_exception_catchpoint_kind kind) - : m_kind (kind) + ada_catchpoint (struct gdbarch *gdbarch_, + enum ada_exception_catchpoint_kind kind) + : base_breakpoint (gdbarch_, bp_catchpoint), + m_kind (kind) { } =20 @@ -12757,7 +12759,7 @@ create_ada_exception_catchpoint (struct gdbarch *gd= barch, std::string addr_string; struct symtab_and_line sal =3D ada_exception_sal (ex_kind, &addr_string); =20 - std::unique_ptr c (new ada_catchpoint (ex_kind)); + std::unique_ptr c (new ada_catchpoint (gdbarch, ex_kind)= ); init_ada_exception_breakpoint (c.get (), gdbarch, sal, addr_string.c_str= (), tempflag, disabled, from_tty); c->excep_string =3D excep_string; diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c index fbdc1c20e50..c828b50cc62 100644 --- a/gdb/break-catch-exec.c +++ b/gdb/break-catch-exec.c @@ -36,6 +36,11 @@ =20 struct exec_catchpoint : public breakpoint { + explicit exec_catchpoint (struct gdbarch *gdbarch) + : breakpoint (gdbarch, bp_catchpoint) + { + } + int insert_location (struct bp_location *) override; int remove_location (struct bp_location *, enum remove_bp_reason reason) override; @@ -203,7 +208,7 @@ catch_exec_command_1 (const char *arg, int from_tty, if ((*arg !=3D '\0') && !isspace (*arg)) error (_("Junk at end of arguments.")); =20 - std::unique_ptr c (new exec_catchpoint ()); + std::unique_ptr c (new exec_catchpoint (gdbarch)); init_catchpoint (c.get (), gdbarch, temp, cond_string); =20 install_breakpoint (0, std::move (c), 1); diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c index 3ad4bafcf1c..913ccecba35 100644 --- a/gdb/break-catch-fork.c +++ b/gdb/break-catch-fork.c @@ -34,8 +34,9 @@ =20 struct fork_catchpoint : public breakpoint { - explicit fork_catchpoint (bool is_vfork_) - : is_vfork (is_vfork_) + fork_catchpoint (struct gdbarch *gdbarch, bool is_vfork_) + : breakpoint (gdbarch, bp_catchpoint), + is_vfork (is_vfork_) { } =20 @@ -185,7 +186,8 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdb= arch, bool temp, const char *cond_string, bool is_vfork) { - std::unique_ptr c (new fork_catchpoint (is_vfork)); + std::unique_ptr c (new fork_catchpoint (gdbarch, + is_vfork)); =20 init_catchpoint (c.get (), gdbarch, temp, cond_string); =20 diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c index 3e3bed2f861..8579f4e3b23 100644 --- a/gdb/break-catch-load.c +++ b/gdb/break-catch-load.c @@ -35,8 +35,9 @@ =20 struct solib_catchpoint : public breakpoint { - solib_catchpoint (bool is_load_, const char *arg) - : is_load (is_load_), + solib_catchpoint (struct gdbarch *gdbarch, bool is_load_, const char *ar= g) + : breakpoint (gdbarch, bp_catchpoint), + is_load (is_load_), regex (arg =3D=3D nullptr ? nullptr : make_unique_xstrdup (arg)), compiled (arg =3D=3D nullptr ? nullptr @@ -228,7 +229,8 @@ add_solib_catchpoint (const char *arg, bool is_load, bo= ol is_temp, bool enabled) if (*arg =3D=3D '\0') arg =3D nullptr; =20 - std::unique_ptr c (new solib_catchpoint (is_load, arg)= ); + std::unique_ptr c (new solib_catchpoint (gdbarch, + is_load, arg)); =20 init_catchpoint (c.get (), gdbarch, is_temp, NULL); =20 diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c index 1c29a057d60..4430dd0b2b8 100644 --- a/gdb/break-catch-sig.c +++ b/gdb/break-catch-sig.c @@ -40,8 +40,10 @@ =20 struct signal_catchpoint : public breakpoint { - signal_catchpoint (std::vector &&sigs, bool catch_all_) - : signals_to_be_caught (std::move (sigs)), + signal_catchpoint (struct gdbarch *gdbarch, std::vector &&si= gs, + bool catch_all_) + : breakpoint (gdbarch, bp_catchpoint), + signals_to_be_caught (std::move (sigs)), catch_all (catch_all_) { } @@ -323,7 +325,7 @@ create_signal_catchpoint (int tempflag, std::vector &&filter, struct gdbarch *gdbarch =3D get_current_arch (); =20 std::unique_ptr c - (new signal_catchpoint (std::move (filter), catch_all)); + (new signal_catchpoint (gdbarch, std::move (filter), catch_all)); init_catchpoint (c.get (), gdbarch, tempflag, nullptr); =20 install_breakpoint (0, std::move (c), 1); diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index d25d7ba7c5e..5ed15ac8bf9 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -37,8 +37,9 @@ =20 struct syscall_catchpoint : public breakpoint { - explicit syscall_catchpoint (std::vector &&calls) - : syscalls_to_be_caught (std::move (calls)) + syscall_catchpoint (struct gdbarch *gdbarch, std::vector &&calls) + : breakpoint (gdbarch, bp_catchpoint), + syscalls_to_be_caught (std::move (calls)) { } =20 @@ -353,7 +354,7 @@ create_syscall_event_catchpoint (int tempflag, std::vec= tor &&filter) struct gdbarch *gdbarch =3D get_current_arch (); =20 std::unique_ptr c - (new syscall_catchpoint (std::move (filter))); + (new syscall_catchpoint (gdbarch, std::move (filter))); init_catchpoint (c.get (), gdbarch, tempflag, nullptr); =20 install_breakpoint (0, std::move (c), 1); diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 59e73da2c28..0237af7b2a7 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -67,9 +67,11 @@ static const struct exception_names exception_functions[= ] =3D =20 struct exception_catchpoint : public base_breakpoint { - exception_catchpoint (enum exception_event_kind kind_, + exception_catchpoint (struct gdbarch *gdbarch, + enum exception_event_kind kind_, std::string &&except_rx) - : kind (kind_), + : base_breakpoint (gdbarch, bp_catchpoint), + kind (kind_), exception_rx (std::move (except_rx)), pattern (exception_rx.empty () ? nullptr @@ -366,10 +368,12 @@ handle_gnu_v3_exceptions (int tempflag, std::string &= &except_rx, const char *cond_string, enum exception_event_kind ex_event, int from_tty) { + struct gdbarch *gdbarch =3D get_current_arch (); + std::unique_ptr cp - (new exception_catchpoint (ex_event, std::move (except_rx))); + (new exception_catchpoint (gdbarch, ex_event, std::move (except_rx))); =20 - init_catchpoint (cp.get (), get_current_arch (), tempflag, cond_string); + init_catchpoint (cp.get (), gdbarch, tempflag, cond_string); =20 cp->re_set (); =20 diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ef8a7001834..4c7542a52c8 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -258,6 +258,8 @@ static const struct breakpoint_ops tracepoint_probe_bre= akpoint_ops =3D /* The structure to be used in regular breakpoints. */ struct ordinary_breakpoint : public base_breakpoint { + using base_breakpoint::base_breakpoint; + int resources_needed (const struct bp_location *) override; enum print_stop_action print_it (const bpstat *bs) const override; void print_mention () const override; @@ -267,6 +269,8 @@ struct ordinary_breakpoint : public base_breakpoint /* Internal breakpoints. */ struct internal_breakpoint : public base_breakpoint { + using base_breakpoint::base_breakpoint; + void re_set () override; void check_status (struct bpstat *bs) override; enum print_stop_action print_it (const bpstat *bs) const override; @@ -276,6 +280,8 @@ struct internal_breakpoint : public base_breakpoint /* Momentary breakpoints. */ struct momentary_breakpoint : public base_breakpoint { + using base_breakpoint::base_breakpoint; + void re_set () override; void check_status (struct bpstat *bs) override; enum print_stop_action print_it (const bpstat *bs) const override; @@ -285,6 +291,8 @@ struct momentary_breakpoint : public base_breakpoint /* DPrintf breakpoints. */ struct dprintf_breakpoint : public ordinary_breakpoint { + using ordinary_breakpoint::ordinary_breakpoint; + void re_set () override; int breakpoint_hit (const struct bp_location *bl, const address_space *aspace, @@ -297,6 +305,11 @@ struct dprintf_breakpoint : public ordinary_breakpoint /* Ranged breakpoints. */ struct ranged_breakpoint : public ordinary_breakpoint { + explicit ranged_breakpoint (struct gdbarch *gdbarch) + : ordinary_breakpoint (gdbarch, bp_hardware_breakpoint) + { + } + int breakpoint_hit (const struct bp_location *bl, const address_space *aspace, CORE_ADDR bp_addr, @@ -312,6 +325,8 @@ struct ranged_breakpoint : public ordinary_breakpoint /* Static tracepoints with marker (`-m'). */ struct static_marker_tracepoint : public tracepoint { + using tracepoint::tracepoint; + std::vector decode_location (struct event_location *location, struct program_space *search_pspace) override; @@ -1193,6 +1208,8 @@ check_no_tracepoint_commands (struct command_line *co= mmands) =20 struct longjmp_breakpoint : public momentary_breakpoint { + using momentary_breakpoint::momentary_breakpoint; + ~longjmp_breakpoint () override; }; =20 @@ -1219,7 +1236,7 @@ is_tracepoint (const struct breakpoint *b) TYPE. */ =20 static std::unique_ptr -new_breakpoint_from_type (bptype type) +new_breakpoint_from_type (struct gdbarch *gdbarch, bptype type) { breakpoint *b; =20 @@ -1227,21 +1244,21 @@ new_breakpoint_from_type (bptype type) { case bp_breakpoint: case bp_hardware_breakpoint: - b =3D new ordinary_breakpoint (); + b =3D new ordinary_breakpoint (gdbarch, type); break; =20 case bp_fast_tracepoint: case bp_static_tracepoint: case bp_tracepoint: - b =3D new tracepoint (); + b =3D new tracepoint (gdbarch, type); break; =20 case bp_static_marker_tracepoint: - b =3D new static_marker_tracepoint (); + b =3D new static_marker_tracepoint (gdbarch, type); break; =20 case bp_dprintf: - b =3D new dprintf_breakpoint (); + b =3D new dprintf_breakpoint (gdbarch, type); break; =20 case bp_overlay_event: @@ -1251,12 +1268,12 @@ new_breakpoint_from_type (bptype type) case bp_thread_event: case bp_jit_event: case bp_shlib_event: - b =3D new internal_breakpoint (); + b =3D new internal_breakpoint (gdbarch, type); break; =20 case bp_longjmp: case bp_exception: - b =3D new longjmp_breakpoint (); + b =3D new longjmp_breakpoint (gdbarch, type); break; =20 case bp_watchpoint_scope: @@ -1270,7 +1287,7 @@ new_breakpoint_from_type (bptype type) case bp_call_dummy: case bp_until: case bp_std_terminate: - b =3D new momentary_breakpoint (); + b =3D new momentary_breakpoint (gdbarch, type); break; =20 default: @@ -7215,20 +7232,6 @@ add_to_breakpoint_chain (std::unique_ptr= &&b) return result; } =20 -/* Initializes breakpoint B with type BPTYPE and no locations yet. */ - -static void -init_raw_breakpoint_without_location (struct breakpoint *b, - struct gdbarch *gdbarch, - enum bptype bptype) -{ - b->type =3D bptype; - b->gdbarch =3D gdbarch; - b->language =3D current_language->la_language; - b->input_radix =3D input_radix; - b->related_breakpoint =3D b; -} - /* Helper to set_raw_breakpoint below. Creates a breakpoint that has type BPTYPE and has no locations as yet. */ =20 @@ -7236,9 +7239,8 @@ static struct breakpoint * set_raw_breakpoint_without_location (struct gdbarch *gdbarch, enum bptype bptype) { - std::unique_ptr b =3D new_breakpoint_from_type (bptype); + std::unique_ptr b =3D new_breakpoint_from_type (gdbarch, bpt= ype); =20 - init_raw_breakpoint_without_location (b.get (), gdbarch, bptype); return add_to_breakpoint_chain (std::move (b)); } =20 @@ -7303,11 +7305,9 @@ get_sal_arch (struct symtab_and_line sal) information regarding the creation of a new breakpoint. */ =20 static void -init_raw_breakpoint (struct breakpoint *b, struct gdbarch *gdbarch, - struct symtab_and_line sal, enum bptype bptype) +init_raw_breakpoint (struct breakpoint *b, struct symtab_and_line sal, + enum bptype bptype) { - init_raw_breakpoint_without_location (b, gdbarch, bptype); - add_location_to_breakpoint (b, &sal); =20 if (bptype !=3D bp_catchpoint) @@ -7339,9 +7339,9 @@ static struct breakpoint * set_raw_breakpoint (struct gdbarch *gdbarch, struct symtab_and_line sal, enum bptype bptype) { - std::unique_ptr b =3D new_breakpoint_from_type (bptype); + std::unique_ptr b =3D new_breakpoint_from_type (gdbarch, bpt= ype); =20 - init_raw_breakpoint (b.get (), gdbarch, sal, bptype); + init_raw_breakpoint (b.get (), sal, bptype); return add_to_breakpoint_chain (std::move (b)); } =20 @@ -7812,7 +7812,9 @@ init_catchpoint (struct breakpoint *b, symtab_and_line sal; sal.pspace =3D current_program_space; =20 - init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint); + /* This should already have been set in the constructor. */ + gdb_assert (b->type =3D=3D bp_catchpoint); + init_raw_breakpoint (b, sal, bp_catchpoint); =20 if (cond_string =3D=3D nullptr) b->cond_string.reset (); @@ -7944,9 +7946,8 @@ enable_breakpoints_after_startup (void) static struct breakpoint * new_single_step_breakpoint (int thread, struct gdbarch *gdbarch) { - std::unique_ptr b (new momentary_breakpoint ()); - - init_raw_breakpoint_without_location (b.get (), gdbarch, bp_single_step); + std::unique_ptr b (new momentary_breakpoint (gdbarch, + bp_single_step)); =20 b->disposition =3D disp_donttouch; b->frame_id =3D null_frame_id; @@ -8325,7 +8326,7 @@ init_breakpoint_sal (struct breakpoint *b, struct gdb= arch *gdbarch, =20 if (&sal =3D=3D &sals[0]) { - init_raw_breakpoint (b, gdbarch, sal, type); + init_raw_breakpoint (b, sal, type); b->thread =3D thread; b->task =3D task; =20 @@ -8435,7 +8436,7 @@ create_breakpoint_sal (struct gdbarch *gdbarch, int enabled, int internal, unsigned flags, int display_canonical) { - std::unique_ptr b =3D new_breakpoint_from_type (type); + std::unique_ptr b =3D new_breakpoint_from_type (gdbarch, typ= e); =20 init_breakpoint_sal (b.get (), gdbarch, sals, std::move (location), @@ -8984,9 +8985,8 @@ create_breakpoint (struct gdbarch *gdbarch, } else { - std::unique_ptr b =3D new_breakpoint_from_type (type_wa= nted); - - init_raw_breakpoint_without_location (b.get (), gdbarch, type_wanted= ); + std::unique_ptr b =3D new_breakpoint_from_type (gdbarch, + type_wanted); b->location =3D copy_event_location (location); =20 if (parse_extra) @@ -9432,9 +9432,8 @@ break_range_command (const char *arg, int from_tty) } =20 /* Now set up the breakpoint. */ - std::unique_ptr br (new ranged_breakpoint ()); - init_raw_breakpoint (br.get (), get_current_arch (), - sal_start, bp_hardware_breakpoint); + std::unique_ptr br (new ranged_breakpoint (get_current_arch = ())); + init_raw_breakpoint (br.get (), sal_start, bp_hardware_breakpoint); b =3D add_to_breakpoint_chain (std::move (br)); =20 set_breakpoint_count (breakpoint_count + 1); @@ -9729,6 +9728,8 @@ watchpoint::explains_signal (enum gdb_signal sig) =20 struct masked_watchpoint : public watchpoint { + using watchpoint::watchpoint; + int insert_location (struct bp_location *) override; int remove_location (struct bp_location *, enum remove_bp_reason reason) override; @@ -10164,10 +10165,9 @@ watch_command_1 (const char *arg, int accessflag, = int from_tty, =20 std::unique_ptr w; if (use_mask) - w.reset (new masked_watchpoint ()); + w.reset (new masked_watchpoint (nullptr, bp_type)); else - w.reset (new watchpoint ()); - init_raw_breakpoint_without_location (w.get (), nullptr, bp_type); + w.reset (new watchpoint (nullptr, bp_type)); =20 w->thread =3D thread; w->task =3D task; @@ -10620,7 +10620,7 @@ init_ada_exception_breakpoint (struct breakpoint *b, enough for now, though. */ } =20 - init_raw_breakpoint (b, gdbarch, sal, bp_catchpoint); + init_raw_breakpoint (b, sal, bp_catchpoint); =20 b->enable_state =3D enabled ? bp_enabled : bp_disabled; b->disposition =3D tempflag ? disp_del : disp_donttouch; @@ -12154,7 +12154,8 @@ strace_marker_create_breakpoints_sal (struct gdbarc= h *gdbarch, event_location_up location =3D copy_event_location (canonical->location.get ()); =20 - std::unique_ptr tp (new tracepoint ()); + std::unique_ptr tp (new tracepoint (gdbarch, + type_wanted)); init_breakpoint_sal (tp.get (), gdbarch, lsal.sals[i], std::move (location), NULL, std::move (cond_string), diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 6923478f60a..356af45accd 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -620,7 +620,15 @@ using bp_location_range =3D next_range; =20 struct breakpoint { - breakpoint () =3D default; + breakpoint (struct gdbarch *gdbarch_, enum bptype bptype) + : type (bptype), + gdbarch (gdbarch_), + language (current_language->la_language), + input_radix (::input_radix), + related_breakpoint (this) + { + } + DISABLE_COPY_AND_ASSIGN (breakpoint); =20 virtual ~breakpoint () =3D default; @@ -784,11 +792,11 @@ struct breakpoint event_location_up location_range_end; =20 /* Architecture we used to set the breakpoint. */ - struct gdbarch *gdbarch =3D NULL; + struct gdbarch *gdbarch; /* Language we used to set the breakpoint. */ - enum language language =3D language_unknown; + enum language language; /* Input radix we used to set the breakpoint. */ - int input_radix =3D 0; + int input_radix; /* String form of the breakpoint condition (malloc'd), or NULL if there is no condition. */ gdb::unique_xmalloc_ptr cond_string; @@ -801,7 +809,7 @@ struct breakpoint using watchpoints on local variables (might the concept of a related breakpoint be useful elsewhere, if not just call it the watchpoint_scope breakpoint or something like that. FIXME). */ - breakpoint *related_breakpoint =3D NULL; + breakpoint *related_breakpoint; =20 /* Thread number for thread-specific breakpoint, or -1 if don't care. */ @@ -849,6 +857,8 @@ protected: breakpoints, etc.). */ struct base_breakpoint : public breakpoint { + using breakpoint::breakpoint; + void re_set () override; int insert_location (struct bp_location *) override; int remove_location (struct bp_location *, @@ -866,6 +876,8 @@ struct base_breakpoint : public breakpoint =20 struct watchpoint : public breakpoint { + using breakpoint::breakpoint; + void re_set () override; int insert_location (struct bp_location *) override; int remove_location (struct bp_location *, @@ -959,6 +971,8 @@ extern bool is_exception_catchpoint (breakpoint *bp); =20 struct tracepoint : public breakpoint { + using breakpoint::breakpoint; + void re_set () override; int breakpoint_hit (const struct bp_location *bl, const address_space *aspace, CORE_ADDR bp_addr,