From: Tom Tromey Date: Wed, 3 Dec 2025 18:20:53 +0000 (-0700) Subject: Show constants in DAP scopes output X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d1d83ec7dbd9bbe53dac9b5f783f35522361a593;p=thirdparty%2Fbinutils-gdb.git Show constants in DAP scopes output This changes the DAP code so that constants will now be returned by a DAP scopes request. This is perhaps slightly strange with Ada enumerators, but on the other hand this is consistent with what the CLI does. Reviewed-By: Eli Zaretskii --- diff --git a/gdb/NEWS b/gdb/NEWS index 9d3f2e97ed9..cd0303fa199 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -100,6 +100,8 @@ New command class for help ** The launch and attach requests now accept the adaSourceCharset parameter. + ** Constants are now returned in scopes. + * Changed remote packets single-inf-arg in qSupported diff --git a/gdb/python/lib/gdb/FrameDecorator.py b/gdb/python/lib/gdb/FrameDecorator.py index 310b9e62027..f8e3276ff40 100644 --- a/gdb/python/lib/gdb/FrameDecorator.py +++ b/gdb/python/lib/gdb/FrameDecorator.py @@ -280,10 +280,11 @@ class FrameVars(object): if sym.is_argument: if not traversed_link: continue - elif not sym.is_variable: + elif not sym.is_variable and not sym.is_constant: # We use an 'elif' here because is_variable # returns False for arguments as well. Anyway, - # don't include non-variables here. + # don't include non-variables here, but remember + # to treat local constants the same as variables. continue elif sym.is_artificial: # Skip artificial symbols. diff --git a/gdb/testsuite/gdb.dap/ada-non-ascii.exp b/gdb/testsuite/gdb.dap/ada-non-ascii.exp index 31458863337..fa9d30e6780 100644 --- a/gdb/testsuite/gdb.dap/ada-non-ascii.exp +++ b/gdb/testsuite/gdb.dap/ada-non-ascii.exp @@ -68,7 +68,7 @@ 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 == 1} "correct number of locals" +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" \ @@ -87,8 +87,12 @@ foreach var [dict get $refs body variables] { switch -nocase -- $name { "\\u03a0" - "\\u03a6" - + "\\u03c0" - + "\\u03c6" - "Π" - - "π" { + "π" - + "Φ" - + "φ" { # Ok. } default { diff --git a/gdb/testsuite/gdb.dap/ada-non-ascii/prog.adb b/gdb/testsuite/gdb.dap/ada-non-ascii/prog.adb index ec844539b1a..7853be5eff8 100644 --- a/gdb/testsuite/gdb.dap/ada-non-ascii/prog.adb +++ b/gdb/testsuite/gdb.dap/ada-non-ascii/prog.adb @@ -17,6 +17,7 @@ with Pack; use Pack; procedure Prog is π : Integer := 3; -- The Indiana Approximation. + φ : constant := 7; -- Not even close. begin Do_Nothing (π'Address); -- BREAK end Prog; diff --git a/gdb/testsuite/gdb.dap/ada-scopes.exp b/gdb/testsuite/gdb.dap/ada-scopes.exp index 5b568c3fe94..f16d3ae5425 100644 --- a/gdb/testsuite/gdb.dap/ada-scopes.exp +++ b/gdb/testsuite/gdb.dap/ada-scopes.exp @@ -62,7 +62,7 @@ lassign $scopes scope _ignore gdb_assert {[dict get $scope name] == "Locals"} "scope is locals" gdb_assert {[dict get $scope source name] == "prog.adb"} "scope has source" -gdb_assert {[dict get $scope namedVariables] == 2} "two vars in scope" +gdb_assert {[dict get $scope namedVariables] == 5} "five vars in scope" set num [dict get $scope variablesReference] set refs [lindex [dap_check_request_and_response "fetch variables" \ @@ -80,6 +80,10 @@ foreach var [dict get $refs body variables] { } "my_string" { } + "one" - + "two" { + # Local enumerators appear in the scope. + } default { fail "unknown variable $name" }