[2/2,gdb/testsuite] Fix gdb.dap/step-out.exp on s390x

Message ID 20241205073511.4236-3-tdevries@suse.de
State Committed
Headers
Series Fix gdb.dap with s390x-linux |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Test passed

Commit Message

Tom de Vries Dec. 5, 2024, 7:35 a.m. UTC
  With test-case gdb.dap/step-out.exp on s390x-linux, I get:
...
>>> {"seq": 7, "type": "request", "command": "scopes", "arguments": {"frameId": 0}}
Content-Length: 569^M
^M
{"request_seq": 7, "type": "response", "command": "scopes", "body": {"scopes": [{"variablesReference": 1, "name": "Locals", "presentationHint": "locals", "expensive": false, "namedVariables": 1, "line": 35, "source": {"name": "step-out.c", "path": "/home/vries/gdb/src/gdb/testsuite/gdb.dap/step-out.c"}}, {"variablesReference": 2, "name": "Registers", "presentationHint": "registers", "expensive": false, "namedVariables": 114, "line": 35, "source": {"name": "step-out.c", "path": "/home/vries/gdb/src/gdb/testsuite/gdb.dap/step-out.c"}}]}, "success": true, "seq": 21}PASS: gdb.dap/step-out.exp: get scopes success
FAIL: gdb.dap/step-out.exp: three scopes
...

The problem is that the test-case expects three scopes:
...
lassign $scopes scope reg_scope return_scope
...
but the return_scope is missing because this doesn't work:
...
$ gdb -q -batch outputs/gdb.dap/step-out/step-out \
    -ex "b function_breakpoint_here" \
    -ex run \
    -ex finish
  ...
Value returned has type: struct result. Cannot determine contents
...

This is likely caused by a problem in gdb, but there's nothing wrong the DAP
support.

Fix this by:
- allowing two scopes, and
- declaring the tests of return_scope unsupported.

Tested on s390x-linux.
---
 gdb/testsuite/gdb.dap/step-out.exp | 52 +++++++++++++++++-------------
 1 file changed, 29 insertions(+), 23 deletions(-)
  

Comments

Tom Tromey Dec. 9, 2024, 7:52 p.m. UTC | #1
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> The problem is that the test-case expects three scopes:
Tom> ...
Tom> lassign $scopes scope reg_scope return_scope
Tom> ...
Tom> but the return_scope is missing because this doesn't work:

Yeah, I forgot that some architectures can't do this in some cases.

Thanks for the patch, this looks good to me.
Approved-By: Tom Tromey <tom@tromey.com>

Tom
  

Patch

diff --git a/gdb/testsuite/gdb.dap/step-out.exp b/gdb/testsuite/gdb.dap/step-out.exp
index 193264fa250..40b21d64fc7 100644
--- a/gdb/testsuite/gdb.dap/step-out.exp
+++ b/gdb/testsuite/gdb.dap/step-out.exp
@@ -59,31 +59,37 @@  set scopes [dap_check_request_and_response "get scopes" scopes \
 		[format {o frameId [i %d]} $frame_id]]
 set scopes [dict get [lindex $scopes 0] body scopes]
 
-gdb_assert {[llength $scopes] == 3} "three scopes"
+gdb_assert {[llength $scopes] == 2 || [llength $scopes] == 3} "two or three scopes"
 
 lassign $scopes scope reg_scope return_scope
-gdb_assert {[dict get $scope name] == "Locals"} "scope is locals"
-gdb_assert {[dict get $scope presentationHint] == "locals"} \
-    "locals presentation hint"
-gdb_assert {[dict get $scope namedVariables] == 1} "one var in scope"
-
-gdb_assert {[dict get $return_scope name] == "Return"} "scope is return"
-gdb_assert {[dict get $return_scope presentationHint] == "returnValue"} \
-    "returnValue presentation hint"
-gdb_assert {[dict get $return_scope namedVariables] == 1} \
-    "one var in return scope"
-
-set num [dict get $return_scope variablesReference]
-set refs [lindex [dap_check_request_and_response "fetch arguments" \
-		      "variables" \
-		      [format {o variablesReference [i %d]} $num]] \
-	      0]
-set varlist [lindex [dict get $refs body variables] 0]
-
-gdb_assert {[dict get $varlist variablesReference] > 0} \
-    "variable has children"
-gdb_assert {[dict get $varlist name] == "(return)"} \
-    "variable is return value"
+
+set test "scope is locals"
+if { $return_scope == "" } {
+    unsupported $test
+} else {
+    gdb_assert {[dict get $scope name] == "Locals"} $test
+    gdb_assert {[dict get $scope presentationHint] == "locals"} \
+	"locals presentation hint"
+    gdb_assert {[dict get $scope namedVariables] == 1} "one var in scope"
+
+    gdb_assert {[dict get $return_scope name] == "Return"} "scope is return"
+    gdb_assert {[dict get $return_scope presentationHint] == "returnValue"} \
+	"returnValue presentation hint"
+    gdb_assert {[dict get $return_scope namedVariables] == 1} \
+	"one var in return scope"
+
+    set num [dict get $return_scope variablesReference]
+    set refs [lindex [dap_check_request_and_response "fetch arguments" \
+			  "variables" \
+			  [format {o variablesReference [i %d]} $num]] \
+		  0]
+    set varlist [lindex [dict get $refs body variables] 0]
+
+    gdb_assert {[dict get $varlist variablesReference] > 0} \
+	"variable has children"
+    gdb_assert {[dict get $varlist name] == "(return)"} \
+	"variable is return value"
+}
 
 set response_and_events [dap_request_and_response stepOut {o threadId [i 1]}]
 set response [lindex $response_and_events 0]