[Lldb-commits] [lldb] r238961 - Fix a bug where trying to Dump() a ValueObject would use the static/non-synthetic version of the value even if the ValueObject one actually called Dump() on turned out to be dynamic and/or synthetic
Enrico Granata
egranata at apple.com
Wed Jun 3 13:43:54 PDT 2015
Author: enrico
Date: Wed Jun 3 15:43:54 2015
New Revision: 238961
URL: http://llvm.org/viewvc/llvm-project?rev=238961&view=rev
Log:
Fix a bug where trying to Dump() a ValueObject would use the static/non-synthetic version of the value even if the ValueObject one actually called Dump() on turned out to be dynamic and/or synthetic
This was of course overridable by using DumpValueObjectOptions, but the default should be saner and the previous behavior made for a few fun investigations....
rdar://problem/21065149
Added:
lldb/trunk/test/functionalities/data-formatter/dump_dynamic/
lldb/trunk/test/functionalities/data-formatter/dump_dynamic/Makefile
lldb/trunk/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py
lldb/trunk/test/functionalities/data-formatter/dump_dynamic/main.cpp
Modified:
lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h
lldb/trunk/source/Core/ValueObject.cpp
lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
Modified: lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h?rev=238961&r1=238960&r2=238961&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/ValueObjectPrinter.h Wed Jun 3 15:43:54 2015
@@ -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,
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=238961&r1=238960&r2=238961&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Wed Jun 3 15:43:54 2015
@@ -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, c
void
ValueObject::Dump (Stream &s)
{
- Dump (s, DumpValueObjectOptions::DefaultOptions());
+ Dump (s, DumpValueObjectOptions(*this));
}
void
Modified: lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp?rev=238961&r1=238960&r2=238961&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp (original)
+++ lldb/trunk/source/DataFormatters/ValueObjectPrinter.cpp Wed Jun 3 15:43:54 2015
@@ -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)
Added: lldb/trunk/test/functionalities/data-formatter/dump_dynamic/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/dump_dynamic/Makefile?rev=238961&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/dump_dynamic/Makefile (added)
+++ lldb/trunk/test/functionalities/data-formatter/dump_dynamic/Makefile Wed Jun 3 15:43:54 2015
@@ -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
Added: lldb/trunk/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py?rev=238961&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py (added)
+++ lldb/trunk/test/functionalities/data-formatter/dump_dynamic/TestDumpDynamic.py Wed Jun 3 15:43:54 2015
@@ -0,0 +1,3 @@
+import lldbinline
+
+lldbinline.MakeInlineTest(__file__, globals())
Added: lldb/trunk/test/functionalities/data-formatter/dump_dynamic/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/dump_dynamic/main.cpp?rev=238961&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/data-formatter/dump_dynamic/main.cpp (added)
+++ lldb/trunk/test/functionalities/data-formatter/dump_dynamic/main.cpp Wed Jun 3 15:43:54 2015
@@ -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 *"))
+}
More information about the lldb-commits
mailing list