public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] gdb: build dprintf commands just once in code_breakpoint constructor
@ 2024-03-31 10:28 Andrew Burgess
  0 siblings, 0 replies; only message in thread
From: Andrew Burgess @ 2024-03-31 10:28 UTC (permalink / raw)
  To: gdb-cvs

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

commit 8b4141cdb03e48826e2935529be7fd7499f9d815
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Wed Apr 5 16:12:05 2023 +0100

    gdb: build dprintf commands just once in code_breakpoint constructor
    
    I noticed in code_breakpoint::code_breakpoint that we are calling
    update_dprintf_command_list once for each breakpoint location, when we
    really only need to call this once per breakpoint -- the data updated
    by this function, the breakpoint command list -- is per breakpoint,
    not per breakpoint location.  Calling update_dprintf_command_list
    multiple times is just wasted effort, there's no per location error
    checking, we don't even pass the current location to the function.
    
    This commit moves the update_dprintf_command_list call outside of the
    per-location loop.
    
    There should be no user visible changes after this commit.

Diff:
---
 gdb/breakpoint.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 71c8c820aa0..ea89c40ce26 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -8698,15 +8698,15 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_,
       /* Do not set breakpoint locations conditions yet.  As locations
 	 are inserted, they get sorted based on their addresses.  Let
 	 the list stabilize to have reliable location numbers.  */
-
-      /* Dynamic printf requires and uses additional arguments on the
-	 command line, otherwise it's an error.  */
-      if (type == bp_dprintf)
-	update_dprintf_command_list (this);
-      else if (extra_string != nullptr)
-	error (_("Garbage '%s' at end of command"), extra_string.get ());
     }
 
+  /* Dynamic printf requires and uses additional arguments on the
+     command line, otherwise it's an error.  */
+  if (type == bp_dprintf)
+    update_dprintf_command_list (this);
+  else if (extra_string != nullptr)
+    error (_("Garbage '%s' at end of command"), extra_string.get ());
+
   /* The order of the locations is now stable.  Set the location
      condition using the location's number.  */
   int loc_num = 1;

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

only message in thread, other threads:[~2024-03-31 10:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-31 10:28 [binutils-gdb] gdb: build dprintf commands just once in code_breakpoint constructor Andrew Burgess

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