From eb6476e2db406ba323efba438b0d1851e86d02e5 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Thu, 7 Dec 2023 09:51:52 -0700 Subject: Add 'program' to DAP 'attach' request In many cases, it's not possible for gdb to discover the executable when a DAP 'attach' request is used. This patch lets the IDE supply this information. Reviewed-By: Eli Zaretskii --- gdb/testsuite/gdb.dap/attach.exp | 2 +- gdb/testsuite/lib/dap-support.exp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'gdb/testsuite') diff --git a/gdb/testsuite/gdb.dap/attach.exp b/gdb/testsuite/gdb.dap/attach.exp index 5b308f9..4d56271 100644 --- a/gdb/testsuite/gdb.dap/attach.exp +++ b/gdb/testsuite/gdb.dap/attach.exp @@ -29,7 +29,7 @@ set test_spawn_id [spawn_wait_for_attach $binfile] set testpid [spawn_id_get_pid $test_spawn_id] # We just want to test that attaching works at all. -if {[dap_attach $testpid] != ""} { +if {[dap_attach $testpid $binfile] != ""} { dap_shutdown true } diff --git a/gdb/testsuite/lib/dap-support.exp b/gdb/testsuite/lib/dap-support.exp index b9ac314..8186148 100644 --- a/gdb/testsuite/lib/dap-support.exp +++ b/gdb/testsuite/lib/dap-support.exp @@ -306,12 +306,17 @@ proc dap_launch {file {args {}}} { # Start gdb, send a DAP initialize request, and then an attach request # specifying PID as the inferior process ID. Returns the empty string # on failure, or the response object from the attach request. -proc dap_attach {pid} { +proc dap_attach {pid {prog ""}} { if {[_dap_initialize "startup - initialize"] == ""} { return "" } - return [dap_check_request_and_response "startup - attach" attach \ - [format {o pid [i %s]} $pid]] + + set args [format {o pid [i %s]} $pid] + if {$prog != ""} { + append args [format { program [s %s]} $prog] + } + + return [dap_check_request_and_response "startup - attach" attach $args] } # Start gdb, send a DAP initialize request, and then an attach request -- cgit v1.1