2010-06-09 00:52:24 +08:00
|
|
|
//===-- Variable.cpp --------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/Symbol/Variable.h"
|
|
|
|
|
|
|
|
#include "lldb/Core/Stream.h"
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
#include "lldb/Core/RegularExpression.h"
|
2011-07-09 05:46:14 +08:00
|
|
|
#include "lldb/Core/ValueObject.h"
|
|
|
|
#include "lldb/Core/ValueObjectVariable.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/Block.h"
|
|
|
|
#include "lldb/Symbol/Function.h"
|
|
|
|
#include "lldb/Symbol/SymbolContext.h"
|
|
|
|
#include "lldb/Symbol/Type.h"
|
2011-07-09 05:46:14 +08:00
|
|
|
#include "lldb/Symbol/VariableList.h"
|
2011-09-02 09:15:17 +08:00
|
|
|
#include "lldb/Target/ABI.h"
|
2010-09-15 07:36:40 +08:00
|
|
|
#include "lldb/Target/Process.h"
|
2010-08-25 05:05:24 +08:00
|
|
|
#include "lldb/Target/RegisterContext.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Target/StackFrame.h"
|
|
|
|
#include "lldb/Target/Thread.h"
|
2010-09-15 07:36:40 +08:00
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Variable constructor
|
|
|
|
//----------------------------------------------------------------------
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
Variable::Variable
|
|
|
|
(
|
|
|
|
lldb::user_id_t uid,
|
|
|
|
const char *name,
|
|
|
|
const char *mangled, // The mangled variable name for variables in namespaces
|
2011-12-08 10:13:16 +08:00
|
|
|
const lldb::SymbolFileTypeSP &symfile_type_sp,
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
ValueType scope,
|
|
|
|
SymbolContextScope *context,
|
|
|
|
Declaration* decl_ptr,
|
|
|
|
const DWARFExpression& location,
|
|
|
|
bool external,
|
|
|
|
bool artificial
|
|
|
|
) :
|
2010-06-09 00:52:24 +08:00
|
|
|
UserID(uid),
|
|
|
|
m_name(name),
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
m_mangled (mangled, true),
|
2011-12-08 10:13:16 +08:00
|
|
|
m_symfile_type_sp(symfile_type_sp),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_scope(scope),
|
2010-08-31 02:11:35 +08:00
|
|
|
m_owner_scope(context),
|
2010-06-09 00:52:24 +08:00
|
|
|
m_declaration(decl_ptr),
|
|
|
|
m_location(location),
|
|
|
|
m_external(external),
|
|
|
|
m_artificial(artificial)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// Destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
Variable::~Variable()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Just like functions can have a basename and a mangled/demangled name, variable
can too. So now the lldb_private::Variable class has support for this.
Variables now have support for having a basename ("i"), and a mangled name
("_ZN12_GLOBAL__N_11iE"), and a demangled name ("(anonymous namespace)::i").
Nowwhen searching for a variable by name, users might enter the fully qualified
name, or just the basename. So new test functions were added to the Variable
and Mangled classes as:
bool NameMatches (const ConstString &name);
bool NameMatches (const RegularExpression ®ex);
I also modified "ClangExpressionDeclMap::FindVariableInScope" to also search
for global variables that are not in the current file scope by first starting
with the current module, then moving on to all modules.
Fixed an issue in the DWARF parser that could cause a varaible to get parsed
more than once. Now, once we have parsed a VariableSP for a DIE, we cache
the result even if a variable wasn't made so we don't do any re-parsing. Some
DW_TAG_variable DIEs don't have locations, or are missing vital info that
stops a debugger from being able to display anything for it, we parse a NULL
variable shared pointer for these DIEs so we don't keep trying to reparse it.
llvm-svn: 119085
2010-11-15 06:13:40 +08:00
|
|
|
const ConstString&
|
|
|
|
Variable::GetName() const
|
|
|
|
{
|
|
|
|
if (m_mangled)
|
|
|
|
return m_mangled.GetName();
|
|
|
|
return m_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
Variable::NameMatches (const RegularExpression& regex) const
|
|
|
|
{
|
|
|
|
if (regex.Execute (m_name.AsCString()))
|
|
|
|
return true;
|
|
|
|
return m_mangled.NameMatches (regex);
|
|
|
|
}
|
|
|
|
|
2011-12-08 10:13:16 +08:00
|
|
|
Type *
|
|
|
|
Variable::GetType()
|
|
|
|
{
|
|
|
|
if (m_symfile_type_sp)
|
|
|
|
return m_symfile_type_sp->GetType();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
void
|
|
|
|
Variable::Dump(Stream *s, bool show_context) const
|
|
|
|
{
|
2011-09-21 05:44:10 +08:00
|
|
|
s->Printf("%p: ", this);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->Indent();
|
|
|
|
*s << "Variable" << (const UserID&)*this;
|
|
|
|
|
|
|
|
if (m_name)
|
|
|
|
*s << ", name = \"" << m_name << "\"";
|
|
|
|
|
2011-12-08 10:13:16 +08:00
|
|
|
if (m_symfile_type_sp)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-12-08 10:13:16 +08:00
|
|
|
Type *type = m_symfile_type_sp->GetType();
|
|
|
|
if (type)
|
|
|
|
{
|
|
|
|
*s << ", type = {" << type->GetID() << "} " << (void*)type << " (";
|
|
|
|
type->DumpTypeName(s);
|
|
|
|
s->PutChar(')');
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_scope != eValueTypeInvalid)
|
|
|
|
{
|
|
|
|
s->PutCString(", scope = ");
|
|
|
|
switch (m_scope)
|
|
|
|
{
|
|
|
|
case eValueTypeVariableGlobal: s->PutCString(m_external ? "global" : "static"); break;
|
|
|
|
case eValueTypeVariableArgument: s->PutCString("parameter"); break;
|
|
|
|
case eValueTypeVariableLocal: s->PutCString("local"); break;
|
|
|
|
default: *s << "??? (" << m_scope << ')';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-31 02:11:35 +08:00
|
|
|
if (show_context && m_owner_scope != NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
s->PutCString(", context = ( ");
|
2010-08-31 02:11:35 +08:00
|
|
|
m_owner_scope->DumpSymbolContext(s);
|
2010-06-09 00:52:24 +08:00
|
|
|
s->PutCString(" )");
|
|
|
|
}
|
|
|
|
|
2010-09-15 13:51:24 +08:00
|
|
|
bool show_fullpaths = false;
|
|
|
|
m_declaration.Dump(s, show_fullpaths);
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (m_location.IsValid())
|
|
|
|
{
|
|
|
|
s->PutCString(", location = ");
|
2010-09-14 10:20:48 +08:00
|
|
|
lldb::addr_t loclist_base_addr = LLDB_INVALID_ADDRESS;
|
|
|
|
if (m_location.IsLocationList())
|
|
|
|
{
|
|
|
|
SymbolContext variable_sc;
|
|
|
|
m_owner_scope->CalculateSymbolContext(&variable_sc);
|
|
|
|
if (variable_sc.function)
|
|
|
|
loclist_base_addr = variable_sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
|
|
|
|
}
|
2011-09-02 09:15:17 +08:00
|
|
|
ABI *abi = NULL;
|
|
|
|
if (m_owner_scope)
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleSP module_sp (m_owner_scope->CalculateSymbolContextModule());
|
|
|
|
if (module_sp)
|
|
|
|
abi = ABI::FindPlugin (module_sp->GetArchitecture()).get();
|
2011-09-02 09:15:17 +08:00
|
|
|
}
|
|
|
|
m_location.GetDescription(s, lldb::eDescriptionLevelBrief, loclist_base_addr, abi);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (m_external)
|
|
|
|
s->PutCString(", external");
|
|
|
|
|
|
|
|
if (m_artificial)
|
|
|
|
s->PutCString(", artificial");
|
|
|
|
|
|
|
|
s->EOL();
|
|
|
|
}
|
|
|
|
|
2011-07-11 03:21:23 +08:00
|
|
|
bool
|
|
|
|
Variable::DumpDeclaration (Stream *s, bool show_fullpaths, bool show_module)
|
|
|
|
{
|
|
|
|
bool dumped_declaration_info = false;
|
|
|
|
if (m_owner_scope)
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
m_owner_scope->CalculateSymbolContext(&sc);
|
|
|
|
sc.block = NULL;
|
|
|
|
sc.line_entry.Clear();
|
|
|
|
bool show_inlined_frames = false;
|
|
|
|
|
|
|
|
dumped_declaration_info = sc.DumpStopContext (s,
|
|
|
|
NULL,
|
|
|
|
Address(),
|
|
|
|
show_fullpaths,
|
|
|
|
show_module,
|
|
|
|
show_inlined_frames);
|
|
|
|
|
|
|
|
if (sc.function)
|
|
|
|
s->PutChar(':');
|
|
|
|
}
|
|
|
|
if (m_declaration.DumpStopContext (s, false))
|
|
|
|
dumped_declaration_info = true;
|
|
|
|
return dumped_declaration_info;
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
size_t
|
|
|
|
Variable::MemorySize() const
|
|
|
|
{
|
|
|
|
return sizeof(Variable);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Variable::CalculateSymbolContext (SymbolContext *sc)
|
|
|
|
{
|
2010-08-31 02:11:35 +08:00
|
|
|
if (m_owner_scope)
|
|
|
|
m_owner_scope->CalculateSymbolContext(sc);
|
2010-06-09 00:52:24 +08:00
|
|
|
else
|
|
|
|
sc->Clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2011-05-30 08:49:24 +08:00
|
|
|
Variable::LocationIsValidForFrame (StackFrame *frame)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
// Is the variable is described by a single location?
|
|
|
|
if (!m_location.IsLocationList())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2011-05-30 08:49:24 +08:00
|
|
|
// Yes it is, the location is valid.
|
2010-06-09 00:52:24 +08:00
|
|
|
return true;
|
2011-05-30 08:49:24 +08:00
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
if (frame)
|
|
|
|
{
|
|
|
|
Function *function = frame->GetSymbolContext(eSymbolContextFunction).function;
|
|
|
|
if (function)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2012-02-18 13:35:26 +08:00
|
|
|
TargetSP target_sp (frame->CalculateTarget());
|
|
|
|
|
|
|
|
addr_t loclist_base_load_addr = function->GetAddressRange().GetBaseAddress().GetLoadAddress (target_sp.get());
|
2010-09-14 10:20:48 +08:00
|
|
|
if (loclist_base_load_addr == LLDB_INVALID_ADDRESS)
|
|
|
|
return false;
|
2010-06-09 00:52:24 +08:00
|
|
|
// It is a location list. We just need to tell if the location
|
|
|
|
// list contains the current address when converted to a load
|
|
|
|
// address
|
2011-05-30 08:49:24 +08:00
|
|
|
return m_location.LocationListContainsAddress (loclist_base_load_addr,
|
2012-02-18 13:35:26 +08:00
|
|
|
frame->GetFrameCodeAddress().GetLoadAddress (target_sp.get()));
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2011-05-30 08:49:24 +08:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-07-11 13:12:02 +08:00
|
|
|
bool
|
|
|
|
Variable::LocationIsValidForAddress (const Address &address)
|
|
|
|
{
|
|
|
|
// Be sure to resolve the address to section offset prior to
|
|
|
|
// calling this function.
|
|
|
|
if (address.IsSectionOffset())
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext(&sc);
|
2012-02-24 09:59:29 +08:00
|
|
|
if (sc.module_sp == address.GetModule())
|
2011-07-11 13:12:02 +08:00
|
|
|
{
|
|
|
|
// Is the variable is described by a single location?
|
|
|
|
if (!m_location.IsLocationList())
|
|
|
|
{
|
|
|
|
// Yes it is, the location is valid.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sc.function)
|
|
|
|
{
|
|
|
|
addr_t loclist_base_file_addr = sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
|
|
|
|
if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
|
|
|
|
return false;
|
|
|
|
// It is a location list. We just need to tell if the location
|
|
|
|
// list contains the current address when converted to a load
|
|
|
|
// address
|
|
|
|
return m_location.LocationListContainsAddress (loclist_base_file_addr,
|
|
|
|
address.GetFileAddress());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
bool
|
|
|
|
Variable::IsInScope (StackFrame *frame)
|
|
|
|
{
|
|
|
|
switch (m_scope)
|
|
|
|
{
|
|
|
|
case eValueTypeRegister:
|
|
|
|
case eValueTypeRegisterSet:
|
|
|
|
return frame != NULL;
|
|
|
|
|
|
|
|
case eValueTypeConstResult:
|
|
|
|
case eValueTypeVariableGlobal:
|
|
|
|
case eValueTypeVariableStatic:
|
2011-07-10 04:12:33 +08:00
|
|
|
return true;
|
|
|
|
|
2011-05-30 08:49:24 +08:00
|
|
|
case eValueTypeVariableArgument:
|
|
|
|
case eValueTypeVariableLocal:
|
|
|
|
if (frame)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
// We don't have a location list, we just need to see if the block
|
|
|
|
// that this variable was defined in is currently
|
2010-09-14 11:16:58 +08:00
|
|
|
Block *deepest_frame_block = frame->GetSymbolContext(eSymbolContextBlock).block;
|
|
|
|
if (deepest_frame_block)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
SymbolContext variable_sc;
|
|
|
|
CalculateSymbolContext (&variable_sc);
|
2011-05-30 08:49:24 +08:00
|
|
|
// Check for static or global variable defined at the compile unit
|
|
|
|
// level that wasn't defined in a block
|
|
|
|
if (variable_sc.block == NULL)
|
|
|
|
return true;
|
|
|
|
|
2010-09-14 11:16:58 +08:00
|
|
|
if (variable_sc.block == deepest_frame_block)
|
2010-09-14 10:20:48 +08:00
|
|
|
return true;
|
2010-09-14 11:16:58 +08:00
|
|
|
return variable_sc.block->Contains (deepest_frame_block);
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-07-09 05:46:14 +08:00
|
|
|
Error
|
|
|
|
Variable::GetValuesForVariableExpressionPath (const char *variable_expr_path,
|
|
|
|
ExecutionContextScope *scope,
|
|
|
|
GetVariableCallback callback,
|
|
|
|
void *baton,
|
|
|
|
VariableList &variable_list,
|
|
|
|
ValueObjectList &valobj_list)
|
|
|
|
{
|
|
|
|
Error error;
|
|
|
|
if (variable_expr_path && callback)
|
|
|
|
{
|
|
|
|
switch (variable_expr_path[0])
|
|
|
|
{
|
|
|
|
case '*':
|
|
|
|
{
|
|
|
|
error = Variable::GetValuesForVariableExpressionPath (variable_expr_path + 1,
|
|
|
|
scope,
|
|
|
|
callback,
|
|
|
|
baton,
|
|
|
|
variable_list,
|
|
|
|
valobj_list);
|
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
for (uint32_t i=0; i<valobj_list.GetSize(); )
|
|
|
|
{
|
|
|
|
Error tmp_error;
|
|
|
|
ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(i)->Dereference(tmp_error));
|
|
|
|
if (tmp_error.Fail())
|
|
|
|
{
|
|
|
|
variable_list.RemoveVariableAtIndex (i);
|
|
|
|
valobj_list.RemoveValueObjectAtIndex (i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
valobj_list.SetValueObjectAtIndex (i, valobj_sp);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unknown error");
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '&':
|
|
|
|
{
|
|
|
|
error = Variable::GetValuesForVariableExpressionPath (variable_expr_path + 1,
|
|
|
|
scope,
|
|
|
|
callback,
|
|
|
|
baton,
|
|
|
|
variable_list,
|
|
|
|
valobj_list);
|
|
|
|
if (error.Success())
|
|
|
|
{
|
|
|
|
for (uint32_t i=0; i<valobj_list.GetSize(); )
|
|
|
|
{
|
|
|
|
Error tmp_error;
|
|
|
|
ValueObjectSP valobj_sp (valobj_list.GetValueObjectAtIndex(i)->AddressOf(tmp_error));
|
|
|
|
if (tmp_error.Fail())
|
|
|
|
{
|
|
|
|
variable_list.RemoveVariableAtIndex (i);
|
|
|
|
valobj_list.RemoveValueObjectAtIndex (i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
valobj_list.SetValueObjectAtIndex (i, valobj_sp);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
error.SetErrorString ("unknown error");
|
|
|
|
}
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
RegularExpression regex ("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)");
|
|
|
|
if (regex.Execute(variable_expr_path, 1))
|
|
|
|
{
|
|
|
|
std::string variable_name;
|
|
|
|
if (regex.GetMatchAtIndex(variable_expr_path, 1, variable_name))
|
|
|
|
{
|
|
|
|
variable_list.Clear();
|
|
|
|
if (callback (baton, variable_name.c_str(), variable_list))
|
|
|
|
{
|
|
|
|
uint32_t i=0;
|
|
|
|
while (i < variable_list.GetSize())
|
|
|
|
{
|
|
|
|
VariableSP var_sp (variable_list.GetVariableAtIndex (i));
|
|
|
|
ValueObjectSP valobj_sp;
|
|
|
|
if (var_sp)
|
|
|
|
{
|
|
|
|
ValueObjectSP variable_valobj_sp(ValueObjectVariable::Create (scope, var_sp));
|
|
|
|
if (variable_valobj_sp)
|
|
|
|
{
|
|
|
|
variable_expr_path += variable_name.size();
|
|
|
|
if (*variable_expr_path)
|
|
|
|
{
|
|
|
|
const char* first_unparsed = NULL;
|
|
|
|
ValueObject::ExpressionPathScanEndReason reason_to_stop;
|
|
|
|
ValueObject::ExpressionPathEndResultType final_value_type;
|
|
|
|
ValueObject::GetValueForExpressionPathOptions options;
|
|
|
|
ValueObject::ExpressionPathAftermath final_task_on_target;
|
|
|
|
|
|
|
|
valobj_sp = variable_valobj_sp->GetValueForExpressionPath (variable_expr_path,
|
|
|
|
&first_unparsed,
|
|
|
|
&reason_to_stop,
|
|
|
|
&final_value_type,
|
|
|
|
options,
|
|
|
|
&final_task_on_target);
|
|
|
|
if (!valobj_sp)
|
|
|
|
{
|
|
|
|
error.SetErrorStringWithFormat ("invalid expression path '%s' for variable '%s'",
|
|
|
|
variable_expr_path,
|
|
|
|
var_sp->GetName().GetCString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Just the name of a variable with no extras
|
|
|
|
valobj_sp = variable_valobj_sp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!var_sp || !valobj_sp)
|
|
|
|
{
|
|
|
|
variable_list.RemoveVariableAtIndex (i);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
valobj_list.Append(valobj_sp);
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (variable_list.GetSize() > 0)
|
|
|
|
{
|
|
|
|
error.Clear();
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
error.SetErrorStringWithFormat ("unable to extracta variable name from '%s'", variable_expr_path);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
error.SetErrorString ("unknown error");
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
2011-07-11 13:12:02 +08:00
|
|
|
bool
|
|
|
|
Variable::DumpLocationForAddress (Stream *s, const Address &address)
|
|
|
|
{
|
|
|
|
// Be sure to resolve the address to section offset prior to
|
|
|
|
// calling this function.
|
|
|
|
if (address.IsSectionOffset())
|
|
|
|
{
|
|
|
|
SymbolContext sc;
|
|
|
|
CalculateSymbolContext(&sc);
|
2012-02-24 09:59:29 +08:00
|
|
|
if (sc.module_sp == address.GetModule())
|
2011-07-11 13:12:02 +08:00
|
|
|
{
|
2011-09-02 09:15:17 +08:00
|
|
|
ABI *abi = NULL;
|
|
|
|
if (m_owner_scope)
|
|
|
|
{
|
2012-02-24 09:59:29 +08:00
|
|
|
ModuleSP module_sp (m_owner_scope->CalculateSymbolContextModule());
|
|
|
|
if (module_sp)
|
|
|
|
abi = ABI::FindPlugin (module_sp->GetArchitecture()).get();
|
2011-09-02 09:15:17 +08:00
|
|
|
}
|
|
|
|
|
2011-07-11 13:12:02 +08:00
|
|
|
const addr_t file_addr = address.GetFileAddress();
|
|
|
|
if (sc.function)
|
|
|
|
{
|
|
|
|
if (sc.function->GetAddressRange().ContainsFileAddress(address))
|
|
|
|
{
|
|
|
|
addr_t loclist_base_file_addr = sc.function->GetAddressRange().GetBaseAddress().GetFileAddress();
|
|
|
|
if (loclist_base_file_addr == LLDB_INVALID_ADDRESS)
|
|
|
|
return false;
|
|
|
|
return m_location.DumpLocationForAddress (s,
|
|
|
|
eDescriptionLevelBrief,
|
|
|
|
loclist_base_file_addr,
|
2011-09-02 09:15:17 +08:00
|
|
|
file_addr,
|
|
|
|
abi);
|
2011-07-11 13:12:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return m_location.DumpLocationForAddress (s,
|
|
|
|
eDescriptionLevelBrief,
|
|
|
|
LLDB_INVALID_ADDRESS,
|
2011-09-02 09:15:17 +08:00
|
|
|
file_addr,
|
|
|
|
abi);
|
2011-07-11 13:12:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|