diff options
author | Pedro Alves <pedro@palves.net> | 2022-05-12 18:58:38 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2022-05-20 20:41:01 +0100 |
commit | 960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863 (patch) | |
tree | aff30b1e20a126c1acb744b6989de77ed62947b5 /gdb | |
parent | 92bb0228c8293ec78c0efcd556b1f115b6e1b3f4 (diff) | |
download | gdb-960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863.zip gdb-960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863.tar.gz gdb-960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863.tar.bz2 |
Move add_location(sal) to base_breakpoint
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).
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.
I inlined new_single_step_breakpoint into its only caller exactly for
this reason.
I did try to propagate more use of base_breakpoint to avoid casts, but
that turned out unwieldy for this patch.
Change-Id: I49d959322b0fdce5a88a216bb44730fc5dd7c6f8
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/breakpoint.c | 45 | ||||
-rw-r--r-- | gdb/breakpoint.h | 8 | ||||
-rw-r--r-- | gdb/elfread.c | 6 | ||||
-rw-r--r-- | gdb/minsyms.c | 4 | ||||
-rw-r--r-- | gdb/symtab.h | 5 |
5 files changed, 31 insertions, 37 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index bfb5cd3..b6e3183 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -87,7 +87,7 @@ static void map_breakpoint_numbers (const char *, gdb::function_view<void (breakpoint *)>); -static void breakpoint_re_set_default (struct breakpoint *); +static void breakpoint_re_set_default (base_breakpoint *); 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 (); } -/* 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<breakpoint> b (new momentary_breakpoint (gdbarch, - bp_single_step)); - - b->disposition = disp_donttouch; - b->frame_id = null_frame_id; - - b->thread = thread; - gdb_assert (b->thread != 0); - - return add_to_breakpoint_chain (std::move (b)); -} - /* Allocate a new momentary breakpoint. */ static momentary_breakpoint * @@ -8057,7 +8039,7 @@ handle_automatic_hardware_breakpoints (bp_location *bl) } 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, struct program_space *pspace) untouched. */ void -update_breakpoint_locations (struct breakpoint *b, +update_breakpoint_locations (base_breakpoint *b, struct program_space *filter_pspace, gdb::array_view<const symtab_and_line> sals, gdb::array_view<const symtab_and_line> sals_end) @@ -12684,7 +12666,7 @@ location_to_sals (struct breakpoint *b, struct event_location *location, locations. */ static void -breakpoint_re_set_default (struct breakpoint *b) +breakpoint_re_set_default (base_breakpoint *b) { struct program_space *filter_pspace = current_program_space; std::vector<symtab_and_line> expanded, expanded_end; @@ -13395,15 +13377,26 @@ insert_single_step_breakpoint (struct gdbarch *gdbarch, if (tp->control.single_step_breakpoints == NULL) { + std::unique_ptr<breakpoint> b + (new momentary_breakpoint (gdbarch, bp_single_step)); + + b->disposition = disp_donttouch; + + b->thread = tp->global_num; + gdb_assert (b->thread != 0); + tp->control.single_step_breakpoints - = new_single_step_breakpoint (tp->global_num, gdbarch); + = add_to_breakpoint_chain (std::move (b)); } sal = find_pc_line (pc, 0); sal.pc = pc; sal.section = find_pc_overlay (pc); sal.explicit_pc = 1; - tp->control.single_step_breakpoints->add_location (sal); + + auto *ss_bp + = static_cast<momentary_breakpoint *> (tp->control.single_step_breakpoints); + ss_bp->add_location (sal); update_global_location_list (UGLL_INSERT); } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index af69af6..807c97a 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -733,9 +733,6 @@ struct breakpoint /* Nothing to do. */ } - /* 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; @@ -874,6 +871,9 @@ struct base_breakpoint : public breakpoint ~base_breakpoint () override = 0; + /* 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, int); /* Initialize a struct bp_location. */ extern void update_breakpoint_locations - (struct breakpoint *b, + (base_breakpoint *b, struct program_space *filter_pspace, gdb::array_view<const symtab_and_line> sals, gdb::array_view<const symtab_and_line> sals_end); diff --git a/gdb/elfread.c b/gdb/elfread.c index b136c60..2720372 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -927,7 +927,7 @@ elf_gnu_ifunc_resolve_addr (struct gdbarch *gdbarch, CORE_ADDR pc) /* Handle inferior hit of bp_gnu_ifunc_resolver, see its definition. */ 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 = 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. */ static void -elf_gnu_ifunc_resolver_return_stop (struct breakpoint *b) +elf_gnu_ifunc_resolver_return_stop (base_breakpoint *b) { thread_info *thread = inferior_thread (); struct gdbarch *gdbarch = 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 = b_next; + b = (base_breakpoint *) b_next; } gdb_assert (b->type == bp_gnu_ifunc_resolver); gdb_assert (b->loc->next == NULL); diff --git a/gdb/minsyms.c b/gdb/minsyms.c index cbd0ad2..217ee04 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -1019,7 +1019,7 @@ stub_gnu_ifunc_resolve_name (const char *function_name, /* See elf_gnu_ifunc_resolver_stop for its real implementation. */ 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. */ 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 b1cf84f..5218be5 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; /* 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); /* 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); /* 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); }; #define gnu_ifunc_resolve_addr gnu_ifunc_fns_p->gnu_ifunc_resolve_addr |