]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: remove an unnecessary scope block in update_breakpoint_locations
authorAndrew Burgess <aburgess@redhat.com>
Tue, 5 Nov 2024 13:42:57 +0000 (13:42 +0000)
committerAndrew Burgess <aburgess@redhat.com>
Mon, 25 Nov 2024 16:45:25 +0000 (16:45 +0000)
In update_breakpoint_locations there's a scope block which I don't
think adds any value.  There is one local defined within the scope,
the local is currently an 'int' but should be a 'bool', either way
there's no destructor being triggered when we exit the scope.

This commit changes the local to a 'bool', removes the unnecessary
scope, and re-indents the code.

Within the (now removed) scope was a `for' loop.  Inside the loop I
have converted this:

  for (....)
    {
      if (CONDITION)
        {
          /* Body */
        }
    }

to this:

  for (....)
    {
      if (!CONDITION)
        continue;

      /* Body */
    }

which means that the body doesn't need to be indented as much, making
things easier to read.

There should be no functional change after this commit.

Reviewed-By: Klaus Gerlicher <klaus.gerlicher@intel.com>
gdb/breakpoint.c

index 9c0d39b60cdbbbb7189da711ec4c47f698f4e67a..c849a998e79a210475c85939a67f1aadb8a68a40 100644 (file)
@@ -13012,53 +13012,53 @@ update_breakpoint_locations (code_breakpoint *b,
     }
 
   /* If possible, carry over 'disable' status from existing
-     breakpoints.  */
-  {
-    /* If there are multiple breakpoints with the same function name,
-       e.g. for inline functions, comparing function names won't work.
-       Instead compare pc addresses; this is just a heuristic as things
-       may have moved, but in practice it gives the correct answer
-       often enough until a better solution is found.  */
-    int have_ambiguous_names = ambiguous_names_p (b->locations ());
-
-    for (const bp_location &e : existing_locations)
-      {
-       if ((!e.enabled || e.disabled_by_cond) && e.function_name)
-         {
-           if (have_ambiguous_names)
-             {
-               for (bp_location &l : b->locations ())
-                 {
-                   /* Ignore software vs hardware location type at
-                      this point, because with "set breakpoint
-                      auto-hw", after a re-set, locations that were
-                      hardware can end up as software, or vice versa.
-                      As mentioned above, this is an heuristic and in
-                      practice should give the correct answer often
-                      enough.  */
-                   if (breakpoint_locations_match (&e, &l, true))
-                     {
-                       l.enabled = e.enabled;
-                       l.disabled_by_cond = e.disabled_by_cond;
-                       break;
-                     }
-                 }
-             }
-           else
+     breakpoints.
+
+     If there are multiple breakpoints with the same function name,
+     e.g. for inline functions, comparing function names won't work.
+     Instead compare pc addresses; this is just a heuristic as things
+     may have moved, but in practice it gives the correct answer
+     often enough until a better solution is found.  */
+  bool have_ambiguous_names = ambiguous_names_p (b->locations ());
+
+  for (const bp_location &e : existing_locations)
+    {
+      if (e.function_name == nullptr
+         || (e.enabled && !e.disabled_by_cond))
+       continue;
+
+      if (have_ambiguous_names)
+       {
+         for (bp_location &l : b->locations ())
+           {
+             /* Ignore software vs hardware location type at
+                this point, because with "set breakpoint
+                auto-hw", after a re-set, locations that were
+                hardware can end up as software, or vice versa.
+                As mentioned above, this is an heuristic and in
+                practice should give the correct answer often
+                enough.  */
+             if (breakpoint_locations_match (&e, &l, true))
+               {
+                 l.enabled = e.enabled;
+                 l.disabled_by_cond = e.disabled_by_cond;
+                 break;
+               }
+           }
+       }
+      else
+       {
+         for (bp_location &l : b->locations ())
+           if (l.function_name
+               && strcmp (e.function_name.get (),
+                          l.function_name.get ()) == 0)
              {
-               for (bp_location &l : b->locations ())
-                 if (l.function_name
-                     && strcmp (e.function_name.get (),
-                                l.function_name.get ()) == 0)
-                   {
-                     l.enabled = e.enabled;
-                     l.disabled_by_cond = e.disabled_by_cond;
-                     break;
-                   }
+               l.enabled = e.enabled;
+               l.disabled_by_cond = e.disabled_by_cond;
+               break;
              }
-         }
-      }
-  }
+       }
+    }
 
   if (!locations_are_equal (existing_locations, b->locations ()))
     notify_breakpoint_modified (b);