forked from OSchip/llvm-project
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 llvm-svn: 238961
This commit is contained in:
parent
4bcc13d988
commit
d595733617
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
|
@ -0,0 +1,3 @@
|
|||
import lldbinline
|
||||
|
||||
lldbinline.MakeInlineTest(__file__, globals())
|
|
@ -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 *"))
|
||||
}
|
Loading…
Reference in New Issue