From: Pedro Alves <pedro@palves.net>
To: gdb-patches@sourceware.org
Subject: [PATCH 18/23] Move add_location(sal) to base_breakpoint
Date: Mon, 16 May 2022 19:40:25 +0100 [thread overview]
Message-ID: <20220516184030.665489-19-pedro@palves.net> (raw)
In-Reply-To: <20220516184030.665489-1-pedro@palves.net>
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
---
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 4dce43b1e6b..613f6a875e4 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;
@@ -12480,7 +12462,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)
@@ -12688,7 +12670,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;
@@ -13399,15 +13381,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 af69af6863b..807c97a5bed 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 b136c605b1a..27203722802 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 cbd0ad22392..217ee047446 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 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;
/* 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
--
2.36.0
next prev parent reply other threads:[~2022-05-16 18:41 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 18:40 [PATCH 00/23] More breakpoints cleanups Pedro Alves
2022-05-16 18:40 ` [PATCH 01/23] add_location_to_breakpoint -> breakpoint::add_location Pedro Alves
2022-05-16 18:40 ` [PATCH 02/23] Make structs breakpoint/base_breakpoint/catchpoint be abstract Pedro Alves
2022-05-16 18:40 ` [PATCH 03/23] ranged_breakpoint: don't use init_raw_breakpoint Pedro Alves
2022-05-16 18:40 ` [PATCH 04/23] ranged_breakpoint, use install_breakpoint Pedro Alves
2022-05-16 18:40 ` [PATCH 05/23] ranged_breakpoint - move initialization to ctor Pedro Alves
2022-05-16 18:40 ` [PATCH 06/23] Make a few functions work with base_breakpoint instead of breakpoint Pedro Alves
2022-05-16 18:40 ` [PATCH 07/23] More breakpoint_ops parameter elimination Pedro Alves
2022-05-16 18:40 ` [PATCH 08/23] Remove "internal" parameter from a couple functions Pedro Alves
2022-05-16 18:40 ` [PATCH 09/23] init_breakpoint_sal -> base_breakpoint::base_breakpoint Pedro Alves
2022-05-20 13:40 ` Lancelot SIX
2022-05-20 19:20 ` Pedro Alves
2022-05-16 18:40 ` [PATCH 10/23] Make ada_catchpoint_location's owner ctor parameter be ada_catchpoint Pedro Alves
2022-05-16 18:40 ` [PATCH 11/23] Convert init_ada_exception_catchpoint to a ctor Pedro Alves
2022-05-16 18:40 ` [PATCH 12/23] Refactor set_internal_breakpoint / internal_breakpoint ctor Pedro Alves
2022-05-16 18:40 ` [PATCH 13/23] Refactor momentary breakpoints, eliminate set_raw_breakpoint{, _without_location} Pedro Alves
2022-05-16 18:40 ` [PATCH 14/23] Make exception_catchpoint inherit base_breakpoint instead of catchpoint Pedro Alves
2022-05-16 18:40 ` [PATCH 15/23] Make breakpoint_address_bits look at the location kind Pedro Alves
2022-05-16 18:40 ` [PATCH 16/23] Make catchpoint inherit breakpoint, eliminate init_raw_breakpoint Pedro Alves
2022-05-16 18:40 ` [PATCH 17/23] Move common bits of catchpoint/exception_catchpoint to breakpoint's ctor Pedro Alves
2022-05-16 18:40 ` Pedro Alves [this message]
2022-05-16 18:40 ` [PATCH 19/23] Add/tweak intro comments of struct breakpoint and several subclasses Pedro Alves
2022-05-16 18:40 ` [PATCH 20/23] Momentary breakpoints should have no breakpoint number Pedro Alves
2022-05-20 16:00 ` Tom Tromey
2022-05-20 19:25 ` Pedro Alves
2022-05-16 18:40 ` [PATCH 21/23] Make sure momentary breakpoints are always thread-specific Pedro Alves
2022-05-16 18:40 ` [PATCH 22/23] Test "set multiple-symbols on" creating multiple breakpoints Pedro Alves
2022-05-16 18:40 ` [PATCH 23/23] Rename base_breakpoint -> code_breakpoint Pedro Alves
2022-05-20 16:05 ` Tom Tromey
2022-05-20 16:06 ` [PATCH 00/23] More breakpoints cleanups Tom Tromey
2022-05-20 19:43 ` Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220516184030.665489-19-pedro@palves.net \
--to=pedro@palves.net \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).