aboutsummaryrefslogtreecommitdiff
path: root/gdb/breakpoint.c
diff options
context:
space:
mode:
authorPedro Alves <pedro@palves.net>2022-05-12 18:58:38 +0100
committerPedro Alves <pedro@palves.net>2022-05-20 20:41:01 +0100
commit960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863 (patch)
treeaff30b1e20a126c1acb744b6989de77ed62947b5 /gdb/breakpoint.c
parent92bb0228c8293ec78c0efcd556b1f115b6e1b3f4 (diff)
downloadfsf-binutils-gdb-960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863.zip
fsf-binutils-gdb-960bc2bd1402bb5e8312e731d6a7f6fe2b6a9863.tar.gz
fsf-binutils-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/breakpoint.c')
-rw-r--r--gdb/breakpoint.c45
1 files changed, 19 insertions, 26 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);
}