From c51fb386792206f12459b22bf7eec8345c4886a6 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 2 Jul 2024 10:43:51 -0600 Subject: Add returnValue scope to DAP The DAP spec recently changed to add a new scope for the return value from a "stepOut" request. This new scope uses the "returnValue" presentation hint. See: https://github.com/microsoft/debug-adapter-protocol/issues/458 This patch implements this for gdb. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31945 Reviewed-By: Eli Zaretskii --- gdb/python/lib/gdb/dap/scopes.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'gdb/python') diff --git a/gdb/python/lib/gdb/dap/scopes.py b/gdb/python/lib/gdb/dap/scopes.py index d0e9115..fb90f64 100644 --- a/gdb/python/lib/gdb/dap/scopes.py +++ b/gdb/python/lib/gdb/dap/scopes.py @@ -111,20 +111,19 @@ class _ScopeReference(BaseReference): return symbol_value(self.var_list[idx], self.frame) -# A _ScopeReference that prepends the most recent return value. Note -# that this object is only created if such a value actually exists. +# A _ScopeReference that wraps the 'finish' value. Note that this +# object is only created if such a value actually exists. class _FinishScopeReference(_ScopeReference): - def __init__(self, *args): - super().__init__(*args) + def __init__(self, frame): + super().__init__("Return", "returnValue", frame, ()) def child_count(self): - return super().child_count() + 1 + return 1 def fetch_one_child(self, idx): - if idx == 0: - global _last_return_value - return ("(return)", _last_return_value) - return super().fetch_one_child(idx - 1) + assert idx == 0 + global _last_return_value + return ("(return)", _last_return_value) class _RegisterReference(_ScopeReference): @@ -159,11 +158,11 @@ def scopes(*, frameId: int, **extra): # Make sure to handle the None case as well as the empty # iterator case. locs = tuple(frame.frame_locals() or ()) - if has_return_value: - scopes.append(_FinishScopeReference("Locals", "locals", frame, locs)) - elif locs: + if locs: scopes.append(_ScopeReference("Locals", "locals", frame, locs)) scopes.append(_RegisterReference("Registers", frame)) + if has_return_value: + scopes.append(_FinishScopeReference(frame)) frame_to_scope[frameId] = scopes global_scope = get_global_scope(frame) if global_scope is not None: -- cgit v1.1