summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/DataFormatters/ValueObjectPrinter.h5
-rw-r--r--lldb/source/Core/ValueObject.cpp4
-rw-r--r--lldb/source/DataFormatters/ValueObjectPrinter.cpp22
-rw-r--r--lldb/test/functionalities/data-formatter/dump_dynamic/Makefile12
-rw-r--r--lldb/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py3
-rw-r--r--lldb/test/functionalities/data-formatter/dump_dynamic/main.cpp35
6 files changed, 79 insertions, 2 deletions
diff --git a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
index 235d5389ee7..dc05fd48267 100644
--- a/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
+++ b/lldb/include/lldb/DataFormatters/ValueObjectPrinter.h
@@ -75,6 +75,8 @@ struct DumpValueObjectOptions
DumpValueObjectOptions (const DumpValueObjectOptions& rhs) = default;
+ DumpValueObjectOptions (ValueObject& valobj);
+
DumpValueObjectOptions&
SetMaximumPointerDepth(uint32_t depth = 0)
{
@@ -246,6 +248,9 @@ struct DumpValueObjectOptions
class ValueObjectPrinter
{
public:
+
+ ValueObjectPrinter (ValueObject* valobj,
+ Stream* s);
ValueObjectPrinter (ValueObject* valobj,
Stream* s,
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index a9e85dc5c35..8718b37b95e 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -3560,7 +3560,7 @@ void
ValueObject::LogValueObject (Log *log)
{
if (log)
- return LogValueObject (log, DumpValueObjectOptions::DefaultOptions());
+ return LogValueObject (log, DumpValueObjectOptions(*this));
}
void
@@ -3578,7 +3578,7 @@ ValueObject::LogValueObject (Log *log, const DumpValueObjectOptions& options)
void
ValueObject::Dump (Stream &s)
{
- Dump (s, DumpValueObjectOptions::DefaultOptions());
+ Dump (s, DumpValueObjectOptions(*this));
}
void
diff --git a/lldb/source/DataFormatters/ValueObjectPrinter.cpp b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
index 8fd627020bc..7c794ee2dda 100644
--- a/lldb/source/DataFormatters/ValueObjectPrinter.cpp
+++ b/lldb/source/DataFormatters/ValueObjectPrinter.cpp
@@ -21,6 +21,28 @@
using namespace lldb;
using namespace lldb_private;
+DumpValueObjectOptions::DumpValueObjectOptions (ValueObject& valobj) :
+DumpValueObjectOptions()
+{
+ m_use_dynamic = valobj.GetDynamicValueType();
+ m_use_synthetic = valobj.IsSynthetic();
+}
+
+ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
+ Stream* s)
+{
+ if (valobj)
+ {
+ DumpValueObjectOptions options(*valobj);
+ Init (valobj,s,options,options.m_max_ptr_depth,0);
+ }
+ else
+ {
+ DumpValueObjectOptions options;
+ Init (valobj,s,options,options.m_max_ptr_depth,0);
+ }
+}
+
ValueObjectPrinter::ValueObjectPrinter (ValueObject* valobj,
Stream* s,
const DumpValueObjectOptions& options)
diff --git a/lldb/test/functionalities/data-formatter/dump_dynamic/Makefile b/lldb/test/functionalities/data-formatter/dump_dynamic/Makefile
new file mode 100644
index 00000000000..69dde1b7618
--- /dev/null
+++ b/lldb/test/functionalities/data-formatter/dump_dynamic/Makefile
@@ -0,0 +1,12 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp
+CXXFLAGS += -std=c++11
+
+# clang-3.5+ outputs FullDebugInfo by default for Darwin/FreeBSD
+# targets. Other targets do not, which causes this test to fail.
+# This flag enables FullDebugInfo for all targets.
+ifneq (,$(findstring clang,$(CC)))
+ CFLAGS_EXTRAS += -fno-limit-debug-info
+endif
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py b/lldb/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py
new file mode 100644
index 00000000000..a70d2ca7414
--- /dev/null
+++ b/lldb/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py
@@ -0,0 +1,3 @@
+import lldbinline
+
+lldbinline.MakeInlineTest(__file__, globals())
diff --git a/lldb/test/functionalities/data-formatter/dump_dynamic/main.cpp b/lldb/test/functionalities/data-formatter/dump_dynamic/main.cpp
new file mode 100644
index 00000000000..612187e925b
--- /dev/null
+++ b/lldb/test/functionalities/data-formatter/dump_dynamic/main.cpp
@@ -0,0 +1,35 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+class Base {
+public:
+ Base () = default;
+ virtual int func() { return 1; }
+ virtual ~Base() = default;
+};
+
+class Derived : public Base {
+private:
+ int m_derived_data;
+public:
+ Derived () : Base(), m_derived_data(0x0fedbeef) {}
+ virtual ~Derived() = default;
+ virtual int func() { return m_derived_data; }
+};
+
+int main (int argc, char const *argv[])
+{
+ Base *base = new Derived();
+ return 0; //% stream = lldb.SBStream()
+ //% base = self.frame().FindVariable("base")
+ //% base.SetPreferDynamicValue(lldb.eDynamicDontRunTarget)
+ //% base.GetDescription(stream)
+ //% if self.TraceOn(): print stream.GetData()
+ //% self.assertTrue(stream.GetData().startswith("(Derived *"))
+}
OpenPOWER on IntegriCloud