]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix tcl error in gdb.dap/sources.exp
authorTom de Vries <tdevries@suse.de>
Tue, 13 Feb 2024 09:44:25 +0000 (10:44 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 13 Feb 2024 09:44:25 +0000 (10:44 +0100)
With test-case gdb.dap/sources.exp, I run into:
...
{"request_seq": 4, "type": "response", "command": "source", \
  "success": false, "message": "notStopped", \
  "seq": 11}FAIL: gdb.dap/sources.exp: get source success
ERROR: tcl error sourcing gdb.dap/sources.exp.
ERROR: key "body" not known in dictionary
...

The FAIL has been filed as PR dap/31374.

The ERROR happens because after the FAIL, dap_check_request_and_response
returns "", and the test-case doesn't check for that.

Fix this by checking for $obj != "" in the test-case.

Tested on x86_64-linux.

gdb/testsuite/gdb.dap/sources.exp

index b60681160af28b1c4bce0749842c46691652d51e..f601190d6f53748d2ae437dea35343b23842f071 100644 (file)
@@ -49,8 +49,10 @@ if {$path == ""} {
     set obj [dap_check_request_and_response "get source" source \
                 [format {o source [o path [s %s]] \
                            sourceReference [i 0]} $path]]
-    set text [dict get [lindex $obj 0] body content]
-    gdb_assert {[string first "Distinguishing comment" $text] != -1}
+    if { $obj != "" } {
+       set text [dict get [lindex $obj 0] body content]
+       gdb_assert {[string first "Distinguishing comment" $text] != -1}
+    }
 }