forked from Imagelibrary/binutils-gdb
[gdb/testsuite] Fix another fail and tcl error in gdb.dap/sources.exp
With gdb.dap/sources.exp on aarch64-linux, I'm running into:
...
{"request_seq": 3, "type": "response", "command": "loadedSources", \
"success": false, "message": "notStopped", "seq": 7}Content-Length: 92^M
^M
{"type": "event", "event": "thread", \
"body": {"reason": "started", "threadId": 1}, \
"seq": 8}FAIL: gdb.dap/sources.exp: loadedSources success
ERROR: tcl error sourcing gdb.dap/sources.exp.
ERROR: tcl error code TCL LOOKUP DICT body
ERROR: key "body" not known in dictionary
while executing
"dict get [lindex $obj 0] body sources"
...
These are the same type of tcl error and FAIL I just fixed for a later
request in the same test-case.
Fix this by:
- moving the wait-for-stop to before the loadedSources request to fix the
FAIL, and
- checking for $obj == "" to fix the tcl error.
Also make the code a bit less indented and more readable by wrapping the tests
in a proc, allowing the use of return to bail out, while still running
dap_shutdown afterwards.
Approved-By: Tom Tromey <tom@tromey.com>
Tested on aarch64-linux.
This commit is contained in:
@@ -33,30 +33,37 @@ if {[dap_launch $testfile stop_at_main 1] == ""} {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
set obj [dap_check_request_and_response loadedSources loadedSources]
|
proc do_tests {} {
|
||||||
set path ""
|
|
||||||
foreach src [dict get [lindex $obj 0] body sources] {
|
|
||||||
if {[file tail [dict get $src name]] == "sources.c"} {
|
|
||||||
set path [dict get $src path]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if {$path == ""} {
|
|
||||||
fail "sources.c in loadedSources"
|
|
||||||
} else {
|
|
||||||
pass "sources.c in loadedSources"
|
|
||||||
|
|
||||||
dap_wait_for_event_and_check "stopped at function breakpoint" stopped \
|
dap_wait_for_event_and_check "stopped at function breakpoint" stopped \
|
||||||
"body reason" breakpoint
|
"body reason" breakpoint
|
||||||
|
|
||||||
|
set obj [dap_check_request_and_response loadedSources loadedSources]
|
||||||
|
if { $obj == "" } {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
set path ""
|
||||||
|
foreach src [dict get [lindex $obj 0] body sources] {
|
||||||
|
if {[file tail [dict get $src name]] == "sources.c"} {
|
||||||
|
set path [dict get $src path]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gdb_assert {$path != "" } "sources.c in loadedSources"
|
||||||
|
if {$path == ""} {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
set obj [dap_check_request_and_response "get source" source \
|
set obj [dap_check_request_and_response "get source" source \
|
||||||
[format {o source [o path [s %s]] \
|
[format {o source [o path [s %s]] \
|
||||||
sourceReference [i 0]} $path]]
|
sourceReference [i 0]} $path]]
|
||||||
if { $obj != "" } {
|
if { $obj == "" } {
|
||||||
set text [dict get [lindex $obj 0] body content]
|
return
|
||||||
gdb_assert {[string first "Distinguishing comment" $text] != -1}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set text [dict get [lindex $obj 0] body content]
|
||||||
|
gdb_assert {[string first "Distinguishing comment" $text] != -1}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_tests
|
||||||
|
|
||||||
dap_shutdown
|
dap_shutdown
|
||||||
|
|||||||
Reference in New Issue
Block a user