aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-07-08 11:28:37 -0600
committerTom Tromey <tromey@adacore.com>2024-08-14 10:08:58 -0600
commitd1b72c26495947dc1f30cab4295c8cf4dd795cb2 (patch)
treecf170a81b2c8dc71ce49ef6490b0ecaafa9e6a6b
parentf2387377574992655490996e46e25cc5fb7993da (diff)
downloadbinutils-d1b72c26495947dc1f30cab4295c8cf4dd795cb2.zip
binutils-d1b72c26495947dc1f30cab4295c8cf4dd795cb2.tar.gz
binutils-d1b72c26495947dc1f30cab4295c8cf4dd795cb2.tar.bz2
Notify Python when breakpoint symbol changes
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>
-rw-r--r--gdb/breakpoint.c7
-rw-r--r--gdb/testsuite/gdb.dap/insn-bp.exp30
2 files changed, 27 insertions, 10 deletions
diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c
index 9d9ce6e..9a78029 100644
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -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 ());
diff --git a/gdb/testsuite/gdb.dap/insn-bp.exp b/gdb/testsuite/gdb.dap/insn-bp.exp
index e98eb8c..4a4c144 100644
--- a/gdb/testsuite/gdb.dap/insn-bp.exp
+++ b/gdb/testsuite/gdb.dap/insn-bp.exp
@@ -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"