summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Commands/CommandObjectFrame.cpp2
-rw-r--r--lldb/source/Core/Mangled.cpp14
-rw-r--r--lldb/source/Expression/ClangExpressionDeclMap.cpp81
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp8
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp53
-rw-r--r--lldb/source/Symbol/Variable.cpp40
-rw-r--r--lldb/source/Symbol/VariableList.cpp4
7 files changed, 134 insertions, 68 deletions
diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp
index 4821e7ec2b2..37cfbfa222d 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -727,7 +727,7 @@ public:
ValueObject::DumpValueObject (result.GetOutputStream(),
exe_ctx.frame,
valobj_sp.get(),
- name_cstr,
+ valobj_sp->GetParent() ? name_cstr : NULL,
ptr_depth,
0,
m_options.max_depth,
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index d69753d79fb..6a55ebc5604 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -13,6 +13,7 @@
#include "lldb/Core/ConstString.h"
#include "lldb/Core/Mangled.h"
+#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/Timer.h"
#include <ctype.h>
@@ -192,6 +193,19 @@ Mangled::GetDemangledName () const
return m_demangled;
}
+
+bool
+Mangled::NameMatches (const RegularExpression& regex) const
+{
+ if (m_mangled && regex.Execute (m_mangled.AsCString()))
+ return true;
+
+ if (GetDemangledName() && regex.Execute (m_demangled.AsCString()))
+ return true;
+ return false;
+}
+
+
//----------------------------------------------------------------------
// Mangled name get accessor
//----------------------------------------------------------------------
diff --git a/lldb/source/Expression/ClangExpressionDeclMap.cpp b/lldb/source/Expression/ClangExpressionDeclMap.cpp
index 0ddd9efaead..7e05940a85b 100644
--- a/lldb/source/Expression/ClangExpressionDeclMap.cpp
+++ b/lldb/source/Expression/ClangExpressionDeclMap.cpp
@@ -39,6 +39,7 @@
#include "lldb/Target/Target.h"
#include "llvm/Support/raw_ostream.h"
+using namespace lldb;
using namespace lldb_private;
using namespace clang;
@@ -364,8 +365,8 @@ ClangExpressionDeclMap::GetObjectPointer
return false;
}
- static ConstString g_this_cs ("this");
- Variable *object_ptr_var = FindVariableInScope(*exe_ctx->frame, g_this_cs, &m_object_pointer_type);
+ static ConstString g_this_const_str ("this");
+ Variable *object_ptr_var = FindVariableInScope (*exe_ctx->frame, g_this_const_str, &m_object_pointer_type);
if (!object_ptr_var)
{
@@ -681,7 +682,7 @@ ClangExpressionDeclMap::DoMaterializeOneVariable
if (!exe_ctx.frame || !exe_ctx.process)
return false;
- Variable *var = FindVariableInScope(*exe_ctx.frame, name, &type);
+ Variable *var = FindVariableInScope (*exe_ctx.frame, name, &type);
if (!var)
{
@@ -931,27 +932,50 @@ ClangExpressionDeclMap::FindVariableInScope
if (!var_list)
return NULL;
- lldb::VariableSP var = var_list->FindVariable(name);
-
- if (!var)
- return NULL;
-
- if (!type)
- return var.get();
-
- if (type->GetASTContext() == var->GetType()->GetClangAST())
+ lldb::VariableSP var_sp (var_list->FindVariable(name));
+
+ const bool append = true;
+ const uint32_t max_matches = 1;
+ if (!var_sp)
{
- if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetClangType()))
- return NULL;
+ // Look for globals elsewhere in the module for the frame
+ ModuleSP module_sp (m_exe_ctx.frame->GetSymbolContext(eSymbolContextModule).module_sp);
+ if (module_sp)
+ {
+ VariableList module_globals;
+ if (module_sp->FindGlobalVariables (name, append, max_matches, module_globals))
+ var_sp = module_globals.GetVariableAtIndex (0);
+ }
}
- else
+
+ if (!var_sp)
{
- if (log)
- log->PutCString("Skipping a candidate variable because of different AST contexts");
- return NULL;
+ // Look for globals elsewhere in the program (all images)
+ TargetSP target_sp (m_exe_ctx.frame->GetSymbolContext(eSymbolContextTarget).target_sp);
+ if (target_sp)
+ {
+ VariableList program_globals;
+ if (target_sp->GetImages().FindGlobalVariables (name, append, max_matches, program_globals))
+ var_sp = program_globals.GetVariableAtIndex (0);
+ }
}
-
- return var.get();
+
+ if (var_sp && type)
+ {
+ if (type->GetASTContext() == var_sp->GetType()->GetClangAST())
+ {
+ if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangType()))
+ return NULL;
+ }
+ else
+ {
+ if (log)
+ log->PutCString("Skipping a candidate variable because of different AST contexts");
+ return NULL;
+ }
+ }
+
+ return var_sp.get();
}
// Interface for ClangASTSource
@@ -969,9 +993,14 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
SymbolContextList sc_list;
+ const char *name_unique_cstr = name.GetCString();
+
+ if (name_unique_cstr == NULL)
+ return;
+
// Only look for functions by name out in our symbols if the function
// doesn't start with our phony prefix of '$'
- if (name.GetCString()[0] != '$')
+ if (name_unique_cstr[0] != '$')
{
Variable *var = FindVariableInScope(*m_exe_ctx.frame, name);
@@ -1084,13 +1113,11 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
// See information on gating of this operation next to the definition for
// m_lookedup_types.
-
- const char *name_uniq = name.GetCString();
-
- if (m_lookedup_types.find(name_uniq) == m_lookedup_types.end())
+
+ if (m_lookedup_types.find(name_unique_cstr) == m_lookedup_types.end())
{
// 1 The name is added to m_lookedup_types.
- m_lookedup_types.insert(std::pair<const char*, bool>(name_uniq, true));
+ m_lookedup_types.insert(std::pair<const char*, bool>(name_unique_cstr, true));
// 2 The type is looked up and added, potentially causing more type loookups.
lldb::TypeSP type = m_sym_ctx.FindTypeByName (name);
@@ -1104,7 +1131,7 @@ ClangExpressionDeclMap::GetDecls (NameSearchContext &context, const ConstString
}
// 3 The name is removed from m_lookedup_types.
- m_lookedup_types.erase(name_uniq);
+ m_lookedup_types.erase(name_unique_cstr);
}
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index 2784ca575a1..bd4e87d8ac7 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -883,6 +883,14 @@ DWARFCompileUnit::Index
if (name && has_location && is_global_or_static_variable)
{
globals.Insert (ConstString(name), die_info);
+ // Be sure to include variables by their mangled and demangled
+ // names if they have any since a variable can have a basename
+ // "i", a mangled named "_ZN12_GLOBAL__N_11iE" and a demangled
+ // mangled name "(anonymous namespace)::i"...
+ if (mangled.GetMangledName())
+ globals.Insert (mangled.GetMangledName(), die_info);
+ if (mangled.GetDemangledName())
+ globals.Insert (mangled.GetDemangledName(), die_info);
}
break;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 1337ba643ac..134421382d3 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -1776,16 +1776,16 @@ SymbolFileDWARF::Index ()
bool clear_dies = curr_cu->ExtractDIEsIfNeeded (false) > 1;
curr_cu->Index (cu_idx,
- m_function_basename_index,
- m_function_fullname_index,
- m_function_method_index,
- m_function_selector_index,
- m_objc_class_selectors_index,
- m_global_index,
- m_type_index,
- m_namespace_index,
- DebugRanges(),
- m_aranges.get());
+ m_function_basename_index,
+ m_function_fullname_index,
+ m_function_method_index,
+ m_function_selector_index,
+ m_objc_class_selectors_index,
+ m_global_index,
+ m_type_index,
+ m_namespace_index,
+ DebugRanges(),
+ m_aranges.get());
// Keep memory down by clearing DIEs if this generate function
// caused them to be parsed
@@ -3719,7 +3719,7 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, dwarf_cu->GetDIEAtIndexUnchecked(global_die_info_array[idx].die_idx), LLDB_INVALID_ADDRESS));
if (var_sp)
{
- variables->AddVariable(var_sp);
+ variables->AddVariableIfUnique (var_sp);
++vars_added;
}
}
@@ -3741,7 +3741,9 @@ SymbolFileDWARF::ParseVariableDIE
)
{
- VariableSP var_sp;
+ VariableSP var_sp (m_die_to_variable_sp[die]);
+ if (var_sp)
+ return var_sp; // Already been parsed!
const dw_tag_t tag = die->Tag();
DWARFDebugInfoEntry::Attributes attributes;
@@ -3821,18 +3823,6 @@ SymbolFileDWARF::ParseVariableDIE
{
assert(var_type != DIE_IS_BEING_PARSED);
- ConstString var_name;
- if (mangled)
- {
- Mangled mangled_var_name (mangled, true);
- var_name = mangled_var_name.GetDemangledName();
- }
-
- if (!var_name && name)
- {
- var_name.SetCString(name);
- }
-
ValueType scope = eValueTypeInvalid;
const DWARFDebugInfoEntry *sc_parent_die = GetParentSymbolContextDIE(die);
@@ -3859,7 +3849,8 @@ SymbolFileDWARF::ParseVariableDIE
assert(symbol_context_scope != NULL);
var_sp.reset (new Variable(die->GetOffset(),
- var_name,
+ name,
+ mangled,
var_type,
scope,
symbol_context_scope,
@@ -3868,9 +3859,13 @@ SymbolFileDWARF::ParseVariableDIE
is_external,
is_artificial));
- m_die_to_variable_sp[die] = var_sp;
}
}
+ // Cache var_sp even if NULL (the variable was just a specification or
+ // was missing vital information to be able to be displayed in the debugger
+ // (missing location due to optimization, etc)) so we don't re-parse
+ // this DIE over and over later...
+ m_die_to_variable_sp[die] = var_sp;
return var_sp;
}
@@ -3952,7 +3947,7 @@ SymbolFileDWARF::ParseVariables
if (m_die_to_variable_sp[die])
{
if (cc_variable_list)
- cc_variable_list->AddVariable (m_die_to_variable_sp[die]);
+ cc_variable_list->AddVariableIfUnique (m_die_to_variable_sp[die]);
}
else
{
@@ -3964,9 +3959,9 @@ SymbolFileDWARF::ParseVariables
VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, die, func_low_pc));
if (var_sp)
{
- variables->AddVariable(var_sp);
+ variables->AddVariableIfUnique (var_sp);
if (cc_variable_list)
- cc_variable_list->AddVariable (var_sp);
+ cc_variable_list->AddVariableIfUnique (var_sp);
++vars_added;
}
}
diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp
index 6511c01c8ab..f264e142fef 100644
--- a/lldb/source/Symbol/Variable.cpp
+++ b/lldb/source/Symbol/Variable.cpp
@@ -10,6 +10,7 @@
#include "lldb/Symbol/Variable.h"
#include "lldb/Core/Stream.h"
+#include "lldb/Core/RegularExpression.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/Function.h"
#include "lldb/Symbol/SymbolContext.h"
@@ -26,17 +27,22 @@ using namespace lldb_private;
//----------------------------------------------------------------------
// Variable constructor
//----------------------------------------------------------------------
-Variable::Variable(lldb::user_id_t uid,
- const ConstString& name,
- Type *type,
- ValueType scope,
- SymbolContextScope *context,
- Declaration* decl_ptr,
- const DWARFExpression& location,
- bool external,
- bool artificial) :
+Variable::Variable
+(
+ lldb::user_id_t uid,
+ const char *name,
+ const char *mangled, // The mangled variable name for variables in namespaces
+ Type *type,
+ ValueType scope,
+ SymbolContextScope *context,
+ Declaration* decl_ptr,
+ const DWARFExpression& location,
+ bool external,
+ bool artificial
+) :
UserID(uid),
m_name(name),
+ m_mangled (mangled, true),
m_type(type),
m_scope(scope),
m_owner_scope(context),
@@ -55,6 +61,22 @@ Variable::~Variable()
}
+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);
+}
+
void
Variable::Dump(Stream *s, bool show_context) const
{
diff --git a/lldb/source/Symbol/VariableList.cpp b/lldb/source/Symbol/VariableList.cpp
index 75106ffc6fb..7dd80a4c100 100644
--- a/lldb/source/Symbol/VariableList.cpp
+++ b/lldb/source/Symbol/VariableList.cpp
@@ -91,7 +91,7 @@ VariableList::FindVariable(const ConstString& name)
iterator pos, end = m_variables.end();
for (pos = m_variables.begin(); pos != end; ++pos)
{
- if ((*pos)->GetName() == name)
+ if ((*pos)->NameMatches(name))
{
var_sp = (*pos);
break;
@@ -107,7 +107,7 @@ VariableList::AppendVariablesIfUnique (const RegularExpression& regex, VariableL
iterator pos, end = m_variables.end();
for (pos = m_variables.begin(); pos != end; ++pos)
{
- if (regex.Execute ((*pos)->GetName().AsCString()))
+ if ((*pos)->NameMatches (regex))
{
// Note the total matches found
total_matches++;
OpenPOWER on IntegriCloud