[Lldb-commits] [lldb] r353363 - [lldb] Make frame recognizers vend synthesized eValueTypeVariableArgument values

Kuba Mracek via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 6 17:49:10 PST 2019


Author: kuba.brecka
Date: Wed Feb  6 17:49:10 2019
New Revision: 353363

URL: http://llvm.org/viewvc/llvm-project?rev=353363&view=rev
Log:
[lldb] Make frame recognizers vend synthesized eValueTypeVariableArgument values


Modified:
    lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
    lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
    lldb/trunk/source/Target/StackFrameRecognizer.cpp

Modified: lldb/trunk/include/lldb/Target/StackFrameRecognizer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/StackFrameRecognizer.h?rev=353363&r1=353362&r2=353363&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/StackFrameRecognizer.h (original)
+++ lldb/trunk/include/lldb/Target/StackFrameRecognizer.h Wed Feb  6 17:49:10 2019
@@ -9,6 +9,7 @@
 #ifndef liblldb_StackFrameRecognizer_h_
 #define liblldb_StackFrameRecognizer_h_
 
+#include "lldb/Core/ValueObject.h"
 #include "lldb/Core/ValueObjectList.h"
 #include "lldb/Symbol/VariableList.h"
 #include "lldb/Utility/StructuredData.h"
@@ -123,6 +124,42 @@ public:
   static lldb::RecognizedStackFrameSP RecognizeFrame(lldb::StackFrameSP frame);
 };
 
+/// @class ValueObjectRecognizerSynthesizedValue
+///
+/// ValueObject subclass that presents the passed ValueObject as a recognized
+/// value with the specified ValueType. Frame recognizers should return
+/// instances of this class as the returned objects in GetRecognizedArguments().
+
+class ValueObjectRecognizerSynthesizedValue : public ValueObject {
+ public:
+  static lldb::ValueObjectSP Create(ValueObject &parent, lldb::ValueType type) {
+    return (new ValueObjectRecognizerSynthesizedValue(parent, type))->GetSP();
+  }
+  ValueObjectRecognizerSynthesizedValue(ValueObject &parent,
+                                        lldb::ValueType type)
+      : ValueObject(parent), m_type(type) {
+    SetName(parent.GetName());
+  }
+
+  uint64_t GetByteSize() override { return m_parent->GetByteSize(); }
+  lldb::ValueType GetValueType() const override { return m_type; }
+  bool UpdateValue() override {
+    if (!m_parent->UpdateValueIfNeeded()) return false;
+    m_value = m_parent->GetValue();
+    return true;
+  }
+  size_t CalculateNumChildren(uint32_t max = UINT32_MAX) override {
+    return m_parent->GetNumChildren(max);
+  }
+  CompilerType GetCompilerTypeImpl() override {
+    return m_parent->GetCompilerType();
+  }
+  bool IsSynthetic() override { return true; }
+
+ private:
+  lldb::ValueType m_type;
+};
+
 } // namespace lldb_private
 
 #endif // liblldb_StackFrameRecognizer_h_

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py?rev=353363&r1=353362&r2=353363&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/frame-recognizer/TestFrameRecognizer.py Wed Feb  6 17:49:10 2019
@@ -89,8 +89,10 @@ class FrameRecognizerTestCase(TestBase):
         self.assertEqual(variables.GetSize(), 2)
         self.assertEqual(variables.GetValueAtIndex(0).name, "a")
         self.assertEqual(variables.GetValueAtIndex(0).signed, 42)
+        self.assertEqual(variables.GetValueAtIndex(0).GetValueType(), lldb.eValueTypeVariableArgument)
         self.assertEqual(variables.GetValueAtIndex(1).name, "b")
         self.assertEqual(variables.GetValueAtIndex(1).signed, 56)
+        self.assertEqual(variables.GetValueAtIndex(1).GetValueType(), lldb.eValueTypeVariableArgument)
 
         self.expect("frame recognizer info 0",
                     substrs=['frame 0 is recognized by recognizer.MyFrameRecognizer'])

Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py?rev=353363&r1=353362&r2=353363&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/lang/objc/exceptions/TestObjCExceptions.py Wed Feb  6 17:49:10 2019
@@ -44,6 +44,7 @@ class ObjCExceptionsTestCase(TestBase):
 
         self.assertEqual(variables.GetSize(), 1)
         self.assertEqual(variables.GetValueAtIndex(0).name, "exception")
+        self.assertEqual(variables.GetValueAtIndex(0).GetValueType(), lldb.eValueTypeVariableArgument)
 
         lldbutil.run_to_source_breakpoint(self, "// Set break point at this line.", lldb.SBFileSpec("main.mm"), launch_info=launch_info)
 

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=353363&r1=353362&r2=353363&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed Feb  6 17:49:10 2019
@@ -2628,6 +2628,8 @@ class ObjCExceptionRecognizedStackFrame
     value.SetCompilerType(voidstar);
     exception = ValueObjectConstResult::Create(frame_sp.get(), value,
                                                ConstString("exception"));
+    exception = ValueObjectRecognizerSynthesizedValue::Create(
+        *exception, eValueTypeVariableArgument);
     exception = exception->GetDynamicValue(eDynamicDontRunTarget);
       
     m_arguments = ValueObjectListSP(new ValueObjectList());

Modified: lldb/trunk/source/Target/StackFrameRecognizer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrameRecognizer.cpp?rev=353363&r1=353362&r2=353363&view=diff
==============================================================================
--- lldb/trunk/source/Target/StackFrameRecognizer.cpp (original)
+++ lldb/trunk/source/Target/StackFrameRecognizer.cpp Wed Feb  6 17:49:10 2019
@@ -40,8 +40,14 @@ ScriptedStackFrameRecognizer::RecognizeF
 
   ValueObjectListSP args =
       m_interpreter->GetRecognizedArguments(m_python_object_sp, frame);
+  auto args_synthesized = ValueObjectListSP(new ValueObjectList());
+  for (const auto o : args->GetObjects()) {
+    args_synthesized->Append(ValueObjectRecognizerSynthesizedValue::Create(
+        *o, eValueTypeVariableArgument));
+  }
 
-  return RecognizedStackFrameSP(new ScriptedRecognizedStackFrame(args));
+  return RecognizedStackFrameSP(
+      new ScriptedRecognizedStackFrame(args_synthesized));
 }
 
 #endif




More information about the lldb-commits mailing list