From: Andrew Burgess Date: Tue, 5 Nov 2024 13:42:57 +0000 (+0000) Subject: gdb: remove an unnecessary scope block in update_breakpoint_locations X-Git-Tag: gdb-16-branchpoint~327 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=df63932c96a393a1211cb2bcec19349db84a9c18;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 9c0d39b60cd..c849a998e79 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);