aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2022-01-15 16:28:06 -0700
committerTom Tromey <tom@tromey.com>2022-04-29 16:14:31 -0600
commitf293a0b5d6b429c3dd8a91e9d55831bfb4efd84a (patch)
treec44c07aa9eec42a8645287799719fbcf0a040d34 /gdb
parentae72050b7f8454ef2c0763f5548cc2cd873e27e0 (diff)
downloadgdb-f293a0b5d6b429c3dd8a91e9d55831bfb4efd84a.zip
gdb-f293a0b5d6b429c3dd8a91e9d55831bfb4efd84a.tar.gz
gdb-f293a0b5d6b429c3dd8a91e9d55831bfb4efd84a.tar.bz2
Convert dprintf to vtable ops
This converts dprintf to use vtable_breakpoint_ops.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/breakpoint.c63
-rw-r--r--gdb/breakpoint.h1
-rw-r--r--gdb/mi/mi-cmd-break.c2
3 files changed, 30 insertions, 36 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8131c71..b856bf9 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -240,9 +240,6 @@ static struct breakpoint_ops bkpt_probe_breakpoint_ops;
/* Tracepoints set on probes. */
static struct breakpoint_ops tracepoint_probe_breakpoint_ops;
-/* Dynamic printf class type. */
-struct breakpoint_ops dprintf_breakpoint_ops;
-
/* The structure to be used in regular breakpoints. */
struct ordinary_breakpoint : public base_breakpoint
{
@@ -273,6 +270,13 @@ struct momentary_breakpoint : public base_breakpoint
/* DPrintf breakpoints. */
struct dprintf_breakpoint : public ordinary_breakpoint
{
+ void re_set () override;
+ int breakpoint_hit (const struct bp_location *bl,
+ const address_space *aspace,
+ CORE_ADDR bp_addr,
+ const target_waitstatus &ws) override;
+ void print_recreate (struct ui_file *fp) override;
+ void after_condition_true (struct bpstat *bs) override;
};
/* The style in which to perform a dynamic printf. This is a user
@@ -9159,7 +9163,7 @@ dprintf_command (const char *arg, int from_tty)
0, bp_dprintf,
0 /* Ignore count */,
pending_break_support,
- &dprintf_breakpoint_ops,
+ &vtable_breakpoint_ops,
from_tty,
1 /* enabled */,
0 /* internal */,
@@ -11860,10 +11864,11 @@ base_breakpoint::breakpoint_hit (const struct bp_location *bl,
return 1;
}
-static int
-dprintf_breakpoint_hit (const struct bp_location *bl,
- const address_space *aspace, CORE_ADDR bp_addr,
- const target_waitstatus &ws)
+int
+dprintf_breakpoint::breakpoint_hit (const struct bp_location *bl,
+ const address_space *aspace,
+ CORE_ADDR bp_addr,
+ const target_waitstatus &ws)
{
if (dprintf_style == dprintf_style_agent
&& target_can_run_breakpoint_commands ())
@@ -11874,7 +11879,7 @@ dprintf_breakpoint_hit (const struct bp_location *bl,
return 0;
}
- return bl->owner->breakpoint_hit (bl, aspace, bp_addr, ws);
+ return this->ordinary_breakpoint::breakpoint_hit (bl, aspace, bp_addr, ws);
}
int
@@ -12273,15 +12278,13 @@ tracepoint_probe_decode_location (struct breakpoint *b,
return bkpt_probe_decode_location (b, location, search_pspace);
}
-/* Dprintf breakpoint_ops methods. */
-
-static void
-dprintf_re_set (struct breakpoint *b)
+void
+dprintf_breakpoint::re_set ()
{
- breakpoint_re_set_default (b);
+ breakpoint_re_set_default (this);
/* extra_string should never be non-NULL for dprintf. */
- gdb_assert (b->extra_string != NULL);
+ gdb_assert (extra_string != NULL);
/* 1 - connect to target 1, that can run breakpoint commands.
2 - create a dprintf, which resolves fine.
@@ -12293,23 +12296,22 @@ dprintf_re_set (struct breakpoint *b)
answers for target_can_run_breakpoint_commands().
Given absence of finer grained resetting, we get to do
it all the time. */
- if (b->extra_string != NULL)
- update_dprintf_command_list (b);
+ if (extra_string != NULL)
+ update_dprintf_command_list (this);
}
-/* Implement the "print_recreate" breakpoint_ops method for dprintf. */
+/* Implement the "print_recreate" method for dprintf. */
-static void
-dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp)
+void
+dprintf_breakpoint::print_recreate (struct ui_file *fp)
{
gdb_printf (fp, "dprintf %s,%s",
- event_location_to_string (tp->location.get ()),
- tp->extra_string.get ());
- print_recreate_thread (tp, fp);
+ event_location_to_string (location.get ()),
+ extra_string.get ());
+ print_recreate_thread (this, fp);
}
-/* Implement the "after_condition_true" breakpoint_ops method for
- dprintf.
+/* Implement the "after_condition_true" method for dprintf.
dprintf's are implemented with regular commands in their command
list, but we run the commands here instead of before presenting the
@@ -12317,8 +12319,8 @@ dprintf_print_recreate (struct breakpoint *tp, struct ui_file *fp)
also makes it so that the commands of multiple dprintfs at the same
address are all handled. */
-static void
-dprintf_after_condition_true (struct bpstat *bs)
+void
+dprintf_breakpoint::after_condition_true (struct bpstat *bs)
{
/* dprintf's never cause a stop. This wasn't set in the
check_status hook instead because that would make the dprintf's
@@ -14588,13 +14590,6 @@ initialize_breakpoint_ops (void)
ops->create_sals_from_location = strace_marker_create_sals_from_location;
ops->create_breakpoints_sal = strace_marker_create_breakpoints_sal;
ops->decode_location = strace_marker_decode_location;
-
- ops = &dprintf_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;
- ops->breakpoint_hit = dprintf_breakpoint_hit;
}
/* Chain containing all defined "enable breakpoint" subcommands. */
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index c137987..7d8c4f3 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -1490,7 +1490,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 dprintf_breakpoint_ops;
extern struct breakpoint_ops vtable_breakpoint_ops;
extern void initialize_breakpoint_ops (void);
diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c
index 0b8ae5d..fb03431 100644
--- a/gdb/mi/mi-cmd-break.c
+++ b/gdb/mi/mi-cmd-break.c
@@ -327,7 +327,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc)
else if (dprintf)
{
type_wanted = bp_dprintf;
- ops = &dprintf_breakpoint_ops;
+ ops = &vtable_breakpoint_ops;
}
else
{