gdb: remove an unnecessary scope block in update_breakpoint_locations

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>
This commit is contained in:
Andrew Burgess
2024-11-05 13:42:57 +00:00
parent 2778a124e3
commit df63932c96

View 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 ());
breakpoints.
for (const bp_location &e : existing_locations)
{
if ((!e.enabled || e.disabled_by_cond) && e.function_name)
{
if (have_ambiguous_names)
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 ())
{
/* 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;
}
}
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)
{
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);