public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Convert say_where to method on code_breakpoint
@ 2023-01-10 15:18 Tom Tromey
  2023-01-10 16:24 ` Simon Marchi
  2023-01-10 23:35 ` Tom Tromey
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Tromey @ 2023-01-10 15:18 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

'say_where' is only useful (and only called for) code breakpoints, so
convert it to be a protected method on code_breakpoint.
---
 gdb/breakpoint.c | 49 ++++++++++++++++++++++++------------------------
 gdb/breakpoint.h |  4 ++++
 2 files changed, 28 insertions(+), 25 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 8cfc46e0bed..6762fad5d2c 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -11496,11 +11496,10 @@ bpstat_remove_breakpoint_callback (struct thread_info *th, void *data)
   return 0;
 }
 
-/* Helper for breakpoint and tracepoint breakpoint->mention
-   callbacks.  */
+/* See breakpoint.h.  */
 
-static void
-say_where (const breakpoint *b)
+void
+code_breakpoint::say_where () const
 {
   struct value_print_options opts;
 
@@ -11508,58 +11507,58 @@ say_where (const breakpoint *b)
 
   /* i18n: cagney/2005-02-11: Below needs to be merged into a
      single string.  */
-  if (b->loc == NULL)
+  if (loc == NULL)
     {
       /* For pending locations, the output differs slightly based
-	 on b->extra_string.  If this is non-NULL, it contains either
+	 on extra_string.  If this is non-NULL, it contains either
 	 a condition or dprintf arguments.  */
-      if (b->extra_string == NULL)
+      if (extra_string == NULL)
 	{
-	  gdb_printf (_(" (%s) pending."), b->locspec->to_string ());
+	  gdb_printf (_(" (%s) pending."), locspec->to_string ());
 	}
-      else if (b->type == bp_dprintf)
+      else if (type == bp_dprintf)
 	{
 	  gdb_printf (_(" (%s,%s) pending."),
-		      b->locspec->to_string (),
-		      b->extra_string.get ());
+		      locspec->to_string (),
+		      extra_string.get ());
 	}
       else
 	{
 	  gdb_printf (_(" (%s %s) pending."),
-		      b->locspec->to_string (),
-		      b->extra_string.get ());
+		      locspec->to_string (),
+		      extra_string.get ());
 	}
     }
   else
     {
-      if (opts.addressprint || b->loc->symtab == NULL)
+      if (opts.addressprint || loc->symtab == NULL)
 	gdb_printf (" at %ps",
 		    styled_string (address_style.style (),
-				   paddress (b->loc->gdbarch,
-					     b->loc->address)));
-      if (b->loc->symtab != NULL)
+				   paddress (loc->gdbarch,
+					     loc->address)));
+      if (loc->symtab != NULL)
 	{
 	  /* If there is a single location, we can print the location
 	     more nicely.  */
-	  if (b->loc->next == NULL)
+	  if (loc->next == NULL)
 	    {
 	      const char *filename
-		= symtab_to_filename_for_display (b->loc->symtab);
+		= symtab_to_filename_for_display (loc->symtab);
 	      gdb_printf (": file %ps, line %d.",
 			  styled_string (file_name_style.style (),
 					 filename),
-			  b->loc->line_number);
+			  loc->line_number);
 	    }
 	  else
 	    /* This is not ideal, but each location may have a
 	       different file name, and this at least reflects the
 	       real situation somewhat.  */
-	    gdb_printf (": %s.", b->locspec->to_string ());
+	    gdb_printf (": %s.", locspec->to_string ());
 	}
 
-      if (b->loc->next)
+      if (loc->next)
 	{
-	  struct bp_location *loc = b->loc;
+	  struct bp_location *loc = loc;
 	  int n = 0;
 	  for (; loc; loc = loc->next)
 	    ++n;
@@ -11794,7 +11793,7 @@ ordinary_breakpoint::print_mention () const
       break;
     }
 
-  say_where (this);
+  say_where ();
 }
 
 void
@@ -12054,7 +12053,7 @@ tracepoint::print_mention () const
       internal_error (_("unhandled tracepoint type %d"), (int) type);
     }
 
-  say_where (this);
+  say_where ();
 }
 
 void
diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h
index 7289a09e95c..399bd037977 100644
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -898,6 +898,10 @@ struct code_breakpoint : public breakpoint
        (location_spec *locspec,
 	struct program_space *search_pspace,
 	int *found);
+
+  /* Helper for breakpoint and tracepoint breakpoint->mention
+     callbacks.  */
+  void say_where () const;
 };
 
 /* An instance of this type is used to represent a watchpoint,
-- 
2.38.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Convert say_where to method on code_breakpoint
  2023-01-10 15:18 [PATCH] Convert say_where to method on code_breakpoint Tom Tromey
@ 2023-01-10 16:24 ` Simon Marchi
  2023-01-10 23:35 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Marchi @ 2023-01-10 16:24 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches



On 1/10/23 10:18, Tom Tromey via Gdb-patches wrote:
> 'say_where' is only useful (and only called for) code breakpoints, so
> convert it to be a protected method on code_breakpoint.

LGTM, thanks.

Simon

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Convert say_where to method on code_breakpoint
  2023-01-10 15:18 [PATCH] Convert say_where to method on code_breakpoint Tom Tromey
  2023-01-10 16:24 ` Simon Marchi
@ 2023-01-10 23:35 ` Tom Tromey
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2023-01-10 23:35 UTC (permalink / raw)
  To: Tom Tromey via Gdb-patches; +Cc: Tom Tromey

>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> 'say_where' is only useful (and only called for) code breakpoints, so
Tom> convert it to be a protected method on code_breakpoint.

Tom> -	  struct bp_location *loc = b->loc;
Tom> +	  struct bp_location *loc = loc;
Tom>  	  int n = 0;
Tom>  	  for (; loc; loc = loc->next)
Tom>  	    ++n;

This hunk is wrong but I didn't notice until now.
Sorry about this.  I'll fix it momentarily.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-10 23:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 15:18 [PATCH] Convert say_where to method on code_breakpoint Tom Tromey
2023-01-10 16:24 ` Simon Marchi
2023-01-10 23:35 ` 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).