Added function name types to allow us to set breakpoints by name more
intelligently. The four name types we currently have are:
eFunctionNameTypeFull = (1 << 1), // The function name.
// For C this is the same as just the name of the function
// For C++ this is the demangled version of the mangled name.
// For ObjC this is the full function signature with the + or
// - and the square brackets and the class and selector
eFunctionNameTypeBase = (1 << 2), // The function name only, no namespaces or arguments and no class
// methods or selectors will be searched.
eFunctionNameTypeMethod = (1 << 3), // Find function by method name (C++) with no namespace or arguments
eFunctionNameTypeSelector = (1 << 4) // Find function by selector name (ObjC) names
this allows much more flexibility when setting breakoints:
(lldb) breakpoint set --name main --basename
(lldb) breakpoint set --name main --fullname
(lldb) breakpoint set --name main --method
(lldb) breakpoint set --name main --selector
The default:
(lldb) breakpoint set --name main
will inspect the name "main" and look for any parens, or if the name starts
with "-[" or "+[" and if any are found then a full name search will happen.
Else a basename search will be the default.
Fixed some command option structures so not all options are required when they
shouldn't be.
Cleaned up the breakpoint output summary.
Made the "image lookup --address <addr>" output much more verbose so it shows
all the important symbol context results. Added a GetDescription method to
many of the SymbolContext objects for the more verbose output.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@107075 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index e7f92c6..54cbf42 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -14,6 +14,7 @@
#include "DWARFDebugAbbrev.h"
#include "DWARFDebugAranges.h"
+#include "DWARFDebugInfo.h"
#include "DWARFDIECollection.h"
#include "DWARFFormValue.h"
#include "LogChannelDWARF.h"
@@ -549,13 +550,14 @@
void
DWARFCompileUnit::Index
(
- lldb_private::UniqueCStringMap<dw_offset_t>& name_to_function_die,
- lldb_private::UniqueCStringMap<dw_offset_t>& name_to_inlined_die,
- lldb_private::UniqueCStringMap<dw_offset_t>& name_to_global_die,
- lldb_private::UniqueCStringMap<dw_offset_t>& name_to_type_die
+ lldb_private::UniqueCStringMap<dw_offset_t>& base_name_to_function_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& full_name_to_function_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& method_name_to_function_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& selector_name_to_function_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& name_to_type_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& name_to_global_die
)
{
-
const DataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data();
DWARFDebugInfoEntry::const_iterator pos;
@@ -597,6 +599,7 @@
bool has_address = false;
bool has_location = false;
bool is_global_or_static_variable = false;
+ dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
const size_t num_attributes = die.GetAttributes(m_dwarf2Data, this, attributes);
if (num_attributes > 0)
{
@@ -685,6 +688,11 @@
}
}
break;
+
+ case DW_AT_specification:
+ if (attributes.ExtractFormValueAtIndex(m_dwarf2Data, i, form_value))
+ specification_die_offset = form_value.Reference(this);
+ break;
}
}
}
@@ -694,7 +702,7 @@
case DW_TAG_subprogram:
if (has_address)
{
- if (name && name[0])
+ if (name)
{
if ((name[0] == '-' || name[0] == '+') && name[1] == '[')
{
@@ -716,24 +724,58 @@
// accelerator tables
size_t method_name_len = name_len - (method_name - name) - 1;
ConstString method_const_str (method_name, method_name_len);
- name_to_function_die.Append(method_const_str.AsCString(), die.GetOffset());
+ selector_name_to_function_die.Append(method_const_str.AsCString(), die.GetOffset());
}
}
}
- name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset());
+ // If we have a mangled name, then the DW_AT_name attribute
+ // is usually the method name without the class or any parameters
+ const DWARFDebugInfoEntry *parent = die.GetParent();
+ bool is_method = false;
+ if (parent)
+ {
+ dw_tag_t tag = parent->Tag();
+ if (tag == DW_TAG_class_type || tag == DW_TAG_structure_type)
+ {
+ is_method = true;
+ }
+ else
+ {
+ if (mangled && specification_die_offset != DW_INVALID_OFFSET)
+ {
+ const DWARFDebugInfoEntry *specification_die = m_dwarf2Data->DebugInfo()->GetDIEPtr (specification_die_offset, NULL);
+ if (specification_die)
+ {
+ parent = specification_die->GetParent();
+ if (parent)
+ {
+ tag = parent->Tag();
+
+ if (tag == DW_TAG_class_type || tag == DW_TAG_structure_type)
+ is_method = true;
+ }
+ }
+ }
+ }
+ }
+
+ if (is_method)
+ method_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset());
+ else
+ base_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset());
}
- if (mangled && mangled[0])
- name_to_function_die.Append(ConstString(mangled).AsCString(), die.GetOffset());
+ if (mangled)
+ full_name_to_function_die.Append(ConstString(mangled).AsCString(), die.GetOffset());
}
break;
case DW_TAG_inlined_subroutine:
if (has_address)
{
- if (name && name[0])
- name_to_inlined_die.Append(ConstString(name).AsCString(), die.GetOffset());
- if (mangled && mangled[0])
- name_to_inlined_die.Append(ConstString(mangled).AsCString(), die.GetOffset());
+ if (name)
+ base_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset());
+ if (mangled)
+ full_name_to_function_die.Append(ConstString(mangled).AsCString(), die.GetOffset());
}
break;
diff --git a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index 44bbbfe..d269537 100644
--- a/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -142,10 +142,13 @@
}
void
- Index (lldb_private::UniqueCStringMap<dw_offset_t>& name_to_function_die,
- lldb_private::UniqueCStringMap<dw_offset_t>& name_to_inlined_die,
- lldb_private::UniqueCStringMap<dw_offset_t>& name_to_global_die,
- lldb_private::UniqueCStringMap<dw_offset_t>& name_to_type_die);
+ Index (lldb_private::UniqueCStringMap<dw_offset_t>& base_name_to_function_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& full_name_to_function_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& method_name_to_function_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& selector_name_to_function_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& name_to_type_die,
+ lldb_private::UniqueCStringMap<dw_offset_t>& name_to_global_die);
+
protected:
SymbolFileDWARF* m_dwarf2Data;
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 27b0aa2..67e4dfc 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -229,8 +229,10 @@
m_aranges(),
m_info(),
m_line(),
- m_name_to_function_die(),
- m_name_to_inlined_die(),
+ m_base_name_to_function_die(),
+ m_full_name_to_function_die(),
+ m_method_name_to_function_die(),
+ m_selector_name_to_function_die(),
m_name_to_global_die(),
m_name_to_type_die(),
m_indexed(false),
@@ -1778,8 +1780,10 @@
bool clear_dies = cu->ExtractDIEsIfNeeded (false) > 1;
- cu->Index (m_name_to_function_die,
- m_name_to_inlined_die,
+ cu->Index (m_base_name_to_function_die,
+ m_full_name_to_function_die,
+ m_method_name_to_function_die,
+ m_selector_name_to_function_die,
m_name_to_global_die,
m_name_to_type_die);
@@ -1789,8 +1793,10 @@
cu->ClearDIEs (true);
}
- m_name_to_function_die.Sort();
- m_name_to_inlined_die.Sort();
+ m_base_name_to_function_die.Sort();
+ m_full_name_to_function_die.Sort();
+ m_method_name_to_function_die.Sort();
+ m_selector_name_to_function_die.Sort();
m_name_to_global_die.Sort();
m_name_to_type_die.Sort();
}
@@ -1893,33 +1899,20 @@
}
-uint32_t
-SymbolFileDWARF::FindFunctions(const ConstString &name, bool append, SymbolContextList& sc_list)
+void
+SymbolFileDWARF::FindFunctions
+(
+ const ConstString &name,
+ UniqueCStringMap<dw_offset_t> &name_to_die,
+ SymbolContextList& sc_list
+)
{
- Timer scoped_timer (__PRETTY_FUNCTION__,
- "SymbolFileDWARF::FindFunctions (name = '%s')",
- name.AsCString());
-
- std::vector<dw_offset_t> die_offsets;
-
- // If we aren't appending the results to this list, then clear the list
- if (!append)
- sc_list.Clear();
-
- // Remember how many sc_list are in the list before we search in case
- // we are appending the results to a variable list.
- uint32_t original_size = sc_list.GetSize();
-
- // Index the DWARF if we haven't already
- if (!m_indexed)
- Index ();
-
const UniqueCStringMap<dw_offset_t>::Entry *entry;
SymbolContext sc;
- for (entry = m_name_to_function_die.FindFirstValueForName (name.AsCString());
+ for (entry = name_to_die.FindFirstValueForName (name.AsCString());
entry != NULL;
- entry = m_name_to_function_die.FindNextValueForName (name.AsCString(), entry))
+ entry = name_to_die.FindNextValueForName (name.AsCString(), entry))
{
DWARFCompileUnitSP cu_sp;
const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr (entry->value, &cu_sp);
@@ -1943,6 +1936,47 @@
}
}
+}
+
+uint32_t
+SymbolFileDWARF::FindFunctions
+(
+ const ConstString &name,
+ uint32_t name_type_mask,
+ bool append,
+ SymbolContextList& sc_list
+)
+{
+ Timer scoped_timer (__PRETTY_FUNCTION__,
+ "SymbolFileDWARF::FindFunctions (name = '%s')",
+ name.AsCString());
+
+ std::vector<dw_offset_t> die_offsets;
+
+ // If we aren't appending the results to this list, then clear the list
+ if (!append)
+ sc_list.Clear();
+
+ // Remember how many sc_list are in the list before we search in case
+ // we are appending the results to a variable list.
+ uint32_t original_size = sc_list.GetSize();
+
+ // Index the DWARF if we haven't already
+ if (!m_indexed)
+ Index ();
+
+ if (name_type_mask & eFunctionNameTypeBase)
+ FindFunctions (name, m_base_name_to_function_die, sc_list);
+
+ if (name_type_mask & eFunctionNameTypeFull)
+ FindFunctions (name, m_full_name_to_function_die, sc_list);
+
+ if (name_type_mask & eFunctionNameTypeMethod)
+ FindFunctions (name, m_method_name_to_function_die, sc_list);
+
+ if (name_type_mask & eFunctionNameTypeSelector)
+ FindFunctions (name, m_selector_name_to_function_die, sc_list);
+
// Return the number of variable that were appended to the list
return sc_list.GetSize() - original_size;
}
@@ -1971,14 +2005,14 @@
// Create the pubnames information so we can quickly lookup external symbols by name
// Create the pubnames information so we can quickly lookup external symbols by name
- const size_t num_entries = m_name_to_function_die.GetSize();
+ const size_t num_entries = m_full_name_to_function_die.GetSize();
SymbolContext sc;
for (size_t i=0; i<num_entries; i++)
{
- if (!regex.Execute(m_name_to_function_die.GetCStringAtIndex (i)))
+ if (!regex.Execute(m_full_name_to_function_die.GetCStringAtIndex (i)))
continue;
- const dw_offset_t die_offset = *m_name_to_function_die.GetValueAtIndex (i);
+ const dw_offset_t die_offset = *m_full_name_to_function_die.GetValueAtIndex (i);
DWARFCompileUnitSP cu_sp;
const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr (die_offset, &cu_sp);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 95545a4..c2ad972 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -97,7 +97,7 @@
virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list);
virtual uint32_t FindGlobalVariables(const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
virtual uint32_t FindGlobalVariables(const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
- virtual uint32_t FindFunctions(const lldb_private::ConstString &name, bool append, lldb_private::SymbolContextList& sc_list);
+ virtual uint32_t FindFunctions(const lldb_private::ConstString &name, uint32_t name_type_mask, bool append, lldb_private::SymbolContextList& sc_list);
virtual uint32_t FindFunctions(const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list);
// virtual uint32_t FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb::Type::Encoding encoding, lldb::user_id_t udt_uid, lldb_private::TypeList& types);
// virtual uint32_t FindTypes(const lldb_private::SymbolContext& sc, const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb::Type::Encoding encoding, lldb::user_id_t udt_uid, lldb_private::TypeList& types);
@@ -277,6 +277,11 @@
uint32_t& byte_stride,
uint32_t& bit_stride);
+ void FindFunctions(
+ const lldb_private::ConstString &name,
+ lldb_private::UniqueCStringMap<dw_offset_t> &name_to_die,
+ lldb_private::SymbolContextList& sc_list);
+
lldb_private::Type* GetUniquedTypeForDIEOffset(dw_offset_t type_die_offset, lldb::TypeSP& owning_type_sp, int32_t child_type, uint32_t idx, bool safe);
lldb::TypeSP GetTypeForDIE(DWARFCompileUnit *cu, const DWARFDebugInfoEntry* die, lldb::TypeSP& owning_type_sp, int32_t child_type, uint32_t idx);
// uint32_t FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, Type::Encoding encoding, lldb::user_id_t udt_uid, TypeList& types);
@@ -303,8 +308,10 @@
std::auto_ptr<DWARFDebugAranges> m_aranges;
std::auto_ptr<DWARFDebugInfo> m_info;
std::auto_ptr<DWARFDebugLine> m_line;
- lldb_private::UniqueCStringMap<dw_offset_t> m_name_to_function_die; // All concrete functions
- lldb_private::UniqueCStringMap<dw_offset_t> m_name_to_inlined_die; // All inlined functions
+ lldb_private::UniqueCStringMap<dw_offset_t> m_base_name_to_function_die; // All concrete functions
+ lldb_private::UniqueCStringMap<dw_offset_t> m_full_name_to_function_die; // All concrete functions
+ lldb_private::UniqueCStringMap<dw_offset_t> m_method_name_to_function_die; // All inlined functions
+ lldb_private::UniqueCStringMap<dw_offset_t> m_selector_name_to_function_die; // All method names for functions of classes
lldb_private::UniqueCStringMap<dw_offset_t> m_name_to_global_die; // Global and static variables
lldb_private::UniqueCStringMap<dw_offset_t> m_name_to_type_die; // All type DIE offsets
bool m_indexed;
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 7bf968d..9da672f 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -763,7 +763,7 @@
}
uint32_t
-SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, bool append, SymbolContextList& sc_list)
+SymbolFileDWARFDebugMap::FindFunctions(const ConstString &name, uint32_t name_type_mask, bool append, SymbolContextList& sc_list)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"SymbolFileDWARFDebugMap::FindFunctions (name = %s)",
@@ -788,7 +788,7 @@
{
SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx);
if (oso_dwarf)
- oso_dwarf->FindFunctions(name, true, sc_list);
+ oso_dwarf->FindFunctions(name, name_type_mask, true, sc_list);
}
}
// Stream s(stdout);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 0a312ab..d5e2b51 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -64,7 +64,7 @@
virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list);
virtual uint32_t FindGlobalVariables (const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
virtual uint32_t FindGlobalVariables (const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
- virtual uint32_t FindFunctions (const lldb_private::ConstString &name, bool append, lldb_private::SymbolContextList& sc_list);
+ virtual uint32_t FindFunctions (const lldb_private::ConstString &name, uint32_t name_type_mask, bool append, lldb_private::SymbolContextList& sc_list);
virtual uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list);
// virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, Type::Encoding encoding, lldb::user_id_t udt_uid, TypeList& types);
// virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, Type::Encoding encoding, lldb::user_id_t udt_uid, TypeList& types);
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index d7da356..ff7b8bf 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -308,7 +308,7 @@
}
uint32_t
-SymbolFileSymtab::FindFunctions(const ConstString &name, bool append, SymbolContextList& sc_list)
+SymbolFileSymtab::FindFunctions(const ConstString &name, uint32_t name_type_mask, bool append, SymbolContextList& sc_list)
{
Timer scoped_timer (__PRETTY_FUNCTION__,
"SymbolFileSymtab::FindFunctions (name = '%s')",
diff --git a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index ac73f29..e3eeb29 100644
--- a/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -87,7 +87,7 @@
FindGlobalVariables(const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables);
virtual uint32_t
- FindFunctions(const lldb_private::ConstString &name, bool append, lldb_private::SymbolContextList& sc_list);
+ FindFunctions(const lldb_private::ConstString &name, uint32_t name_type_mask, bool append, lldb_private::SymbolContextList& sc_list);
virtual uint32_t
FindFunctions(const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list);