]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Show constants in DAP scopes output
authorTom Tromey <tromey@adacore.com>
Wed, 3 Dec 2025 18:20:53 +0000 (11:20 -0700)
committerTom Tromey <tromey@adacore.com>
Fri, 9 Jan 2026 15:37:27 +0000 (08:37 -0700)
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 <eliz@gnu.org>
gdb/NEWS
gdb/python/lib/gdb/FrameDecorator.py
gdb/testsuite/gdb.dap/ada-non-ascii.exp
gdb/testsuite/gdb.dap/ada-non-ascii/prog.adb
gdb/testsuite/gdb.dap/ada-scopes.exp

index 9d3f2e97ed9f517f6fd5c53c1fd8fcc363868b96..cd0303fa199d9aac4fa4b25d162d73bdbe7c1680 100644 (file)
--- 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
index 310b9e6202712abbad14ab068a429a0763da50b8..f8e3276ff403d9ba5acd120422df7b50a39a1509 100644 (file)
@@ -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.
index 3145886333762da5a31b2b3b6e6b398f32c91404..fa9d30e6780bf7239e2e7d9ba7705201fa55b453 100644 (file)
@@ -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 {
index ec844539b1a03c0c4c464458739e949e22eaff54..7853be5eff8b110cfbba21b3319529639babc4ec 100644 (file)
@@ -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;
index 5b568c3fe9411604cd8dba360a7625de1047780f..f16d3ae54258f6082dd3eff9b8b463d31d1b4eaa 100644 (file)
@@ -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"
        }