]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix gdb.dap/ada-non-ascii.exp for gcc < 10
authorTom de Vries <tdevries@suse.de>
Mon, 26 Jan 2026 14:36:26 +0000 (15:36 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 26 Jan 2026 14:36:26 +0000 (15:36 +0100)
On openSUSE Leap 15.6, test-case gdb.dap/ada-non-ascii.exp passes with
gcc 10-12.

But with gcc 7-9 I see:
...
{"request_seq": 6, "type": "response", "command": "scopes", "success": true,
"body": {"scopes": [{"variablesReference": 1, "name": "Locals",
"presentationHint": "locals", "expensive": false, "namedVariables": 1,
"line": 22, "source": {"name": "prog.adb", "path":
"/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.dap/ada-non-ascii/prog.adb"}},
{"variablesReference": 2, "name": "Registers", "presentationHint": "registers",
"expensive": false, "namedVariables": 61, "line": 22, "source": {"name":
"prog.adb", "path":
"/data/vries/gdb/binutils-gdb.git/gdb/testsuite/gdb.dap/ada-non-ascii/prog.adb"}}]},
"seq": 18}
PASS: gdb.dap/ada-non-ascii.exp: get scopes success
PASS: gdb.dap/ada-non-ascii.exp: local scope
PASS: gdb.dap/ada-non-ascii.exp: register scope
FAIL: gdb.dap/ada-non-ascii.exp: correct number of locals
...

This is not dap-specific, also with the CLI I see:
...
$ gdb -q -batch prog -ex "break prog.adb:22" -ex run -ex "info locals"
  ...
<W03a0> = 3
...
vs.:
...
<W03a0> = 3
<W03a6> = 7
...

This corresponds to the debug info, for gcc 9 we have:
...
 <1><1866>: Abbrev Number: 3 (DW_TAG_subprogram)
    <1867>   DW_AT_name        : prog
 <2><1888>: Abbrev Number: 4 (DW_TAG_variable)
    <1889>   DW_AT_name        : W03a0
    <1894>   DW_AT_location    : 2 byte block: 91 6c    (DW_OP_fbreg: -20)
...
and for gcc 10 we have instead:
...
 <1><187d>: Abbrev Number: 3 (DW_TAG_subprogram)
    <187e>   DW_AT_name        : prog
 <2><189f>: Abbrev Number: 4 (DW_TAG_variable)
    <18a0>   DW_AT_name        : W03a0
    <18ab>   DW_AT_location    : 2 byte block: 91 6c    (DW_OP_fbreg: -20)
 <2><18ae>: Abbrev Number: 5 (DW_TAG_constant)
    <18af>   DW_AT_name        : W03a6
    <18ba>   DW_AT_const_value : 7
...

Fix this by allowing 1 local variable for gcc < 10.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/gdb.dap/ada-non-ascii.exp

index fa9d30e6780bf7239e2e7d9ba7705201fa55b453..ed1a7fea5df9f5cd67b7df204781908cf071e301 100644 (file)
@@ -68,7 +68,12 @@ gdb_assert {[dict get $locals name] == "Locals"} "local scope"
 gdb_assert {[dict get $regs name] == "Registers"} "register scope"
 
 set num_vars [dict get $locals namedVariables]
-gdb_assert {$num_vars == 2} "correct number of locals"
+
+if { [gnat_version_compare < 10] } {
+    gdb_assert {$num_vars <= 2} "correct number of locals"
+} else {
+    gdb_assert {$num_vars == 2} "correct number of locals"
+}
 
 set num [dict get $locals variablesReference]
 set refs [lindex [dap_check_request_and_response "fetch variables" \