From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 20/36] Convert ordinary breakpoints to vtable ops
Date: Tue, 18 Jan 2022 12:39:51 -0700 [thread overview]
Message-ID: <20220118194007.2853108-21-tom@tromey.com> (raw)
In-Reply-To: <20220118194007.2853108-1-tom@tromey.com>
This converts "ordinary" breakpoint to use vtable_breakpoint_ops.
Recall that an ordinary breakpoint is both the kind normally created
by users, and also a base class used by other classes.
---
gdb/ada-lang.c | 4 +-
gdb/breakpoint.c | 94 ++++++++++++++------------------
gdb/breakpoint.h | 1 -
gdb/mi/mi-cmd-break.c | 2 +-
gdb/python/py-finishbreakpoint.c | 2 +-
5 files changed, 45 insertions(+), 58 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a2a6275fb5f..6df770d27cd 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -11728,7 +11728,7 @@ re_set_exception (struct breakpoint *b)
/* Call the base class's method. This updates the catchpoint's
locations. */
- bkpt_breakpoint_ops.re_set (b);
+ b->re_set ();
/* Reparse the exception conditional expressions. One for each
location. */
@@ -13407,7 +13407,7 @@ initialize_ada_catchpoint_ops (void)
initialize_breakpoint_ops ();
ops = &catch_exception_breakpoint_ops;
- *ops = bkpt_breakpoint_ops;
+ *ops = vtable_breakpoint_ops;
ops->allocate_location = allocate_location_exception;
ops->re_set = re_set_exception;
ops->check_status = check_status_exception;
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index d96d0163785..4b2f97d1173 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -234,10 +234,6 @@ static int strace_marker_p (struct breakpoint *b);
(user breakpoints, internal and momentary breakpoints, etc.). */
static struct breakpoint_ops bkpt_base_breakpoint_ops;
-/* The breakpoint_ops structure to be used in regular user created
- breakpoints. */
-struct breakpoint_ops bkpt_breakpoint_ops;
-
/* Breakpoints set on probes. */
static struct breakpoint_ops bkpt_probe_breakpoint_ops;
@@ -250,6 +246,10 @@ struct breakpoint_ops dprintf_breakpoint_ops;
/* The structure to be used in regular breakpoints. */
struct ordinary_breakpoint : public base_breakpoint
{
+ int resources_needed (const struct bp_location *) override;
+ enum print_stop_action print_it (struct bpstat *bs) override;
+ void print_mention () override;
+ void print_recreate (struct ui_file *fp) override;
};
/* Internal breakpoints. */
@@ -8752,7 +8752,7 @@ breakpoint_ops_for_event_location_type (enum event_location_type location_type,
if (location_type == PROBE_LOCATION)
return &bkpt_probe_breakpoint_ops;
else
- return &bkpt_breakpoint_ops;
+ return &vtable_breakpoint_ops;
}
}
@@ -8765,7 +8765,7 @@ breakpoint_ops_for_event_location (const struct event_location *location,
if (location != nullptr)
return breakpoint_ops_for_event_location_type
(event_location_type (location), is_tracepoint);
- return is_tracepoint ? &vtable_breakpoint_ops : &bkpt_breakpoint_ops;
+ return &vtable_breakpoint_ops;
}
/* See breakpoint.h. */
@@ -11888,105 +11888,101 @@ dprintf_breakpoint_hit (const struct bp_location *bl,
return bl->owner->breakpoint_hit (bl, aspace, bp_addr, ws);
}
-static int
-bkpt_resources_needed (const struct bp_location *bl)
+int
+ordinary_breakpoint::resources_needed (const struct bp_location *bl)
{
- gdb_assert (bl->owner->type == bp_hardware_breakpoint);
+ gdb_assert (type == bp_hardware_breakpoint);
return 1;
}
-static enum print_stop_action
-bkpt_print_it (bpstat *bs)
+enum print_stop_action
+ordinary_breakpoint::print_it (bpstat *bs)
{
- struct breakpoint *b;
const struct bp_location *bl;
int bp_temp;
struct ui_out *uiout = current_uiout;
- gdb_assert (bs->bp_location_at != NULL);
-
bl = bs->bp_location_at.get ();
- b = bs->breakpoint_at;
- bp_temp = b->disposition == disp_del;
+ bp_temp = disposition == disp_del;
if (bl->address != bl->requested_address)
breakpoint_adjustment_warning (bl->requested_address,
bl->address,
- b->number, 1);
- annotate_breakpoint (b->number);
+ number, 1);
+ annotate_breakpoint (number);
maybe_print_thread_hit_breakpoint (uiout);
if (uiout->is_mi_like_p ())
{
uiout->field_string ("reason",
async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT));
- uiout->field_string ("disp", bpdisp_text (b->disposition));
+ uiout->field_string ("disp", bpdisp_text (disposition));
}
if (bp_temp)
uiout->message ("Temporary breakpoint %pF, ",
- signed_field ("bkptno", b->number));
+ signed_field ("bkptno", number));
else
uiout->message ("Breakpoint %pF, ",
- signed_field ("bkptno", b->number));
+ signed_field ("bkptno", number));
return PRINT_SRC_AND_LOC;
}
-static void
-bkpt_print_mention (struct breakpoint *b)
+void
+ordinary_breakpoint::print_mention ()
{
if (current_uiout->is_mi_like_p ())
return;
- switch (b->type)
+ switch (type)
{
case bp_breakpoint:
case bp_gnu_ifunc_resolver:
- if (b->disposition == disp_del)
+ if (disposition == disp_del)
printf_filtered (_("Temporary breakpoint"));
else
printf_filtered (_("Breakpoint"));
- printf_filtered (_(" %d"), b->number);
- if (b->type == bp_gnu_ifunc_resolver)
+ printf_filtered (_(" %d"), number);
+ if (type == bp_gnu_ifunc_resolver)
printf_filtered (_(" at gnu-indirect-function resolver"));
break;
case bp_hardware_breakpoint:
- printf_filtered (_("Hardware assisted breakpoint %d"), b->number);
+ printf_filtered (_("Hardware assisted breakpoint %d"), number);
break;
case bp_dprintf:
- printf_filtered (_("Dprintf %d"), b->number);
+ printf_filtered (_("Dprintf %d"), number);
break;
}
- say_where (b);
+ say_where (this);
}
-static void
-bkpt_print_recreate (struct breakpoint *tp, struct ui_file *fp)
+void
+ordinary_breakpoint::print_recreate (struct ui_file *fp)
{
- if (tp->type == bp_breakpoint && tp->disposition == disp_del)
+ if (type == bp_breakpoint && disposition == disp_del)
fprintf_unfiltered (fp, "tbreak");
- else if (tp->type == bp_breakpoint)
+ else if (type == bp_breakpoint)
fprintf_unfiltered (fp, "break");
- else if (tp->type == bp_hardware_breakpoint
- && tp->disposition == disp_del)
+ else if (type == bp_hardware_breakpoint
+ && disposition == disp_del)
fprintf_unfiltered (fp, "thbreak");
- else if (tp->type == bp_hardware_breakpoint)
+ else if (type == bp_hardware_breakpoint)
fprintf_unfiltered (fp, "hbreak");
else
internal_error (__FILE__, __LINE__,
- _("unhandled breakpoint type %d"), (int) tp->type);
+ _("unhandled breakpoint type %d"), (int) type);
fprintf_unfiltered (fp, " %s",
- event_location_to_string (tp->location.get ()));
+ event_location_to_string (location.get ()));
/* Print out extra_string if this breakpoint is pending. It might
contain, for example, conditions that were set by the user. */
- if (tp->loc == NULL && tp->extra_string != NULL)
- fprintf_unfiltered (fp, " %s", tp->extra_string.get ());
+ if (loc == NULL && extra_string != NULL)
+ fprintf_unfiltered (fp, " %s", extra_string.get ());
- print_recreate_thread (tp, fp);
+ print_recreate_thread (this, fp);
}
std::vector<symtab_and_line>
@@ -14573,17 +14569,9 @@ initialize_breakpoint_ops (void)
ops = &bkpt_base_breakpoint_ops;
*ops = vtable_breakpoint_ops;
- /* The breakpoint_ops structure to be used in regular breakpoints. */
- ops = &bkpt_breakpoint_ops;
- *ops = bkpt_base_breakpoint_ops;
- ops->resources_needed = bkpt_resources_needed;
- ops->print_it = bkpt_print_it;
- ops->print_mention = bkpt_print_mention;
- ops->print_recreate = bkpt_print_recreate;
-
/* Ranged breakpoints. */
ops = &ranged_breakpoint_ops;
- *ops = bkpt_breakpoint_ops;
+ *ops = vtable_breakpoint_ops;
ops->breakpoint_hit = breakpoint_hit_ranged_breakpoint;
ops->resources_needed = resources_needed_ranged_breakpoint;
ops->print_it = print_it_ranged_breakpoint;
@@ -14594,7 +14582,7 @@ initialize_breakpoint_ops (void)
/* Probe breakpoints. */
ops = &bkpt_probe_breakpoint_ops;
- *ops = bkpt_breakpoint_ops;
+ *ops = vtable_breakpoint_ops;
ops->insert_location = bkpt_probe_insert_location;
ops->remove_location = bkpt_probe_remove_location;
ops->create_sals_from_location = bkpt_probe_create_sals_from_location;
@@ -14614,7 +14602,7 @@ initialize_breakpoint_ops (void)
ops->decode_location = strace_marker_decode_location;
ops = &dprintf_breakpoint_ops;
- *ops = bkpt_breakpoint_ops;
+ *ops = vtable_breakpoint_ops;
ops->re_set = dprintf_re_set;
ops->print_recreate = dprintf_print_recreate;
ops->after_condition_true = dprintf_after_condition_true;
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 11b65ab8318..1ba78ecbb70 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1472,7 +1472,6 @@ extern void rwatch_command_wrapper (const char *, int, bool);
extern void tbreak_command (const char *, int);
extern struct breakpoint_ops base_breakpoint_ops;
-extern struct breakpoint_ops bkpt_breakpoint_ops;
extern struct breakpoint_ops dprintf_breakpoint_ops;
extern struct breakpoint_ops vtable_breakpoint_ops;
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index a5c78529dd1..0b8ae5d5910 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -332,7 +332,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
else
{
type_wanted = hardware ? bp_hardware_breakpoint : bp_breakpoint;
- ops = &bkpt_breakpoint_ops;
+ ops = &vtable_breakpoint_ops;
}
if (is_explicit)
diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c
index 8d5eb42efc0..00129b09240 100644
--- a/gdb/python/py-finishbreakpoint.c
+++ b/gdb/python/py-finishbreakpoint.c
@@ -300,7 +300,7 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs)
bp_breakpoint,
0,
AUTO_BOOLEAN_TRUE,
- &bkpt_breakpoint_ops,
+ &vtable_breakpoint_ops,
0, 1, internal_bp, 0);
}
catch (const gdb_exception &except)
--
2.31.1
next prev parent reply other threads:[~2022-01-18 19:40 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-18 19:39 [PATCH 00/36] C++-ify breakpoints Tom Tromey
2022-01-18 19:39 ` [PATCH 01/36] Move "catch load" to a new file Tom Tromey
2022-04-23 2:34 ` Simon Marchi
2022-04-24 19:35 ` Tom Tromey
2022-01-18 19:39 ` [PATCH 02/36] Boolify print_solib_event Tom Tromey
2022-01-18 19:39 ` [PATCH 03/36] Add an assertion to clone_momentary_breakpoint Tom Tromey
2022-04-25 13:25 ` Thiago Jung Bauermann
2022-04-25 19:03 ` Tom Tromey
2022-01-18 19:39 ` [PATCH 04/36] Delete some unnecessary wrapper functions Tom Tromey
2022-04-25 14:08 ` Thiago Jung Bauermann
2022-04-25 19:06 ` Tom Tromey
2022-04-25 20:06 ` Thiago Jung Bauermann
2022-01-18 19:39 ` [PATCH 05/36] Return bool from breakpoint_ops::print_one Tom Tromey
2022-01-18 19:39 ` [PATCH 06/36] Add a vtable-based breakpoint ops Tom Tromey
2022-01-18 19:39 ` [PATCH 07/36] Convert break-catch-sig to use vtable ops Tom Tromey
2022-01-18 19:39 ` [PATCH 08/36] Convert break-catch-syscall to " Tom Tromey
2022-01-18 19:39 ` [PATCH 09/36] Convert break-catch-exec " Tom Tromey
2022-01-18 19:39 ` [PATCH 10/36] Convert break-catch-fork " Tom Tromey
2022-01-18 19:39 ` [PATCH 11/36] Convert break-catch-load " Tom Tromey
2022-01-18 19:39 ` [PATCH 12/36] Convert watchpoints " Tom Tromey
2022-01-18 19:39 ` [PATCH 13/36] Convert tracepoints " Tom Tromey
2022-01-18 19:39 ` [PATCH 14/36] Add some new subclasses of breakpoint Tom Tromey
2022-01-18 19:39 ` [PATCH 15/36] Convert base breakpoints to vtable ops Tom Tromey
2022-05-02 10:27 ` Tom de Vries
2022-05-02 16:40 ` Tom Tromey
2022-01-18 19:39 ` [PATCH 16/36] Convert break-catch-throw " Tom Tromey
2022-01-18 19:39 ` [PATCH 17/36] Convert internal breakpoints " Tom Tromey
2022-01-18 19:39 ` [PATCH 18/36] Convert momentary " Tom Tromey
2022-01-18 19:39 ` [PATCH 19/36] Change inheritance of dprintf Tom Tromey
2022-01-18 19:39 ` Tom Tromey [this message]
2022-01-18 19:39 ` [PATCH 21/36] Convert Ada catchpoints to vtable ops Tom Tromey
2022-01-18 19:39 ` [PATCH 22/36] Convert dprintf " Tom Tromey
2022-01-18 19:39 ` [PATCH 23/36] Convert ranged breakpoints " Tom Tromey
2022-01-18 19:39 ` [PATCH 24/36] Add bp_static_marker_tracepoint Tom Tromey
2022-01-18 19:39 ` [PATCH 25/36] Convert static marker tracepoints to vtable ops Tom Tromey
2022-01-18 19:39 ` [PATCH 26/36] Remove bkpt_base_breakpoint_ops Tom Tromey
2022-01-18 19:39 ` [PATCH 27/36] Merge probe and ordinary breakpoints Tom Tromey
2022-01-18 19:39 ` [PATCH 28/36] Merge probe and ordinary tracepoints Tom Tromey
2022-01-18 19:40 ` [PATCH 29/36] Remove breakpoint_ops from init_ada_exception_breakpoint Tom Tromey
2022-01-18 19:40 ` [PATCH 30/36] Remove breakpoint_ops from init_catchpoint Tom Tromey
2022-01-18 19:40 ` [PATCH 31/36] Remove most fields from breakpoint_ops Tom Tromey
2022-01-18 19:40 ` [PATCH 32/36] Remove vtable_breakpoint_ops Tom Tromey
2022-01-18 19:40 ` [PATCH 33/36] Remove breakpoint ops initialization Tom Tromey
2022-01-18 19:40 ` [PATCH 34/36] Constify breakpoint_ops Tom Tromey
2022-01-18 19:40 ` [PATCH 35/36] Remove allocate_bp_location Tom Tromey
2022-01-18 19:40 ` [PATCH 36/36] Remove create_breakpoints_sal_default Tom Tromey
2022-04-22 20:21 ` [PATCH 00/36] C++-ify breakpoints Tom Tromey
2022-04-23 2:59 ` Simon Marchi
2022-04-29 22:15 ` Tom Tromey
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=20220118194007.2853108-21-tom@tromey.com \
--to=tom@tromey.com \
--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).