diff options
| author | Greg Clayton <gclayton@apple.com> | 2010-06-28 21:30:43 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2010-06-28 21:30:43 +0000 |
| commit | 0c5cd90d6310d537c862b550b5c9e7653bdbe749 (patch) | |
| tree | 4c849ae5a153e1c100d0fb828d7e71437012b5cb /lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp | |
| parent | e697a6f24f571c690bf196700f69a316b803563f (diff) | |
| download | bcm5719-llvm-0c5cd90d6310d537c862b550b5c9e7653bdbe749.tar.gz bcm5719-llvm-0c5cd90d6310d537c862b550b5c9e7653bdbe749.zip | |
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.
llvm-svn: 107075
Diffstat (limited to 'lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp')
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp | 70 |
1 files changed, 56 insertions, 14 deletions
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index e7f92c6eff2..54cbf42f0d6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/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 @@ DWARFCompileUnit::AddGlobal (const DWARFDebugInfoEntry* die) 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 @@ DWARFCompileUnit::Index 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 @@ DWARFCompileUnit::Index } } 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 @@ DWARFCompileUnit::Index case DW_TAG_subprogram: if (has_address) { - if (name && name[0]) + if (name) { if ((name[0] == '-' || name[0] == '+') && name[1] == '[') { @@ -716,24 +724,58 @@ DWARFCompileUnit::Index // 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()); + } + } + } + // 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; + } + } } } } - name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset()); + + 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; |

