From: Tom Tromey Date: Mon, 8 Jul 2024 17:28:37 +0000 (-0600) Subject: Notify Python when breakpoint symbol changes X-Git-Tag: gdb-16-branchpoint~1136 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1b72c26495947dc1f30cab4295c8cf4dd795cb2;p=thirdparty%2Fbinutils-gdb.git 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 --- diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 9d9ce6e1e66..9a78029546c 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 e98eb8c3935..4a4c14484e1 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"