public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite/dap: fix gdb.dap/basic-dap.exp disassembly test for PIE Date: Thu, 26 Jan 2023 20:23:18 +0000 (GMT) [thread overview] Message-ID: <20230126202318.6B5893858C83@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d4c4ea75838091b6bf52d97208bd2fa4021951db commit d4c4ea75838091b6bf52d97208bd2fa4021951db Author: Simon Marchi <simon.marchi@efficios.com> Date: Fri Jan 6 13:26:19 2023 -0500 gdb/testsuite/dap: fix gdb.dap/basic-dap.exp disassembly test for PIE Prior to this patch, I get: >>> {"seq": 17, "type": "request", "command": "disassemble", "arguments": {"memoryReference": "0x115d", "instructionCount": 1}} Content-Length: 147 {"request_seq": 17, "type": "response", "command": "disassemble", "success": false, "message": "Cannot access memory at address 0x115d", "seq": 41}FAIL: gdb.dap/basic-dap.exp: disassemble one instruction success FAIL: gdb.dap/basic-dap.exp: instructions in disassemble output The problem is that the PC to disassemble is taken from the breakpoint insertion response, which happens before running. With a PIE executable, that PC is unrelocated, but the disassembly request happens after relocation. I chose to fix this by watching for a breakpoint changed event giving the new breakpoint address, and recording the address from there. I think this is an interesting way to fix it, because it adds a bit of test coverage, I don't think these events are checked right now. Other ways to fix it would be: - Get the address by doing a breakpoint insertion after the program is started, or some other way. - Do the disassembly by symbol instead of by address. - Do the disassembly before running the program. Change-Id: I3c396f796ac4c8b22e7dfd2fa1c5467f7a47e84e Diff: --- gdb/testsuite/gdb.dap/basic-dap.exp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/gdb/testsuite/gdb.dap/basic-dap.exp b/gdb/testsuite/gdb.dap/basic-dap.exp index 795702a5a8f..5303e943320 100644 --- a/gdb/testsuite/gdb.dap/basic-dap.exp +++ b/gdb/testsuite/gdb.dap/basic-dap.exp @@ -90,9 +90,36 @@ set insn_pc [dict get [lindex $bplist 0] instructionReference] dap_check_request_and_response "start inferior" configurationDone dap_wait_for_event_and_check "inferior started" thread "body reason" started -dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ - "body reason" breakpoint \ - "body hitBreakpointIds" $fn_bpno +# While waiting for the stopped event, we might receive breakpoint changed +# events indicating some breakpoint addresses were relocated. Update INSN_PC +# if necessary. +lassign [dap_wait_for_event_and_check "stopped at function breakpoint" stopped \ + "body reason" breakpoint \ + "body hitBreakpointIds" $fn_bpno] unused objs +foreach obj $objs { + if { [dict get $obj "type"] != "event" } { + continue + } + + if { [dict get $obj "event"] != "breakpoint" } { + continue + } + + set body [dict get $obj "body"] + + if { [dict get $body "reason"] != "changed" } { + continue + } + + set breakpoint [dict get $body "breakpoint"] + set breakpoint_id [dict get $breakpoint "id"] + + if { $breakpoint_id != $insn_bpno } { + continue + } + + set insn_pc [dict get $breakpoint "instructionReference"] +} set obj [dap_check_request_and_response "evaluate global in function" \ evaluate {o expression [s global_variable]}]
reply other threads:[~2023-01-26 20:23 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230126202318.6B5893858C83@sourceware.org \ --to=simark@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).