From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id MUqlFkm/mWq1GyYAWB0awg (envelope-from ) for ; Thu, 03 Sep 2026 14:41:13 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=dJ1o5O7n; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2B3641E033; Thu, 03 Sep 2026 14:41:13 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id C60491E033 for ; Thu, 03 Sep 2026 14:41:11 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DBCD64BA9034 for ; Thu, 3 Sep 2026 18:41:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DBCD64BA9034 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=dJ1o5O7n Received: from mail-oi1-x22b.google.com (mail-oi1-x22b.google.com [IPv6:2607:f8b0:4864:20::22b]) by sourceware.org (Postfix) with ESMTPS id C5DEC4BA9034 for ; Thu, 3 Sep 2026 18:40:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5DEC4BA9034 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C5DEC4BA9034 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::22b ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788460846; cv=none; b=cqVGYBxi6iUooyz6F8h+xIUFtDEq8EWMqhESQ+CReQj28U4flm4lBOG9n05hf1P9ciWvmRNl0cVu98LwZAv/XXKy8iZJCrZjFxxpOPhraasfTSAeqBV4R0hPhHR0goba9Ms1dyu+tKKKLLHlTQ31ZmvACKdNXztjlUvZyx7OeXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1788460846; c=relaxed/simple; bh=gOCyrOI6l2qSF+1IG6c/7up4fS28pMpwNmXXHcQ8X/4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Oh+IWFsWCGWq8GLo7QAcBytASEOFPtMsocdgfkAQsKXWK2x4a19e1LC/qSe8jxM45I7qg8viCyrRPeishd4FtnECPorZxihw1dW8j+CfcX4IbJMJSqu84wBoCNaYKGaMpBc9npYn3ls17jCh2VR0G8z4VJIAU1deHiujQVv0FEQ= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=dJ1o5O7n DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C5DEC4BA9034 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-4a40bcc8d69so190756b6e.3 for ; Thu, 03 Sep 2026 11:40:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1788460845; x=1789065645; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=e6nDVv6zeyWUbFdvJiQ24fBvYcDmlYs1C+ymCXgpxGY=; b=dJ1o5O7n7R+K6Is3NQH9hOmEhCEx6mY6exOAyxCOwW2jy64FQzJdgGA32JyoHmnAN+ nSf2aivtYiBQY3YRI43cb+0eSXWilsB4lWmBocRNGgE+M2NCRkr5YM781r3fDB4weM2o WQqfDLZccI+ylfwphHuAQXm2VRubgLaHGvvbWaVV19Y8FyZVo4LbU+Pl2BmRgohRO052 xQ+5oSl26joaVtTD/SEn1GrULTpBOvsrwFxd9I9BlWDt2IJQzBzM/Ym8YRFpq23HlpPA WON4Qs9W/swzBizRSUpB/DZaeT6Iu/a8kNSWa/kBP5+HOuG76QVCf2owQYHlwyvoCQng inpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788460845; x=1789065645; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=e6nDVv6zeyWUbFdvJiQ24fBvYcDmlYs1C+ymCXgpxGY=; b=LFSm8JcYH/kqvLT8wHpyQwSTD/gMl1X84Tg/o8PBioc6jNz2l0Hdm7TwbUQY9xPrW0 QWIA4oZUanpWYoJnosEbEkF0c2BqSeI9NlaJG6Li8v8Mc1aiOJT8RnlbF9e0rdrI4VaP ATdrIEgojV5iNkXVLfj6BOwM5DK5gayxzCBfnGuhnNYFUpo1MlhPZW42mDu5XI/3W4CY 7aiFEjF3sVbSL9deaHN9BO24xJwSYRquI536sJdkWPXhhcLIhzTVQB+15+1bkrs/b7wC M9KpJbpKE2b/pVlIYILGYTdvqW5Eq3koFlkqPCuMiQNCHv7JVdWrJHeOtJNJKzWCN5Zh eI3g== X-Gm-Message-State: AFuF++lcsrDtS86RZnh6KAuNMWjwNVpiLP/F6TPmTU7Jz26Lt9jFr01e qSZOY9OA6AY7Q/35umVFNmoC8G3T2K9qbbVvQRAn43o7mSKe0JeR6ITUfUCPN2pvHTkFVYMG/jV v4ORhDg== X-Gm-Gg: AYBFou1PaYrd8LP0We1VBel6girn/VUHZ5lyTLckQkdYhsJ/iZ6zwQ/dp1PP15LzFbQ Cs27aGo8oBYmDc4Z0uusFfr/GXHsM8WuHmieEZxiX1eyIW/U23+72pNRQXrTzNwJ1tuKjQ8PFo0 L0QVWsCgKnj+Q+mNTVsPUOdyfQFuEeDk0GmC9HhijzM6Ot+25RA3BnuLtfC1cBHMdCnMTKGy4XA jX8MXbDFpNXgFIKiXBGqcTvAlpcTjE44wuSdgmFGJB5A9ISePYfbc4yEQogffu3RKBYlPvFbzAr e8ES6XTIihxrW6HtU1xVzTUDyZF00k+vePH1Jjn3cJxSHfZjjcLyHzx9NL6qZnL5VZcGcOuLhgB KAspVXGny/C2PLc53FsqWDX/ej87isNuC0O1bwugiXfMWNaRN7uRKm2IzFzjeV2UTcJ3pm9+C1y 7zlWmzQAb4Vt8EbM7EdcTSiRre1YaVEmHFY/7IhvHOSyOD/Ni9mvVh+jKDjSaWwth+ytjS0Wbvt TM5 X-Received: by 2002:a05:6808:2f15:b0:4b3:96d7:fd59 with SMTP id 5614622812f47-4b9604837acmr487800b6e.8.1788460844982; Thu, 03 Sep 2026 11:40:44 -0700 (PDT) Received: from bapiya (97-122-117-2.hlrn.qwest.net. [97.122.117.2]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-47554d7d787sm317833fac.17.2026.09.03.11.40.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 11:40:44 -0700 (PDT) From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Add evaluateName to registers returned by DAP Date: Thu, 3 Sep 2026 12:40:41 -0600 Message-ID: <20260903184042.3954699-1-tromey@adacore.com> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This patch adds the evaluateName field to register variables returned by DAP. This isn't truly complete, in that referring to a sub-part of a register won't have an evaluateName. This is a larger problem, though, and requires a solution for pretty-printers as well. Meanwhile, this patch helps with a pretty typical case. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33407 --- gdb/python/lib/gdb/dap/bt.py | 2 +- gdb/python/lib/gdb/dap/globalvars.py | 2 +- gdb/python/lib/gdb/dap/scopes.py | 18 +++++++++++------- gdb/python/lib/gdb/dap/varref.py | 17 +++++++++++------ gdb/testsuite/gdb.dap/scopes.exp | 6 ++++++ 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/gdb/python/lib/gdb/dap/bt.py b/gdb/python/lib/gdb/dap/bt.py index b8976e54698..38eaea7759d 100644 --- a/gdb/python/lib/gdb/dap/bt.py +++ b/gdb/python/lib/gdb/dap/bt.py @@ -38,7 +38,7 @@ def _compute_parameters(frame, stack_format): result = [] for arg in arg_iter: desc = [] - name, val = symbol_value(arg, frame) + name, val, _ = symbol_value(arg, frame) # We don't try to use any particular language's syntax for the # output here. if stack_format["parameterTypes"]: diff --git a/gdb/python/lib/gdb/dap/globalvars.py b/gdb/python/lib/gdb/dap/globalvars.py index c90404362c4..70b1f64e24f 100644 --- a/gdb/python/lib/gdb/dap/globalvars.py +++ b/gdb/python/lib/gdb/dap/globalvars.py @@ -61,7 +61,7 @@ class _Globals(BaseReference): @in_gdb_thread def fetch_one_child(self, idx): sym = self._var_list[idx] - return (sym.print_name, sym.value()) + return (sym.print_name, sym.value(), None) @in_gdb_thread diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py index 98a710f2df5..2b88a2fd15b 100644 --- a/gdb/python/lib/gdb/dap/scopes.py +++ b/gdb/python/lib/gdb/dap/scopes.py @@ -55,8 +55,9 @@ def set_finish_value(val): # A helper function to compute the value of a symbol. SYM is either a # gdb.Symbol, or an object implementing the SymValueWrapper interface. # FRAME is a frame wrapper, as produced by a frame filter. Returns a -# tuple of the form (NAME, VALUE), where NAME is the symbol's name and -# VALUE is a gdb.Value. +# tuple of the form (NAME, VALUE, None), where NAME is the symbol's +# name and VALUE is a gdb.Value. The 'None' is returned because this +# function is called by fetch_one_child. @in_gdb_thread def symbol_value(sym, frame): inf_frame = frame.inferior_frame() @@ -72,7 +73,7 @@ def symbol_value(sym, frame): val = sym.symbol().value(inf_frame) elif not isinstance(val, gdb.Value): val = gdb.Value(val) - return (name, val) + return (name, val, None) class _ScopeReference(BaseReference): @@ -120,7 +121,9 @@ class _FinishScopeReference(_ScopeReference): def fetch_one_child(self, idx): assert idx == 0 - return ("(return)", _last_return_value) + # It might be nice to return an evaluateName here; maybe this + # could be done by introducing a convenience variable. + return ("(return)", _last_return_value, None) class _RegisterReference(_ScopeReference): @@ -134,12 +137,13 @@ class _RegisterReference(_ScopeReference): @in_gdb_thread def fetch_one_child(self, idx): - return ( - self._var_list[idx].name, + name = self._var_list[idx].name + value = ( frame_for_id(self._frameId) .inferior_frame() - .read_register(self._var_list[idx]), + .read_register(self._var_list[idx]) ) + return (name, value, "$" + name) @request("scopes") diff --git a/gdb/python/lib/gdb/dap/varref.py b/gdb/python/lib/gdb/dap/varref.py index e2dcd03910c..cd0321a7c82 100644 --- a/gdb/python/lib/gdb/dap/varref.py +++ b/gdb/python/lib/gdb/dap/varref.py @@ -107,8 +107,10 @@ class BaseReference(ABC): """Fetch one child of this variable. INDEX is the index of the child to fetch. - This should return a tuple of the form (NAME, VALUE), where - NAME is the name of the variable, and VALUE is a gdb.Value.""" + This should return a tuple of the form (NAME, VALUE, EVAL_NAME), + where NAME is the name of the variable, and VALUE is a gdb.Value. + EVAL_NAME may either be None, or a string that is used as the + variable's 'evaluateName'.""" return @abstractmethod @@ -153,9 +155,9 @@ class BaseReference(ABC): if idx >= len(self._children): break if self._children[idx] is None: - name, value = self.fetch_one_child(idx) + name, value, eval_name = self.fetch_one_child(idx) name = self._compute_name(name) - var = VariableReference(name, value) + var = VariableReference(name, value, eval_name=eval_name) self._children[idx] = var self._by_name[name] = var yield self._children[idx] @@ -176,7 +178,7 @@ class BaseReference(ABC): class VariableReference(BaseReference): """Concrete subclass of BaseReference that handles gdb.Value.""" - def __init__(self, name, value, result_name="value"): + def __init__(self, name, value, result_name="value", eval_name=None): """Initializer. NAME is the name of this reference, see superclass. @@ -186,6 +188,7 @@ class VariableReference(BaseReference): super().__init__(name) self._result_name = result_name self._value = value + self._eval_name = eval_name self._update_value() # Internal method to update local data when the value changes. @@ -261,6 +264,8 @@ class VariableReference(BaseReference): result["memoryReference"] = hex(int(self._value)) if client_bool_capability("supportsVariableType"): result["type"] = str(self._value.type) + if self._eval_name is not None: + result["evaluateName"] = self._eval_name return result @in_gdb_thread @@ -275,7 +280,7 @@ class VariableReference(BaseReference): # gdb.Value, but it must be convertible. if not isinstance(val, gdb.Value): val = gdb.Value(val) - return (name, val) + return (name, val, None) @in_gdb_thread diff --git a/gdb/testsuite/gdb.dap/scopes.exp b/gdb/testsuite/gdb.dap/scopes.exp index d22d39cbf8b..eb3e6a5e04f 100644 --- a/gdb/testsuite/gdb.dap/scopes.exp +++ b/gdb/testsuite/gdb.dap/scopes.exp @@ -153,6 +153,12 @@ lassign [dap_check_request_and_response "fetch all registers" \ # If any register has children, try to fetch those as well. This is a # regression test for part of PR dap/33228. foreach var [dict get $val body variables] { + # Check that gdb emits an evaluateName for each register. + set name [dict get $var name] + set evalName [dict get $var evaluateName] + gdb_assert {[string cat "$" $name] == $evalName} \ + "evaluateName for register $name" + set regvar [dict get $var variablesReference] if {$regvar > 0} { # If variablesReference is non-zero, then there must be either base-commit: 2986ed8ba365f7e583e2f6c9098ea5ec57ee50e1 -- 2.55.0