Modified LLDB expressions to not have to JIT and run code just to see variable
values or persistent expression variables. Now if an expression consists of a value that is a child of a variable, or of a persistent variable only, we will create a value object for it and make a ValueObjectConstResult from it to freeze the value (for program variables only, not persistent variables) and avoid running JITed code. For everything else we still parse up and JIT code and run it in the inferior. There was also a lot of clean up in the expression code. I made the ClangExpressionVariables be stored in collections of shared pointers instead of in collections of objects. This will help stop a lot of copy constructors on these large objects and also cleans up the code considerably. The persistent clang expression variables were moved over to the Target to ensure they persist across process executions. Added the ability for lldb_private::Target objects to evaluate expressions. We want to evaluate expressions at the target level in case we aren't running yet, or we have just completed running. We still want to be able to access the persistent expression variables between runs, and also evaluate constant expressions. Added extra logging to the dynamic loader plug-in for MacOSX. ModuleList objects can now dump their contents with the UUID, arch and full paths being logged with appropriate prefix values. Thread hardened the Communication class a bit by making the connection auto_ptr member into a shared pointer member and then making a local copy of the shared pointer in each method that uses it to make sure another thread can't nuke the connection object while it is being used by another thread. Added a new file to the lldb/test/load_unload test that causes the test a.out file to link to the libd.dylib file all the time. This will allow us to test using the DYLD_LIBRARY_PATH environment variable after moving libd.dylib somewhere else. llvm-svn: 121745
This commit is contained in:
@@ -478,6 +478,159 @@ StackFrame::GetVariableList (bool get_file_globals)
|
||||
return m_variable_list_sp.get();
|
||||
}
|
||||
|
||||
ValueObjectSP
|
||||
StackFrame::GetValueForVariableExpressionPath (const char *var_expr)
|
||||
{
|
||||
bool deref = false;
|
||||
bool address_of = false;
|
||||
ValueObjectSP valobj_sp;
|
||||
const bool get_file_globals = true;
|
||||
VariableList *variable_list = GetVariableList (get_file_globals);
|
||||
|
||||
if (variable_list)
|
||||
{
|
||||
// If first character is a '*', then show pointer contents
|
||||
if (var_expr[0] == '*')
|
||||
{
|
||||
deref = true;
|
||||
var_expr++; // Skip the '*'
|
||||
}
|
||||
else if (var_expr[0] == '&')
|
||||
{
|
||||
address_of = true;
|
||||
var_expr++; // Skip the '&'
|
||||
}
|
||||
|
||||
std::string var_path (var_expr);
|
||||
size_t separator_idx = var_path.find_first_of(".-[");
|
||||
|
||||
ConstString name_const_string;
|
||||
if (separator_idx == std::string::npos)
|
||||
name_const_string.SetCString (var_path.c_str());
|
||||
else
|
||||
name_const_string.SetCStringWithLength (var_path.c_str(), separator_idx);
|
||||
|
||||
VariableSP var_sp (variable_list->FindVariable(name_const_string));
|
||||
if (var_sp)
|
||||
{
|
||||
valobj_sp = GetValueObjectForFrameVariable (var_sp);
|
||||
|
||||
var_path.erase (0, name_const_string.GetLength ());
|
||||
// We are dumping at least one child
|
||||
while (separator_idx != std::string::npos)
|
||||
{
|
||||
// Calculate the next separator index ahead of time
|
||||
ValueObjectSP child_valobj_sp;
|
||||
const char separator_type = var_path[0];
|
||||
switch (separator_type)
|
||||
{
|
||||
|
||||
case '-':
|
||||
if (var_path.size() >= 2 && var_path[1] != '>')
|
||||
return ValueObjectSP();
|
||||
|
||||
var_path.erase (0, 1); // Remove the '-'
|
||||
// Fall through
|
||||
case '.':
|
||||
{
|
||||
// We either have a pointer type and need to verify
|
||||
// valobj_sp is a pointer, or we have a member of a
|
||||
// class/union/struct being accessed with the . syntax
|
||||
// and need to verify we don't have a pointer.
|
||||
const bool is_ptr = var_path[0] == '>';
|
||||
|
||||
if (valobj_sp->IsPointerType () != is_ptr)
|
||||
{
|
||||
// Incorrect use of "." with a pointer, or "->" with
|
||||
// a class/union/struct instance or reference.
|
||||
return ValueObjectSP();
|
||||
}
|
||||
|
||||
var_path.erase (0, 1); // Remove the '.' or '>'
|
||||
separator_idx = var_path.find_first_of(".-[");
|
||||
ConstString child_name;
|
||||
if (separator_idx == std::string::npos)
|
||||
child_name.SetCString (var_path.c_str());
|
||||
else
|
||||
child_name.SetCStringWithLength(var_path.c_str(), separator_idx);
|
||||
|
||||
child_valobj_sp = valobj_sp->GetChildMemberWithName (child_name, true);
|
||||
if (!child_valobj_sp)
|
||||
{
|
||||
// No child member with name "child_name"
|
||||
return ValueObjectSP();
|
||||
}
|
||||
// Remove the child name from the path
|
||||
var_path.erase(0, child_name.GetLength());
|
||||
}
|
||||
break;
|
||||
|
||||
case '[':
|
||||
// Array member access, or treating pointer as an array
|
||||
if (var_path.size() > 2) // Need at least two brackets and a number
|
||||
{
|
||||
char *end = NULL;
|
||||
int32_t child_index = ::strtol (&var_path[1], &end, 0);
|
||||
if (end && *end == ']')
|
||||
{
|
||||
|
||||
if (valobj_sp->IsPointerType ())
|
||||
{
|
||||
child_valobj_sp = valobj_sp->GetSyntheticArrayMemberFromPointer (child_index, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
child_valobj_sp = valobj_sp->GetChildAtIndex (child_index, true);
|
||||
}
|
||||
|
||||
if (!child_valobj_sp)
|
||||
{
|
||||
// Invalid array index...
|
||||
return ValueObjectSP();
|
||||
}
|
||||
|
||||
// Erase the array member specification '[%i]' where
|
||||
// %i is the array index
|
||||
var_path.erase(0, (end - var_path.c_str()) + 1);
|
||||
separator_idx = var_path.find_first_of(".-[");
|
||||
|
||||
// Break out early from the switch since we were
|
||||
// able to find the child member
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ValueObjectSP();
|
||||
|
||||
default:
|
||||
// Failure...
|
||||
return ValueObjectSP();
|
||||
}
|
||||
|
||||
if (child_valobj_sp)
|
||||
valobj_sp = child_valobj_sp;
|
||||
|
||||
if (var_path.empty())
|
||||
break;
|
||||
|
||||
}
|
||||
if (valobj_sp)
|
||||
{
|
||||
if (deref)
|
||||
{
|
||||
ValueObjectSP deref_valobj_sp (valobj_sp->Dereference(this, NULL));
|
||||
valobj_sp = deref_valobj_sp;
|
||||
}
|
||||
else if (address_of)
|
||||
{
|
||||
ValueObjectSP address_of_valobj_sp (valobj_sp->AddressOf());
|
||||
valobj_sp = address_of_valobj_sp;
|
||||
}
|
||||
}
|
||||
return valobj_sp;
|
||||
}
|
||||
}
|
||||
return ValueObjectSP();
|
||||
}
|
||||
|
||||
bool
|
||||
StackFrame::GetFrameBaseValue (Scalar &frame_base, Error *error_ptr)
|
||||
|
||||
Reference in New Issue
Block a user