]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: build dprintf commands just once in code_breakpoint constructor
authorAndrew Burgess <aburgess@redhat.com>
Wed, 5 Apr 2023 15:12:05 +0000 (16:12 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Sun, 31 Mar 2024 10:13:34 +0000 (11:13 +0100)
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.

gdb/breakpoint.c

index 71c8c820aa0b70410f69eae786a00158036fcd24..ea89c40ce26d99190c9f2bd2f64187acc4ee7f24 100644 (file)
@@ -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;