From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id 99E43383088B; Fri, 20 May 2022 19:43:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 99E43383088B Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pedro Alves To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Move add_location(sal) to base_breakpoint X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: 92bb0228c8293ec78c0efcd556b1f115b6e1b3f4 X-Git-Newrev: 960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863 Message-Id: <20220520194354.99E43383088B@sourceware.org> Date: Fri, 20 May 2022 19:43:54 +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, 20 May 2022 19:43:54 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D960bc2bd1402= bb5e8312e731d6a7f6fe2b6a9863 commit 960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863 Author: Pedro Alves Date: Thu May 12 18:58:38 2022 +0100 Move add_location(sal) to base_breakpoint =20 After the previous patches, only base_breakpoint subclasses use add_location(sal), so we can move it to base_breakpoint (a.k.a. base class for code breakpoints). =20 This requires a few casts here and there, but always at spots where you can see from context what the breakpoint's type actually is. =20 I inlined new_single_step_breakpoint into its only caller exactly for this reason. =20 I did try to propagate more use of base_breakpoint to avoid casts, but that turned out unwieldy for this patch. =20 Change-Id: I49d959322b0fdce5a88a216bb44730fc5dd7c6f8 Diff: --- gdb/breakpoint.c | 45 +++++++++++++++++++-------------------------- gdb/breakpoint.h | 8 ++++---- gdb/elfread.c | 6 +++--- gdb/minsyms.c | 4 ++-- gdb/symtab.h | 5 +++-- 5 files changed, 31 insertions(+), 37 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index bfb5cd37ecd..b6e31836df1 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -87,7 +87,7 @@ static void map_breakpoint_numbers (const char *, gdb::function_view); =20 -static void breakpoint_re_set_default (struct breakpoint *); +static void breakpoint_re_set_default (base_breakpoint *); =20 static void create_sals_from_location_default (struct event_location *location, @@ -5860,10 +5860,10 @@ bpstat_run_callbacks (bpstat *bs_head) handle_jit_event (bs->bp_location_at->address); break; case bp_gnu_ifunc_resolver: - gnu_ifunc_resolver_stop (b); + gnu_ifunc_resolver_stop ((base_breakpoint *) b); break; case bp_gnu_ifunc_resolver_return: - gnu_ifunc_resolver_return_stop (b); + gnu_ifunc_resolver_return_stop ((base_breakpoint *) b); break; } } @@ -7867,24 +7867,6 @@ enable_breakpoints_after_startup (void) breakpoint_re_set (); } =20 -/* Create a new single-step breakpoint for thread THREAD, with no - locations. */ - -static struct breakpoint * -new_single_step_breakpoint (int thread, struct gdbarch *gdbarch) -{ - std::unique_ptr b (new momentary_breakpoint (gdbarch, - bp_single_step)); - - b->disposition =3D disp_donttouch; - b->frame_id =3D null_frame_id; - - b->thread =3D thread; - gdb_assert (b->thread !=3D 0); - - return add_to_breakpoint_chain (std::move (b)); -} - /* Allocate a new momentary breakpoint. */ =20 static momentary_breakpoint * @@ -8057,7 +8039,7 @@ handle_automatic_hardware_breakpoints (bp_location *b= l) } =20 bp_location * -breakpoint::add_location (const symtab_and_line &sal) +base_breakpoint::add_location (const symtab_and_line &sal) { struct bp_location *new_loc, **tmp; CORE_ADDR adjusted_address; @@ -12476,7 +12458,7 @@ hoist_existing_locations (struct breakpoint *b, str= uct program_space *pspace) untouched. */ =20 void -update_breakpoint_locations (struct breakpoint *b, +update_breakpoint_locations (base_breakpoint *b, struct program_space *filter_pspace, gdb::array_view sals, gdb::array_view sals_end) @@ -12684,7 +12666,7 @@ location_to_sals (struct breakpoint *b, struct even= t_location *location, locations. */ =20 static void -breakpoint_re_set_default (struct breakpoint *b) +breakpoint_re_set_default (base_breakpoint *b) { struct program_space *filter_pspace =3D current_program_space; std::vector expanded, expanded_end; @@ -13395,15 +13377,26 @@ insert_single_step_breakpoint (struct gdbarch *gd= barch, =20 if (tp->control.single_step_breakpoints =3D=3D NULL) { + std::unique_ptr b + (new momentary_breakpoint (gdbarch, bp_single_step)); + + b->disposition =3D disp_donttouch; + + b->thread =3D tp->global_num; + gdb_assert (b->thread !=3D 0); + tp->control.single_step_breakpoints - =3D new_single_step_breakpoint (tp->global_num, gdbarch); + =3D add_to_breakpoint_chain (std::move (b)); } =20 sal =3D find_pc_line (pc, 0); sal.pc =3D pc; sal.section =3D find_pc_overlay (pc); sal.explicit_pc =3D 1; - tp->control.single_step_breakpoints->add_location (sal); + + auto *ss_bp + =3D static_cast (tp->control.single_step_break= points); + ss_bp->add_location (sal); =20 update_global_location_list (UGLL_INSERT); } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index af69af6863b..807c97a5bed 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -733,9 +733,6 @@ struct breakpoint /* Nothing to do. */ } =20 - /* Add a location for SAL to this breakpoint. */ - bp_location *add_location (const symtab_and_line &sal); - /* Return a range of this breakpoint's locations. */ bp_location_range locations () const; =20 @@ -874,6 +871,9 @@ struct base_breakpoint : public breakpoint =20 ~base_breakpoint () override =3D 0; =20 + /* Add a location for SAL to this breakpoint. */ + bp_location *add_location (const symtab_and_line &sal); + void re_set () override; int insert_location (struct bp_location *) override; int remove_location (struct bp_location *, @@ -1383,7 +1383,7 @@ extern void until_break_command (const char *, int, i= nt); /* Initialize a struct bp_location. */ =20 extern void update_breakpoint_locations - (struct breakpoint *b, + (base_breakpoint *b, struct program_space *filter_pspace, gdb::array_view sals, gdb::array_view sals_end); diff --git a/gdb/elfread.c b/gdb/elfread.c index b136c605b1a..27203722802 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -927,7 +927,7 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CO= RE_ADDR pc) /* Handle inferior hit of bp_gnu_ifunc_resolver, see its definition. */ =20 static void -elf_gnu_ifunc_resolver_stop (struct breakpoint *b) +elf_gnu_ifunc_resolver_stop (base_breakpoint *b) { struct breakpoint *b_return; struct frame_info *prev_frame =3D get_prev_frame (get_current_frame ()); @@ -978,7 +978,7 @@ elf_gnu_ifunc_resolver_stop (struct breakpoint *b) /* Handle inferior hit of bp_gnu_ifunc_resolver_return, see its definition= . */ =20 static void -elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b) +elf_gnu_ifunc_resolver_return_stop (base_breakpoint *b) { thread_info *thread =3D inferior_thread (); struct gdbarch *gdbarch =3D get_frame_arch (get_current_frame ()); @@ -1008,7 +1008,7 @@ elf_gnu_ifunc_resolver_return_stop (struct breakpoint= *b) "gnu-indirect-function breakpoint type %d"), (int) b->type); } - b =3D b_next; + b =3D (base_breakpoint *) b_next; } gdb_assert (b->type =3D=3D bp_gnu_ifunc_resolver); gdb_assert (b->loc->next =3D=3D NULL); diff --git a/gdb/minsyms.c b/gdb/minsyms.c index cbd0ad22392..217ee047446 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1019,7 +1019,7 @@ stub_gnu_ifunc_resolve_name (const char *function_nam= e, /* See elf_gnu_ifunc_resolver_stop for its real implementation. */ =20 static void -stub_gnu_ifunc_resolver_stop (struct breakpoint *b) +stub_gnu_ifunc_resolver_stop (base_breakpoint *b) { internal_error (__FILE__, __LINE__, _("elf_gnu_ifunc_resolver_stop cannot be reached.")); @@ -1028,7 +1028,7 @@ stub_gnu_ifunc_resolver_stop (struct breakpoint *b) /* See elf_gnu_ifunc_resolver_return_stop for its real implementation. */ =20 static void -stub_gnu_ifunc_resolver_return_stop (struct breakpoint *b) +stub_gnu_ifunc_resolver_return_stop (base_breakpoint *b) { internal_error (__FILE__, __LINE__, _("elf_gnu_ifunc_resolver_return_stop cannot be reached.")); diff --git a/gdb/symtab.h b/gdb/symtab.h index b1cf84f756f..5218be587de 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -55,6 +55,7 @@ struct obj_section; struct cmd_list_element; class probe; struct lookup_name_info; +struct base_breakpoint; =20 /* How to match a lookup name against a symbol search name. */ enum class symbol_name_match_type @@ -2227,10 +2228,10 @@ struct gnu_ifunc_fns CORE_ADDR *function_address_p); =20 /* See elf_gnu_ifunc_resolver_stop for its real implementation. */ - void (*gnu_ifunc_resolver_stop) (struct breakpoint *b); + void (*gnu_ifunc_resolver_stop) (base_breakpoint *b); =20 /* See elf_gnu_ifunc_resolver_return_stop for its real implementation. = */ - void (*gnu_ifunc_resolver_return_stop) (struct breakpoint *b); + void (*gnu_ifunc_resolver_return_stop) (base_breakpoint *b); }; =20 #define gnu_ifunc_resolve_addr gnu_ifunc_fns_p->gnu_ifunc_resolve_addr