diff options
author | Andrew Burgess <aburgess@redhat.com> | 2024-11-05 13:42:57 +0000 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2024-11-25 16:45:25 +0000 |
commit | df63932c96a393a1211cb2bcec19349db84a9c18 (patch) | |
tree | 10ed0d591c64b2d622a34870d45897ff5624060f | |
parent | 2778a124e30439c1801d3d19a47d8233935051af (diff) | |
download | binutils-df63932c96a393a1211cb2bcec19349db84a9c18.zip binutils-df63932c96a393a1211cb2bcec19349db84a9c18.tar.gz binutils-df63932c96a393a1211cb2bcec19349db84a9c18.tar.bz2 |
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>
-rw-r--r-- | gdb/breakpoint.c | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 9c0d39b..c849a99 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -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); |