llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-lldb

Author: Nerixyz (Nerixyz)

<details>
<summary>Changes</summary>

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`.

---
Full diff: https://github.com/llvm/llvm-project/pull/204177.diff


2 Files Affected:

- (modified) lldb/source/Symbol/Variable.cpp (+5) 
- (modified) 
lldb/test/API/functionalities/scripted_frame_provider/TestScriptedFrameProvider.py
 (+5-3) 


``````````diff
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.

``````````

</details>


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

Reply via email to