Files
llvm/lldb/test/cpp/dynamic-value/pass-to-base.cpp
Jim Ingham 78a685aa2d Add support for "dynamic values" for C++ classes. This currently only works for "frame var" and for the
expressions that are simple enough to get passed to the "frame var" underpinnings.  The parser code will
have to be changed to also query for the dynamic types & offsets as it is looking up variables.

The behavior of "frame var" is controlled in two ways.  You can pass "-d {true/false} to the frame var
command to get the dynamic or static value of the variables you are printing.

There's also a general setting:

target.prefer-dynamic-value (boolean) = 'true'

which is consulted if you call "frame var" without supplying a value for the -d option.

llvm-svn: 129623
2011-04-16 00:01:13 +00:00

63 lines
1.3 KiB
C++

#include <stdio.h>
#include <memory>
class Extra
{
public:
Extra (int in_one, int in_two) : m_extra_one(in_one), m_extra_two(in_two) {}
private:
int m_extra_one;
int m_extra_two;
};
class A
{
public:
A(int value) : m_a_value (value) {}
A(int value, A* client_A) : m_a_value (value), m_client_A (client_A) {}
virtual void
doSomething (A &anotherA)
{
printf ("In A %p doing something with %d.\n", this, m_a_value);
printf ("Also have another A at %p: %d.\n", &anotherA, anotherA.Value()); // Break here in doSomething.
}
int
Value()
{
return m_a_value;
}
private:
int m_a_value;
std::auto_ptr<A> m_client_A;
};
class B : public Extra, public virtual A
{
public:
B (int b_value, int a_value) : Extra(b_value, a_value), A(a_value), m_b_value(b_value) {}
B (int b_value, int a_value, A *client_A) : Extra(b_value, a_value), A(a_value, client_A), m_b_value(b_value) {}
private:
int m_b_value;
};
static A* my_global_A_ptr;
int
main (int argc, char **argv)
{
my_global_A_ptr = new B (100, 200);
B myB (10, 20, my_global_A_ptr);
B otherB (300, 400, my_global_A_ptr);
myB.doSomething(otherB); // Break here and get real addresses of myB and otherB.
A reallyA (500);
myB.doSomething (reallyA); // Break here and get real address of reallyA.
return 0;
}