public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Convert dprintf to vtable ops
@ 2022-04-29 22:23 Tom Tromey
  0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2022-04-29 22:23 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f293a0b5d6b429c3dd8a91e9d55831bfb4efd84a

commit f293a0b5d6b429c3dd8a91e9d55831bfb4efd84a
Author: Tom Tromey <tom@tromey.com>
Date:   Sat Jan 15 16:28:06 2022 -0700

    Convert dprintf to vtable ops
    
    This converts dprintf to use vtable_breakpoint_ops.

Diff:
---
 gdb/breakpoint.c      | 63 ++++++++++++++++++++++++---------------------------
 gdb/breakpoint.h      |  1 -
 gdb/mi/mi-cmd-break.c |  2 +-
 3 files changed, 30 insertions(+), 36 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8131c71ad80..b856bf937d3 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 c1379870436..7d8c4f3bc3a 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 0b8ae5d5910..fb034317a6e 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
     {


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-29 22:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29 22:23 [binutils-gdb] Convert dprintf to vtable ops Tom Tromey

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).