setFunctionBreakpoints \
{o breakpoints [a [o name [s no_debug_info]]]}]
set breakpoints [dict get [lindex $obj 0] body breakpoints]
-gdb_assert {[dict exists [lindex $breakpoints 0] instructionReference]} "breakpoint has instructionReference"
+gdb_assert {[dict exists [lindex $breakpoints 0] instructionReference]} \
+ "breakpoint has instructionReference"
+
+# instructionReference is specified as a string, but it's form is not
+# otherwise given in the spec. gdb always emits it as hex. A bug
+# slipped in that caused this to be incorrect, so we test both parts
+# here; to test whether a string was given, we have to reach into the
+# TON form.
+set list_form [namespace eval ton::2list $last_ton]
+set ref [namespace eval ton::2list {
+ get $list_form body breakpoints 0 instructionReference
+}]
+gdb_assert {[regexp "^$hex\$" $ref]} \
+ "instructionReference is a hex string"
dap_shutdown
}
# Read a JSON response from gdb. This will return a dict on
-# success, or throw an exception on error.
+# success, or throw an exception on error. On success, the global
+# "last_ton" will be set to the TON form of the result.
proc _dap_read_json {} {
set length ""
gdb_expect {
incr length -$this_len
}
- set ton [ton::json2ton $json]
- return [namespace eval ton::2dict $ton]
+ global last_ton
+ set last_ton [ton::json2ton $json]
+ return [namespace eval ton::2dict $last_ton]
}
# Read a sequence of JSON objects from gdb, until a response object is
# seen. If the response object has the request sequence number NUM,
# and is for command CMD, return a list of two elements: the response
# object and a list of any preceding events, in the order they were
-# emitted. The objects are dicts. If a response object is seen but has
-# the wrong sequence number or command, throw an exception
+# emitted. The objects are dicts. If a response object is seen but
+# has the wrong sequence number or command, throw an exception If a
+# response is seen, this leaves the global "last_ton" set to the TON
+# for the response.
proc _dap_read_response {cmd num} {
set result {}