https://github.com/Nerixyz created 
https://github.com/llvm/llvm-project/pull/204177

When the variables in scope are requested, synthetic variables wouldn't be 
returned, because `Variable::IsInScope` would return false. With this PR, we 
return true for synthetic variables.

There's still one inconsistency between `frame var` and `SBFrame::GetVariables` 
where `frame var` shows "re-exported" variables from real frames (here: 
`variable_in_main`). Note that `IsSyntheticValueType` returns false for 
`variable_in_main`.

>From f6aee649d87227bf2707a03009301af62adb3d12 Mon Sep 17 00:00:00 2001
From: Nerixyz <[email protected]>
Date: Tue, 16 Jun 2026 16:53:33 +0200
Subject: [PATCH] [lldb] Treat synthetic variables as always in scope

---
 lldb/source/Symbol/Variable.cpp                           | 5 +++++
 .../scripted_frame_provider/TestScriptedFrameProvider.py  | 8 +++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 3f280d9cec2c6..7b96b6e8d71f4 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -31,6 +31,7 @@
 #include "lldb/Utility/Log.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Stream.h"
+#include "lldb/Utility/ValueType.h"
 #include "lldb/ValueObject/ValueObject.h"
 #include "lldb/ValueObject/ValueObjectVariable.h"
 
@@ -281,6 +282,10 @@ bool Variable::LocationIsValidForAddress(const Address 
&address) {
 }
 
 bool Variable::IsInScope(StackFrame *frame) {
+  // Synthetic values are always in scope.
+  if (IsSyntheticValueType(m_scope))
+    return true;
+
   switch (m_scope) {
   case eValueTypeRegister:
   case eValueTypeRegisterSet:
diff --git 
a/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py
 
b/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py
index 597447723047e..f1882582883df 100644
--- 
a/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py
+++ 
b/lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py
@@ -840,10 +840,12 @@ def test_get_values(self):
         self.assertTrue(variables.IsValid())
         self.assertTrue(variables.GetValueAtIndex(0).name == "_handler_one")
 
-        # FIXME: Synthetic variables are never in scope.
+        # Synthetic variables are always in scope.
         variables = frame0.GetVariables(False, False, False, True)
-        self.assertFalse(variables.IsValid())
-        self.assertEqual(variables.GetSize(), 0)
+        self.assertTrue(variables.IsValid())
+        # FIXME: This should also include `variable_in_main` like `frame var`.
+        self.assertEqual(variables.GetSize(), 1)
+        self.assertEqual(variables.GetValueAtIndex(0).name, "_handler_one")
 
         # Check the `frame variable` command(s) handle synthetic variables the
         # way we expect by printing them.

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to