]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Notify Python when breakpoint symbol changes
authorTom Tromey <tromey@adacore.com>
Mon, 8 Jul 2024 17:28:37 +0000 (11:28 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 14 Aug 2024 16:08:58 +0000 (10:08 -0600)
A DAP user noticed that breakpoints set by address were never updated
to show their location after the DAP launch request.  It turns out
that gdb does not emit the breakpoint-modified event when this sort of
breakpoint is updated.

This patch changes gdb to notify the breakpoint-modified observer when
a breakpoint location's symbol changes.  This in turn causes the DAP
event to be emitted.

Reviewed-by: Keith Seitz <keiths@redhat.com>
gdb/breakpoint.c
gdb/testsuite/gdb.dap/insn-bp.exp

index 9d9ce6e1e664f89a172d716d2fa397ca928819af..9a78029546cbc0d822104d2208491752d30c6221 100644 (file)
@@ -12918,6 +12918,13 @@ locations_are_equal (const bp_location_list &a, const bp_location_range &b)
 
       if (a_iter->disabled_by_cond != b_iter->disabled_by_cond)
        return false;
+
+      /* When a breakpoint is set by address, it is not created as
+        pending; but then during an solib event or the like it may
+        acquire a symbol.  So, check this here.  */
+      if (a_iter->symbol != b_iter->symbol
+         || a_iter->msymbol != b_iter->msymbol)
+       return false;
     }
 
   return (a_iter == a.end ()) == (b_iter == b.end ());
index e98eb8c3935d6518d75b1ee4dd795c386d1b1655..4a4c14484e176fb9d3026462f5758e0d9103da9c 100644 (file)
@@ -39,6 +39,11 @@ if {[dap_initialize] == ""} {
     return
 }
 
+set obj [dap_check_request_and_response "set breakpoint on main" \
+            setFunctionBreakpoints \
+            {o breakpoints [a [o name [s main]]]}]
+set fn_bpno [dap_get_breakpoint_number $obj]
+
 set obj [dap_check_request_and_response "set breakpoint by address" \
             setInstructionBreakpoints \
             [format {o breakpoints [a [o instructionReference [s %s]]]} \
@@ -54,15 +59,20 @@ dap_check_request_and_response "configurationDone" configurationDone
 if {[dap_launch $testfile] == ""} {
     return
 }
-dap_wait_for_event_and_check "inferior started" thread "body reason" started
 
-# While waiting for the stopped event, we should receive breakpoint
-# changed events.
+# The event we're looking for should occur during startup, but we want
+# to leave open the possibility that it occurs when waiting for the
+# stopped event.  So, keep both event lists around and search them
+# once below.
+lassign [dap_wait_for_event_and_check "inferior started" \
+            thread "body reason" started] \
+    unused objs1
 lassign [dap_wait_for_event_and_check "stopped at breakpoint" stopped \
            "body reason" breakpoint \
-           "body hitBreakpointIds" $bpno] unused objs
+           "body hitBreakpointIds" $fn_bpno] unused objs2
+
 set found_bp_event 0
-foreach obj $objs {
+foreach obj [concat $objs1 $objs2] {
     if { [dict get $obj "type"] != "event" } {
        continue
     }
@@ -78,11 +88,11 @@ foreach obj $objs {
     }
 
     set breakpoint [dict get $body breakpoint]
-    gdb_assert {[dict get $breakpoint id] == $bpno} \
-       "breakpoint modification event has correct id"
-    gdb_assert {[dict get $breakpoint source name] == "basic-dap.c"} \
-       "breakpoint modification event has source"
-    set found_bp_event 1
+    if {[dict get $breakpoint id] == $bpno} {
+       gdb_assert {[dict get $breakpoint source name] == "basic-dap.c"} \
+           "breakpoint modification event has source"
+       set found_bp_event 1
+    }
 }
 
 gdb_assert {$found_bp_event} "found the breakpoint event"