[PATCHv9,07/14] gdb: remove breakpoint_re_set_one

Message ID b3807ffde6c2d69c670862efcd8e0a1320482e29.1709651994.git.aburgess@redhat.com
State New
Headers
Series thread-specific breakpoints in just some inferiors |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Andrew Burgess March 5, 2024, 3:21 p.m. UTC
  During a later patch I wanted to reset a single breakpoint, so I
called breakpoint_re_set_one.  However, this is not the right thing to
do.  If we look at breakpoint_re_set then we see that there's a whole
bunch of state that needs to be preserved prior to calling
breakpoint_re_set_one, and after calling breakpoint_re_set_one we
still need to call update_global_location_list.

I could just update the comment on breakpoint_re_set_one to make it
clearer how the function should be used -- or more likely to warn that
the function should only be used as a helper from breakpoint_re_set.

However, breakpoint_re_set_one is only 3 lines long.  So I figure it
might actually be easier to just fold breakpoint_re_set_one into
breakpoint_re_set, then there's no risk of accidentally calling
breakpoint_re_set_one when we shouldn't.

There should be no user visible changes after this commit.
---
 gdb/breakpoint.c | 26 ++++++++------------------
 1 file changed, 8 insertions(+), 18 deletions(-)
  

Patch

diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index aae1b932a5d..5e97d27bbf5 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -13210,17 +13210,6 @@  create_sals_from_location_spec_default (location_spec *locspec,
   parse_breakpoint_sals (locspec, canonical);
 }
 
-/* Reset a breakpoint.  */
-
-static void
-breakpoint_re_set_one (breakpoint *b)
-{
-  input_radix = b->input_radix;
-  set_language (b->language);
-
-  b->re_set ();
-}
-
 /* Re-set breakpoint locations for the current program space.
    Locations bound to other program spaces are left untouched.  */
 
@@ -13232,12 +13221,11 @@  breakpoint_re_set (void)
     scoped_restore save_input_radix = make_scoped_restore (&input_radix);
     scoped_restore_current_pspace_and_thread restore_pspace_thread;
 
-    /* breakpoint_re_set_one sets the current_language to the language
-       of the breakpoint it is resetting (see prepare_re_set_context)
-       before re-evaluating the breakpoint's location.  This change can
-       unfortunately get undone by accident if the language_mode is set
-       to auto, and we either switch frames, or more likely in this context,
-       we select the current frame.
+    /* To ::re_set each breakpoint we set the current_language to the
+       language of the breakpoint before re-evaluating the breakpoint's
+       location.  This change can unfortunately get undone by accident if
+       the language_mode is set to auto, and we either switch frames, or
+       more likely in this context, we select the current frame.
 
        We prevent this by temporarily turning the language_mode to
        language_mode_manual.  We restore it once all breakpoints
@@ -13254,7 +13242,9 @@  breakpoint_re_set (void)
       {
 	try
 	  {
-	    breakpoint_re_set_one (&b);
+	    input_radix = b.input_radix;
+	    set_language (b.language);
+	    b.re_set ();
 	  }
 	catch (const gdb_exception &ex)
 	  {