summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2010-09-15 04:15:46 +0000
committerGreg Clayton <gclayton@apple.com>2010-09-15 04:15:46 +0000
commitc685f8e5402284f4a743f2e4d7d7168578cfb687 (patch)
tree08cafa1431519ca5789105907e1e15669f86e81d
parent81ce17386075dcdbae3891837ce0316ad9bcbd19 (diff)
downloadbcm5719-llvm-c685f8e5402284f4a743f2e4d7d7168578cfb687.tar.gz
bcm5719-llvm-c685f8e5402284f4a743f2e4d7d7168578cfb687.zip
So we can't use .debug_pubtypes as it, as designed, does not tell us about
all types in all compile units. I added a new kind of accelerator table to the DWARF that allows us to index the DWARF compile units and DIEs in a way that doesn't require the data to stay loaded. Currently when indexing the DWARF we check if the compile unit had parsed its DIEs and if it hasn't we index the data and free all of the DIEs so we can reparse later when we need to after using one of our complete accelerator tables to determine we need to reparse some DWARF. If the DIEs had already been parsed we leave them loaded. The new accelerator table uses the "const char *" pointers from our ConstString class as the keys, and NameToDIE::Info as the value. This info contains the compile unit index and the DIE index which means we are pointed right to the DIE we need unlike the other DWARF accelerator tables that often just point us to the compile unit we would find our answer in. llvm-svn: 113933
-rw-r--r--lldb/lldb.xcodeproj/project.pbxproj8
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp84
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h53
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp32
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp60
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h63
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp627
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h56
10 files changed, 439 insertions, 548 deletions
diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj
index 72ca1aa0782..2331f84bc99 100644
--- a/lldb/lldb.xcodeproj/project.pbxproj
+++ b/lldb/lldb.xcodeproj/project.pbxproj
@@ -16,6 +16,8 @@
2617447A11685869005ADD65 /* SBType.h in Headers */ = {isa = PBXBuildFile; fileRef = 2617447911685869005ADD65 /* SBType.h */; settings = {ATTRIBUTES = (Public, ); }; };
2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618D78F1240115500F2B8FE /* SectionLoadList.h */; };
2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618D7911240116900F2B8FE /* SectionLoadList.cpp */; };
+ 2618D959124056C700F2B8FE /* NameToDIE.h in Headers */ = {isa = PBXBuildFile; fileRef = 2618D957124056C700F2B8FE /* NameToDIE.h */; };
+ 2618D9EB12406FE600F2B8FE /* NameToDIE.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */; };
261B5A5411C3F2AD00AABD0A /* SharingPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */; };
261B5A5511C3F2AD00AABD0A /* SharingPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 261B5A5311C3F2AD00AABD0A /* SharingPtr.h */; settings = {ATTRIBUTES = (Public, ); }; };
262CFC7711A4510000946C6C /* debugserver in Resources */ = {isa = PBXBuildFile; fileRef = 26CE05A0115C31E50022F371 /* debugserver */; };
@@ -534,6 +536,8 @@
2617447911685869005ADD65 /* SBType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBType.h; path = include/lldb/API/SBType.h; sourceTree = "<group>"; };
2618D78F1240115500F2B8FE /* SectionLoadList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SectionLoadList.h; path = include/lldb/Target/SectionLoadList.h; sourceTree = "<group>"; };
2618D7911240116900F2B8FE /* SectionLoadList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SectionLoadList.cpp; path = source/Target/SectionLoadList.cpp; sourceTree = "<group>"; };
+ 2618D957124056C700F2B8FE /* NameToDIE.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NameToDIE.h; sourceTree = "<group>"; };
+ 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NameToDIE.cpp; sourceTree = "<group>"; };
261B5A5211C3F2AD00AABD0A /* SharingPtr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SharingPtr.cpp; path = source/Utility/SharingPtr.cpp; sourceTree = "<group>"; };
261B5A5311C3F2AD00AABD0A /* SharingPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SharingPtr.h; path = include/lldb/Utility/SharingPtr.h; sourceTree = "<group>"; };
261E18CC1148966100BADCD3 /* GDBRemoteRegisterContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GDBRemoteRegisterContext.h; path = "source/Plugins/Process/gdb-remote/GDBRemoteRegisterContext.h"; sourceTree = "<group>"; };
@@ -1384,6 +1388,8 @@
260C89D610F57C5600BB2B04 /* DWARFLocationDescription.h */,
260C89D710F57C5600BB2B04 /* DWARFLocationList.cpp */,
260C89D810F57C5600BB2B04 /* DWARFLocationList.h */,
+ 2618D9EA12406FE600F2B8FE /* NameToDIE.cpp */,
+ 2618D957124056C700F2B8FE /* NameToDIE.h */,
260C89D910F57C5600BB2B04 /* SymbolFileDWARF.cpp */,
260C89DA10F57C5600BB2B04 /* SymbolFileDWARF.h */,
26109B3B1155D70100CC3529 /* LogChannelDWARF.cpp */,
@@ -2278,6 +2284,7 @@
961FAC1F12360C7D00F93A47 /* ArchDefaultUnwindPlan-x86.h in Headers */,
268F9D53123AA15200B91E9B /* SBSymbolContextList.h in Headers */,
2618D7901240115500F2B8FE /* SectionLoadList.h in Headers */,
+ 2618D959124056C700F2B8FE /* NameToDIE.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2742,6 +2749,7 @@
69A01E261236C5D400C660B5 /* TimeValue.cpp in Sources */,
268F9D55123AA16600B91E9B /* SBSymbolContextList.cpp in Sources */,
2618D7921240116900F2B8FE /* SectionLoadList.cpp in Sources */,
+ 2618D9EB12406FE600F2B8FE /* NameToDIE.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
index d75b5fc4cf4..0a03684bbaa 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
@@ -19,6 +19,7 @@
#include "DWARFDIECollection.h"
#include "DWARFFormValue.h"
#include "LogChannelDWARF.h"
+#include "NameToDIE.h"
#include "SymbolFileDWARF.h"
using namespace lldb_private;
@@ -524,44 +525,46 @@ DWARFCompileUnit::AppendDIEsWithTag (const dw_tag_t tag, DWARFDIECollection& die
return dies.Size() - old_size;
}
-void
-DWARFCompileUnit::AddGlobalDIEByIndex (uint32_t die_idx)
-{
- m_global_die_indexes.push_back (die_idx);
-}
-
-
-void
-DWARFCompileUnit::AddGlobal (const DWARFDebugInfoEntry* die)
-{
- // Indexes to all file level global and static variables
- m_global_die_indexes;
-
- if (m_die_array.empty())
- return;
-
- const DWARFDebugInfoEntry* first_die = &m_die_array[0];
- const DWARFDebugInfoEntry* end = first_die + m_die_array.size();
- if (first_die <= die && die < end)
- m_global_die_indexes.push_back (die - first_die);
-}
+//void
+//DWARFCompileUnit::AddGlobalDIEByIndex (uint32_t die_idx)
+//{
+// m_global_die_indexes.push_back (die_idx);
+//}
+//
+//
+//void
+//DWARFCompileUnit::AddGlobal (const DWARFDebugInfoEntry* die)
+//{
+// // Indexes to all file level global and static variables
+// m_global_die_indexes;
+//
+// if (m_die_array.empty())
+// return;
+//
+// const DWARFDebugInfoEntry* first_die = &m_die_array[0];
+// const DWARFDebugInfoEntry* end = first_die + m_die_array.size();
+// if (first_die <= die && die < end)
+// m_global_die_indexes.push_back (die - first_die);
+//}
void
DWARFCompileUnit::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,
+ const uint32_t cu_idx,
+ NameToDIE& base_name_to_function_die,
+ NameToDIE& full_name_to_function_die,
+ NameToDIE& method_name_to_function_die,
+ NameToDIE& selector_name_to_function_die,
+ NameToDIE& name_to_global_die,
+ NameToDIE& name_to_type_die,
const DWARFDebugRanges *debug_ranges,
DWARFDebugAranges *aranges
)
{
const DataExtractor* debug_str = &m_dwarf2Data->get_debug_str_data();
+ NameToDIE::Info die_info = { cu_idx, 0 };
DWARFDebugInfoEntry::const_iterator pos;
DWARFDebugInfoEntry::const_iterator begin = m_die_array.begin();
DWARFDebugInfoEntry::const_iterator end = m_die_array.end();
@@ -746,6 +749,8 @@ DWARFCompileUnit::Index
}
}
+ die_info.die_idx = std::distance (begin, pos);
+
switch (tag)
{
case DW_TAG_subprogram:
@@ -771,9 +776,8 @@ DWARFCompileUnit::Index
++method_name;
// Extract the objective C basename and add it to the
// accelerator tables
- size_t method_name_len = name_len - (method_name - name) - 1;
- ConstString method_const_str (method_name, method_name_len);
- selector_name_to_function_die.Append(method_const_str.AsCString(), die.GetOffset());
+ size_t method_name_len = name_len - (method_name - name) - 1;
+ selector_name_to_function_die.Insert (ConstString (method_name, method_name_len), die_info);
}
}
}
@@ -808,15 +812,16 @@ DWARFCompileUnit::Index
}
}
+
if (is_method)
- method_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset());
+ method_name_to_function_die.Insert (ConstString(name), die_info);
else
- base_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset());
+ base_name_to_function_die.Insert (ConstString(name), die_info);
}
if (mangled.GetMangledName())
- full_name_to_function_die.Append(mangled.GetMangledName().AsCString(), die.GetOffset());
+ full_name_to_function_die.Insert (mangled.GetMangledName(), die_info);
if (mangled.GetDemangledName())
- full_name_to_function_die.Append(mangled.GetDemangledName().AsCString(), die.GetOffset());
+ full_name_to_function_die.Insert (mangled.GetDemangledName(), die_info);
}
break;
@@ -824,11 +829,11 @@ DWARFCompileUnit::Index
if (has_address)
{
if (name)
- base_name_to_function_die.Append(ConstString(name).AsCString(), die.GetOffset());
+ base_name_to_function_die.Insert (ConstString(name), die_info);
if (mangled.GetMangledName())
- full_name_to_function_die.Append(mangled.GetMangledName().AsCString(), die.GetOffset());
+ full_name_to_function_die.Insert (mangled.GetMangledName(), die_info);
if (mangled.GetDemangledName())
- full_name_to_function_die.Append(mangled.GetDemangledName().AsCString(), die.GetOffset());
+ full_name_to_function_die.Insert (mangled.GetDemangledName(), die_info);
}
break;
@@ -844,15 +849,14 @@ DWARFCompileUnit::Index
case DW_TAG_namespace:
if (name && is_declaration == false)
{
- name_to_type_die.Append(ConstString(name).AsCString(), die.GetOffset());
+ name_to_type_die.Insert (ConstString(name), die_info);
}
break;
case DW_TAG_variable:
if (name && has_location && is_global_or_static_variable)
{
- AddGlobalDIEByIndex (std::distance (begin, pos));
- name_to_global_die.Append(ConstString(name).AsCString(), die.GetOffset());
+ name_to_global_die.Insert (ConstString(name), die_info);
}
break;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
index 0e097dd5c86..fc467a11e46 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h
@@ -13,6 +13,8 @@
#include "SymbolFileDWARF.h"
#include "DWARFDebugInfoEntry.h"
+class NameToDIE;
+
class DWARFCompileUnit
{
public:
@@ -91,6 +93,12 @@ public:
}
DWARFDebugInfoEntry*
+ GetDIEAtIndexUnchecked (uint32_t idx)
+ {
+ return &m_die_array[idx];
+ }
+
+ DWARFDebugInfoEntry*
GetDIEPtr (dw_offset_t die_offset);
const DWARFDebugInfoEntry*
@@ -101,6 +109,7 @@ public:
static uint8_t
GetDefaultAddressSize();
+
static void
SetDefaultAddressSize(uint8_t addr_size);
@@ -117,37 +126,20 @@ public:
}
+// void
+// AddGlobalDIEByIndex (uint32_t die_idx);
+//
+// void
+// AddGlobal (const DWARFDebugInfoEntry* die);
+//
void
- AddGlobalDIEByIndex (uint32_t die_idx);
-
- void
- AddGlobal (const DWARFDebugInfoEntry* die);
-
- size_t
- GetNumGlobals () const
- {
- return m_global_die_indexes.size();
- }
-
- const DWARFDebugInfoEntry *
- GetGlobalDIEAtIndex (uint32_t idx)
- {
- if (idx < m_global_die_indexes.size())
- {
- uint32_t die_idx = m_global_die_indexes[idx];
- if (die_idx < m_die_array.size())
- return &m_die_array[die_idx];
- }
- return NULL;
- }
-
- void
- 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,
+ Index (const uint32_t cu_idx,
+ NameToDIE& base_name_to_function_die,
+ NameToDIE& full_name_to_function_die,
+ NameToDIE& method_name_to_function_die,
+ NameToDIE& selector_name_to_function_die,
+ NameToDIE& name_to_global_die,
+ NameToDIE& name_to_type_die,
const DWARFDebugRanges* debug_ranges,
DWARFDebugAranges *aranges);
@@ -164,7 +156,6 @@ protected:
DWARFDebugInfoEntry::collection
m_die_array; // The compile unit debug information entry item
std::auto_ptr<DWARFDebugAranges> m_aranges_ap; // A table similar to the .debug_aranges table, but this one points to the exact DW_TAG_subprogram DIEs
- std::vector<uint32_t> m_global_die_indexes; // Indexes to all file level global and static variables
void * m_user_data;
private:
DISALLOW_COPY_AND_ASSIGN (DWARFCompileUnit);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
index 1c8ef58c3c5..13178af6e43 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp
@@ -167,22 +167,22 @@ DWARFDebugAranges::Range::Dump(Stream *s) const
//----------------------------------------------------------------------
// Dump
//----------------------------------------------------------------------
-void
-DWARFDebugAranges::Dump(SymbolFileDWARF* dwarf2Data, Stream *s)
-{
- const DataExtractor &debug_aranges_data = dwarf2Data->get_debug_aranges_data();
- if (debug_aranges_data.ValidOffset(0))
- {
- uint32_t offset = 0;
-
- DWARFDebugArangeSet set;
- while (set.Extract(debug_aranges_data, &offset))
- set.Dump(s);
- }
- else
- s->PutCString("< EMPTY >\n");
-}
-
+//void
+//DWARFDebugAranges::Dump(SymbolFileDWARF* dwarf2Data, Stream *s)
+//{
+// const DataExtractor &debug_aranges_data = dwarf2Data->get_debug_aranges_data();
+// if (debug_aranges_data.ValidOffset(0))
+// {
+// uint32_t offset = 0;
+//
+// DWARFDebugArangeSet set;
+// while (set.Extract(debug_aranges_data, &offset))
+// set.Dump(s);
+// }
+// else
+// s->PutCString("< EMPTY >\n");
+//}
+//
//----------------------------------------------------------------------
// AppendDebugRanges
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
index 0861376fc66..dd8ec8b742a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
@@ -75,7 +75,7 @@ public:
void Print() const;
dw_offset_t FindAddress(dw_addr_t address) const;
bool IsEmpty() const { return m_aranges.empty(); }
- void Dump(lldb_private::Stream *s);
+// void Dump(lldb_private::Stream *s);
uint32_t NumRanges() const
{
return m_aranges.size();
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
index 93ecaed72c6..27460d4082f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugPubnames.cpp
@@ -187,8 +187,6 @@ DWARFDebugPubnames::GeneratePubnames(SymbolFileDWARF* dwarf2Data)
if (add_die && (name || mangled))
{
- if (is_variable)
- cu->AddGlobal(die);
pubnames_set.AddDescriptor(die->GetOffset() - cu_offset, mangled ? mangled : name);
}
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
new file mode 100644
index 00000000000..48acf30d583
--- /dev/null
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -0,0 +1,60 @@
+//===-- NameToDIE.cpp -------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "NameToDIE.h"
+#include "lldb/Core/Stream.h"
+
+size_t
+NameToDIE::Find (const lldb_private::ConstString &name, std::vector<Info> &info_array) const
+{
+ const char *name_cstr = name.AsCString();
+ const size_t initial_info_array_size = info_array.size();
+ collection::const_iterator pos, end = m_collection.end();
+ for (pos = m_collection.lower_bound (name_cstr); pos != end && pos->first == name_cstr; ++pos)
+ {
+ info_array.push_back (pos->second);
+ }
+ return info_array.size() - initial_info_array_size;
+}
+
+size_t
+NameToDIE::Find (const lldb_private::RegularExpression& regex, std::vector<Info> &info_array) const
+{
+ const size_t initial_info_array_size = info_array.size();
+ collection::const_iterator pos, end = m_collection.end();
+ for (pos = m_collection.begin(); pos != end; ++pos)
+ {
+ if (regex.Execute(pos->first))
+ info_array.push_back (pos->second);
+ }
+ return info_array.size() - initial_info_array_size;
+}
+
+size_t
+NameToDIE::FindAllEntriesForCompileUnitWithIndex (const uint32_t cu_idx, std::vector<Info> &info_array) const
+{
+ const size_t initial_info_array_size = info_array.size();
+ collection::const_iterator pos, end = m_collection.end();
+ for (pos = m_collection.begin(); pos != end; ++pos)
+ {
+ if (cu_idx == pos->second.cu_idx)
+ info_array.push_back (pos->second);
+ }
+ return info_array.size() - initial_info_array_size;
+}
+
+void
+NameToDIE::Dump (lldb_private::Stream *s)
+{
+ collection::const_iterator pos, end = m_collection.end();
+ for (pos = m_collection.begin(); pos != end; ++pos)
+ {
+ s->Printf("%p: 0x%8.8x 0x%8.8x \"%s\"\n", pos->first, pos->second.cu_idx, pos->second.die_idx, pos->first);
+ }
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
new file mode 100644
index 00000000000..ef1d27b8b2f
--- /dev/null
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -0,0 +1,63 @@
+//===-- NameToDIE.h ---------------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SymbolFileDWARF_NameToDIE_h_
+#define SymbolFileDWARF_NameToDIE_h_
+
+#include <map>
+#include "lldb/Core/ConstString.h"
+#include "lldb/Core/RegularExpression.h"
+
+class NameToDIE
+{
+public:
+ typedef struct Info
+ {
+ uint32_t cu_idx;
+ uint32_t die_idx;
+ } Info;
+
+
+ NameToDIE () :
+ m_collection ()
+ {
+ }
+
+ ~NameToDIE ()
+ {
+ }
+
+ void
+ Dump (lldb_private::Stream *s);
+
+ void
+ Insert (const lldb_private::ConstString& name, const Info &info)
+ {
+ m_collection.insert (std::make_pair(name.AsCString(), info));
+ }
+
+ size_t
+ Find (const lldb_private::ConstString &name,
+ std::vector<Info> &info_array) const;
+
+ size_t
+ Find (const lldb_private::RegularExpression& regex,
+ std::vector<Info> &info_array) const;
+
+ size_t
+ FindAllEntriesForCompileUnitWithIndex (const uint32_t cu_idx,
+ std::vector<Info> &info_array) const;
+
+protected:
+ typedef std::multimap<const char *, Info> collection;
+
+ collection m_collection;
+};
+
+#endif // SymbolFileDWARF_NameToDIE_h_
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 0dbd479c5ab..bcae13c3404 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -26,6 +26,7 @@
#include "lldb/Core/RegularExpression.h"
#include "lldb/Core/Scalar.h"
#include "lldb/Core/Section.h"
+#include "lldb/Core/StreamFile.h"
#include "lldb/Core/Timer.h"
#include "lldb/Core/Value.h"
@@ -135,33 +136,24 @@ SymbolFileDWARF::SymbolFileDWARF(ObjectFile* ofile) :
SymbolFile(ofile),
m_flags(),
m_data_debug_abbrev(),
- m_data_debug_aranges(),
m_data_debug_frame(),
m_data_debug_info(),
m_data_debug_line(),
m_data_debug_loc(),
- m_data_debug_macinfo(),
- m_data_debug_pubnames(),
- m_data_debug_pubtypes(),
m_data_debug_ranges(),
m_data_debug_str(),
m_abbr(),
m_aranges(),
m_info(),
m_line(),
- 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_function_basename_index(),
+ m_function_fullname_index(),
+ m_function_method_index(),
+ m_function_selector_index(),
+ m_global_index(),
+ m_types_index(),
m_indexed(false),
-// m_pubnames(),
-// m_pubbasetypes(),
- m_pubtypes(),
- m_ranges()//,
-// m_type_fixups(),
-// m_indirect_fixups()
+ m_ranges()
{
}
@@ -333,12 +325,6 @@ SymbolFileDWARF::get_debug_abbrev_data()
}
const DataExtractor&
-SymbolFileDWARF::get_debug_aranges_data()
-{
- return GetCachedSectionData (flagsGotDebugArangesData, eSectionTypeDWARFDebugAranges, m_data_debug_aranges);
-}
-
-const DataExtractor&
SymbolFileDWARF::get_debug_frame_data()
{
return GetCachedSectionData (flagsGotDebugFrameData, eSectionTypeDWARFDebugFrame, m_data_debug_frame);
@@ -363,24 +349,6 @@ SymbolFileDWARF::get_debug_loc_data()
}
const DataExtractor&
-SymbolFileDWARF::get_debug_macinfo_data()
-{
- return GetCachedSectionData (flagsGotDebugMacInfoData, eSectionTypeDWARFDebugMacInfo, m_data_debug_macinfo);
-}
-
-const DataExtractor&
-SymbolFileDWARF::get_debug_pubnames_data()
-{
- return GetCachedSectionData (flagsGotDebugPubNamesData, eSectionTypeDWARFDebugPubNames, m_data_debug_pubnames);
-}
-
-const DataExtractor&
-SymbolFileDWARF::get_debug_pubtypes_data()
-{
- return GetCachedSectionData (flagsGotDebugPubTypesData, eSectionTypeDWARFDebugPubTypes, m_data_debug_pubtypes);
-}
-
-const DataExtractor&
SymbolFileDWARF::get_debug_ranges_data()
{
return GetCachedSectionData (flagsGotDebugRangesData, eSectionTypeDWARFDebugRanges, m_data_debug_ranges);
@@ -475,30 +443,6 @@ SymbolFileDWARF::DebugInfo() const
return m_info.get();
}
-//DWARFDebugLine*
-//SymbolFileDWARF::DebugLine()
-//{
-// if (m_line.get() == NULL)
-// {
-// Timer scoped_timer(__PRETTY_FUNCTION__);
-// const DataExtractor &debug_line_data = debug_line();
-// if (debug_line_data.GetByteSize() > 0)
-// {
-// m_line.reset(new DWARFDebugLine());
-// if (m_line.get())
-// m_line->Parse(debug_line_data);
-// }
-// }
-// return m_line.get();
-//}
-//
-//const DWARFDebugLine*
-//SymbolFileDWARF::DebugLine() const
-//{
-// return m_line.get();
-//}
-
-
DWARFCompileUnit*
SymbolFileDWARF::GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid)
{
@@ -508,37 +452,6 @@ SymbolFileDWARF::GetDWARFCompileUnitForUID(lldb::user_id_t cu_uid)
return NULL;
}
-//DWARFCompileUnit*
-//SymbolFileDWARF::GetNextUnparsedDWARFCompileUnit(DWARFCompileUnit* prev_cu)
-//{
-// DWARFCompileUnit* cu = NULL;
-// DWARFDebugInfo* info = DebugInfo();
-// if (info)
-// {
-// uint32_t cu_idx = 0;
-// if (prev_cu != NULL)
-// {
-// // Find the index of the previus DWARF compile unit if one was provided
-// while ((cu = info->GetCompileUnitAtIndex(cu_idx)) != NULL)
-// {
-// ++cu_idx;
-// if (cu == prev_cu)
-// break;
-// }
-// }
-//
-// // Now find the next unparsed DWARF compile unit. We do this by checking the
-// // user data in the DWARFCompileUnit class that starts as NULL, and eventually
-// // holds a pointer to the CompileUnit that was created for it after it has
-// // been parsed.
-// while ((cu = info->GetCompileUnitAtIndex(cu_idx)) != NULL)
-// {
-// if (cu->GetUserData() == NULL)
-// break;
-// }
-// }
-// return cu;
-//}
DWARFDebugRanges*
SymbolFileDWARF::DebugRanges()
@@ -561,88 +474,6 @@ SymbolFileDWARF::DebugRanges() const
{
return m_ranges.get();
}
-//
-//DWARFDebugPubnames*
-//SymbolFileDWARF::DebugPubnames()
-//{
-// if (m_pubnames.get() == NULL)
-// {
-// Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this);
-// const DataExtractor &debug_pubnames_data = get_debug_pubnames_data();
-// if (debug_pubnames_data.GetByteSize() > 0)
-// {
-// // Pass false to indicate this is a pubnames section
-// m_pubnames.reset(new DWARFDebugPubnames());
-// if (m_pubnames.get())
-// {
-// // "m_pubnames->GeneratePubnames" is costly, but needed for global variables
-// m_pubnames->GeneratePubnames(this);
-//
-//#if 0
-// StreamFile s(stdout);
-// s.Printf (".debug_pubnames for %s/%s:\n",
-// m_obj_file->GetModule()->GetFileSpec().GetDirectory().AsCString(),
-// m_obj_file->GetModule()->GetFileSpec().GetFilename().AsCString());
-// m_pubnames->Dump (&s);
-//#endif
-// // "m_pubnames->Extract" is quicker, but the pubnames don't always contain what we need.
-// //m_pubnames->Extract(debug_pubnames_data);
-// }
-// }
-// }
-// return m_pubnames.get();
-//}
-//
-//const DWARFDebugPubnames*
-//SymbolFileDWARF::DebugPubnames() const
-//{
-// return m_pubnames.get();
-//}
-
-//DWARFDebugPubnames*
-//SymbolFileDWARF::DebugPubBaseTypes()
-//{
-// if (m_pubbasetypes.get() == NULL)
-// {
-// Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this);
-// // Pass false to indicate this is a pubnames section
-// m_pubbasetypes.reset(new DWARFDebugPubnames());
-// if (m_pubbasetypes.get())
-// m_pubbasetypes->GeneratePubBaseTypes(this);
-// }
-// return m_pubbasetypes.get();
-//}
-//
-//const DWARFDebugPubnames*
-//SymbolFileDWARF::DebugPubBaseTypes() const
-//{
-// return m_pubbasetypes.get();
-//}
-//
-//const DWARFDebugPubnames*
-//SymbolFileDWARF::DebugPubtypes() const
-//{
-// return m_pubtypes.get();
-//}
-//
-DWARFDebugPubnames*
-SymbolFileDWARF::DebugPubtypes()
-{
- if (m_pubtypes.get() == NULL)
- {
- Timer scoped_timer(__PRETTY_FUNCTION__, "%s this = %p", __PRETTY_FUNCTION__, this);
- const DataExtractor &debug_pubtypes_data = get_debug_pubtypes_data();
- if (debug_pubtypes_data.GetByteSize() > 0)
- {
- // Pass false to indicate this is a pubnames section
- m_pubtypes.reset(new DWARFDebugPubnames());
- if (m_pubtypes.get())
- m_pubtypes->Extract(debug_pubtypes_data);
- }
- }
- return m_pubtypes.get();
-}
-
bool
SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit* cu, CompUnitSP& compile_unit_sp)
@@ -682,92 +513,12 @@ SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit* cu, CompUnitSP& compile_unit
return false;
}
-#if defined LLDB_SYMBOL_FILE_DWARF_SHRINK_TEST
-
-void
-SymbolFileDWARF::ShrinkDSYM(CompileUnit *dc_cu, DWARFCompileUnit *dw_cu, const FileSpec& cu_fspec, const FileSpec& base_types_fspec, FSToDIES& fs_to_dies, const DWARFDebugInfoEntry *die)
-{
- while (die != NULL)
- {
- dw_tag_t tag = die->Tag();
-
- switch (tag)
- {
- case DW_TAG_base_type:
- // Put all base types into the base type compile unit
- fs_to_dies[base_types_fspec].Insert(die);
- break;
-
- default:
- {
- uint32_t decl_file = die->GetAttributeValueAsUnsigned(this, dw_cu, DW_AT_decl_file, 0);
- if (decl_file)
- {
- fs_to_dies[dc_cu->GetSupportFiles().GetFileSpecAtIndex(decl_file)].Insert(die);
- }
- else
- {
- // add this to the current compile unit
- fs_to_dies[cu_fspec].Insert(die);
- }
- }
- break;
- }
-
- die = die->GetSibling();
- }
-}
-
-
-
-#endif
-
uint32_t
SymbolFileDWARF::GetNumCompileUnits()
{
DWARFDebugInfo* info = DebugInfo();
if (info)
- {
-#if defined LLDB_SYMBOL_FILE_DWARF_SHRINK_TEST
- uint32_t cu_idx;
- FSToDIES fs_to_dies;
-
- FileSpec base_type_fspec("DW_TAG_base_type");
- const uint32_t num_comp_units = info->GetNumCompileUnits();
-
- for (cu_idx=0; cu_idx < num_comp_units; ++cu_idx)
- {
- DWARFCompileUnit* cu = info->GetCompileUnitAtIndex(cu_idx);
- if (cu != NULL)
- {
- const DWARFDebugInfoEntry *cu_die = cu->DIE();
- if (cu_die)
- {
- CompUnitSP dc_cu_sp;
- ParseCompileUnit(cu, dc_cu_sp);
- if (dc_cu_sp.get())
- {
- FileSpec cu_fspec(*dc_cu_sp.get());
-
- ShrinkDSYM(dc_cu_sp.get(), cu, cu_fspec, base_type_fspec, fs_to_dies, cu->DIE()->GetFirstChild());
- }
- }
- }
- }
-
- Stream strm(stdout);
- FSToDIES::const_iterator pos, end = fs_to_dies.end();
- for (pos = fs_to_dies.begin(); pos != end; ++pos)
- {
- strm << "\n\nMinimal Compile Unit: " << pos->first << ":\n";
- const DWARFDIECollection& dies = pos->second;
- dies.Dump(strm, NULL);
- }
- return num_comp_units;
-#else
return info->GetNumCompileUnits();
-#endif
- }
return 0;
}
@@ -1462,24 +1213,20 @@ SymbolFileDWARF::GetClangDeclContextForTypeUID (lldb::user_id_t type_uid)
}
Type*
-SymbolFileDWARF::ResolveTypeUID(lldb::user_id_t type_uid)
+SymbolFileDWARF::ResolveTypeUID (lldb::user_id_t type_uid)
{
DWARFDebugInfo* debug_info = DebugInfo();
if (debug_info)
{
- const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, NULL);
+ DWARFCompileUnitSP cu_sp;
+ const DWARFDebugInfoEntry* type_die = debug_info->GetDIEPtr(type_uid, &cu_sp);
if (type_die != NULL)
{
void *type = type_die->GetUserData();
if (type == NULL)
{
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* die = debug_info->GetDIEPtr(type_uid, &cu_sp);
- if (die != NULL)
- {
- TypeSP owning_type_sp;
- TypeSP type_sp(GetTypeForDIE(cu_sp.get(), die, owning_type_sp, 0, 0));
- }
+ TypeSP owning_type_sp;
+ GetTypeForDIE(cu_sp.get(), type_die, owning_type_sp, 0, 0);
type = type_die->GetUserData();
}
if (type != DIE_IS_BEING_PARSED)
@@ -1489,6 +1236,24 @@ SymbolFileDWARF::ResolveTypeUID(lldb::user_id_t type_uid)
return NULL;
}
+Type*
+SymbolFileDWARF::ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die)
+{
+ if (type_die != NULL)
+ {
+ void *type = type_die->GetUserData();
+ if (type == NULL)
+ {
+ TypeSP owning_type_sp;
+ TypeSP type_sp(GetTypeForDIE(cu, type_die, owning_type_sp, 0, 0));
+ type = type_die->GetUserData();
+ }
+ if (type != DIE_IS_BEING_PARSED)
+ return (Type *)type;
+ }
+ return NULL;
+}
+
CompileUnit*
SymbolFileDWARF::GetCompUnitForDWARFCompUnit(DWARFCompileUnit* cu, uint32_t cu_idx)
{
@@ -1762,12 +1527,13 @@ SymbolFileDWARF::Index ()
bool clear_dies = cu->ExtractDIEsIfNeeded (false) > 1;
- 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,
+ cu->Index (cu_idx,
+ m_function_basename_index,
+ m_function_fullname_index,
+ m_function_method_index,
+ m_function_selector_index,
+ m_global_index,
+ m_types_index,
DebugRanges(),
m_aranges.get());
@@ -1777,20 +1543,27 @@ SymbolFileDWARF::Index ()
cu->ClearDIEs (true);
}
- 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();
m_aranges->Sort();
+
+#if 0
+ StreamFile s(stdout);
+ s.Printf("DWARF index for '%s':", GetObjectFile()->GetFileSpec().GetFilename().AsCString());
+ s.Printf("\nFunction basenames:\n"); m_function_basename_index.Dump (&s);
+ s.Printf("\nFunction fullnames:\n"); m_function_fullname_index.Dump (&s);
+ s.Printf("\nFunction methods:\n"); m_function_method_index.Dump (&s);
+ s.Printf("\nFunction selectors:\n"); m_function_selector_index.Dump (&s);
+ s.Printf("\nGlobals and statics:\n"); m_global_index.Dump (&s);
+ s.Printf("\nTypes:\n"); m_types_index.Dump (&s);
+#endif
}
}
uint32_t
SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint32_t max_matches, VariableList& variables)
{
- std::vector<dw_offset_t> die_offsets;
+ DWARFDebugInfo* info = DebugInfo();
+ if (info == NULL)
+ return 0;
// If we aren't appending the results to this list, then clear the list
if (!append)
@@ -1804,29 +1577,31 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint
if (!m_indexed)
Index ();
- const UniqueCStringMap<dw_offset_t>::Entry *entry;
+ SymbolContext sc;
+ sc.module_sp = m_obj_file->GetModule()->GetSP();
+ assert (sc.module_sp);
- for (entry = m_name_to_global_die.FindFirstValueForName (name.AsCString());
- entry != NULL;
- entry = m_name_to_global_die.FindNextValueForName (name.AsCString(), entry))
+ DWARFCompileUnit* cu = NULL;
+ DWARFCompileUnit* prev_cu = NULL;
+ const DWARFDebugInfoEntry* die = NULL;
+ std::vector<NameToDIE::Info> die_info_array;
+ const size_t num_matches = m_global_index.Find(name, die_info_array);
+ for (size_t i=0; i<num_matches; ++i, prev_cu = cu)
{
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr (entry->value, &cu_sp);
- DWARFCompileUnit* cu = cu_sp.get();
- if (die)
- {
- SymbolContext sc;
- sc.module_sp = m_obj_file->GetModule()->GetSP();
- assert (sc.module_sp);
+ cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx);
+
+ if (cu != prev_cu)
+ cu->ExtractDIEsIfNeeded (false);
- sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX);
- assert(sc.comp_unit != NULL);
+ die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
- ParseVariables(sc, cu_sp.get(), LLDB_INVALID_ADDRESS, die, false, false, &variables);
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX);
+ assert(sc.comp_unit != NULL);
- if (variables.GetSize() - original_size >= max_matches)
- break;
- }
+ ParseVariables(sc, cu, LLDB_INVALID_ADDRESS, die, false, false, &variables);
+
+ if (variables.GetSize() - original_size >= max_matches)
+ break;
}
// Return the number of variable that were appended to the list
@@ -1836,7 +1611,9 @@ SymbolFileDWARF::FindGlobalVariables (const ConstString &name, bool append, uint
uint32_t
SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables)
{
- std::vector<dw_offset_t> die_offsets;
+ DWARFDebugInfo* info = DebugInfo();
+ if (info == NULL)
+ return 0;
// If we aren't appending the results to this list, then clear the list
if (!append)
@@ -1850,33 +1627,31 @@ SymbolFileDWARF::FindGlobalVariables(const RegularExpression& regex, bool append
if (!m_indexed)
Index ();
- // Create the pubnames information so we can quickly lookup external symbols by name
- const size_t num_entries = m_name_to_global_die.GetSize();
- for (size_t i=0; i<num_entries; i++)
+ SymbolContext sc;
+ sc.module_sp = m_obj_file->GetModule()->GetSP();
+ assert (sc.module_sp);
+
+ DWARFCompileUnit* cu = NULL;
+ DWARFCompileUnit* prev_cu = NULL;
+ const DWARFDebugInfoEntry* die = NULL;
+ std::vector<NameToDIE::Info> die_info_array;
+ const size_t num_matches = m_global_index.Find(regex, die_info_array);
+ for (size_t i=0; i<num_matches; ++i, prev_cu = cu)
{
- if (!regex.Execute(m_name_to_global_die.GetCStringAtIndex (i)))
- continue;
-
- const dw_offset_t die_offset = *m_name_to_global_die.GetValueAtIndex (i);
-
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr (die_offset, &cu_sp);
- DWARFCompileUnit* cu = cu_sp.get();
- if (die)
- {
- SymbolContext sc;
- sc.module_sp = m_obj_file->GetModule()->GetSP();
- assert (sc.module_sp);
+ cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx);
+
+ if (cu != prev_cu)
+ cu->ExtractDIEsIfNeeded (false);
+ die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
- sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX);
- assert(sc.comp_unit != NULL);
+ sc.comp_unit = GetCompUnitForDWARFCompUnit(cu, UINT32_MAX);
+ assert(sc.comp_unit != NULL);
- ParseVariables(sc, cu_sp.get(), LLDB_INVALID_ADDRESS, die, false, false, &variables);
+ ParseVariables(sc, cu, LLDB_INVALID_ADDRESS, die, false, false, &variables);
- if (variables.GetSize() - original_size >= max_matches)
- break;
- }
+ if (variables.GetSize() - original_size >= max_matches)
+ break;
}
// Return the number of variable that were appended to the list
@@ -1888,39 +1663,95 @@ void
SymbolFileDWARF::FindFunctions
(
const ConstString &name,
- UniqueCStringMap<dw_offset_t> &name_to_die,
+ const NameToDIE &name_to_die,
SymbolContextList& sc_list
)
{
- const UniqueCStringMap<dw_offset_t>::Entry *entry;
-
+ DWARFDebugInfo* info = DebugInfo();
+ if (info == NULL)
+ return;
+
SymbolContext sc;
- for (entry = name_to_die.FindFirstValueForName (name.AsCString());
- entry != NULL;
- entry = name_to_die.FindNextValueForName (name.AsCString(), entry))
+ sc.module_sp = m_obj_file->GetModule()->GetSP();
+ assert (sc.module_sp);
+
+ DWARFCompileUnit* cu = NULL;
+ DWARFCompileUnit* prev_cu = NULL;
+ const DWARFDebugInfoEntry* die = NULL;
+ std::vector<NameToDIE::Info> die_info_array;
+ const size_t num_matches = name_to_die.Find(name, die_info_array);
+ for (size_t i=0; i<num_matches; ++i, prev_cu = cu)
{
- DWARFCompileUnitSP cu_sp;
- const DWARFDebugInfoEntry* die = DebugInfo()->GetDIEPtr (entry->value, &cu_sp);
- if (die)
+ cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx);
+
+ if (cu != prev_cu)
+ cu->ExtractDIEsIfNeeded (false);
+
+ die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
+ if (GetFunction (cu, die, sc))
{
- if (GetFunction (cu_sp.get(), die, sc))
+ // We found the function, so we should find the line table
+ // and line table entry as well
+ LineTable *line_table = sc.comp_unit->GetLineTable();
+ if (line_table == NULL)
{
- // We found the function, so we should find the line table
- // and line table entry as well
- LineTable *line_table = sc.comp_unit->GetLineTable();
- if (line_table == NULL)
- {
- if (ParseCompileUnitLineTable(sc))
- line_table = sc.comp_unit->GetLineTable();
- }
- if (line_table != NULL)
- line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry);
-
- sc_list.Append(sc);
+ if (ParseCompileUnitLineTable(sc))
+ line_table = sc.comp_unit->GetLineTable();
}
+ if (line_table != NULL)
+ line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry);
+
+ sc_list.Append(sc);
}
}
+}
+
+
+void
+SymbolFileDWARF::FindFunctions
+(
+ const RegularExpression &regex,
+ const NameToDIE &name_to_die,
+ SymbolContextList& sc_list
+)
+{
+ DWARFDebugInfo* info = DebugInfo();
+ if (info == NULL)
+ return;
+ SymbolContext sc;
+ sc.module_sp = m_obj_file->GetModule()->GetSP();
+ assert (sc.module_sp);
+
+ DWARFCompileUnit* cu = NULL;
+ DWARFCompileUnit* prev_cu = NULL;
+ const DWARFDebugInfoEntry* die = NULL;
+ std::vector<NameToDIE::Info> die_info_array;
+ const size_t num_matches = name_to_die.Find(regex, die_info_array);
+ for (size_t i=0; i<num_matches; ++i, prev_cu = cu)
+ {
+ cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx);
+
+ if (cu != prev_cu)
+ cu->ExtractDIEsIfNeeded (false);
+
+ die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
+ if (GetFunction (cu, die, sc))
+ {
+ // We found the function, so we should find the line table
+ // and line table entry as well
+ LineTable *line_table = sc.comp_unit->GetLineTable();
+ if (line_table == NULL)
+ {
+ if (ParseCompileUnitLineTable(sc))
+ line_table = sc.comp_unit->GetLineTable();
+ }
+ if (line_table != NULL)
+ line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry);
+
+ sc_list.Append(sc);
+ }
+ }
}
uint32_t
@@ -1936,8 +1767,6 @@ SymbolFileDWARF::FindFunctions
"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();
@@ -1951,16 +1780,16 @@ SymbolFileDWARF::FindFunctions
Index ();
if (name_type_mask & eFunctionNameTypeBase)
- FindFunctions (name, m_base_name_to_function_die, sc_list);
+ FindFunctions (name, m_function_basename_index, sc_list);
if (name_type_mask & eFunctionNameTypeFull)
- FindFunctions (name, m_full_name_to_function_die, sc_list);
+ FindFunctions (name, m_function_fullname_index, sc_list);
if (name_type_mask & eFunctionNameTypeMethod)
- FindFunctions (name, m_method_name_to_function_die, sc_list);
+ FindFunctions (name, m_function_method_index, sc_list);
if (name_type_mask & eFunctionNameTypeSelector)
- FindFunctions (name, m_selector_name_to_function_die, sc_list);
+ FindFunctions (name, m_function_selector_index, sc_list);
// Return the number of variable that were appended to the list
return sc_list.GetSize() - original_size;
@@ -1974,8 +1803,6 @@ SymbolFileDWARF::FindFunctions(const RegularExpression& regex, bool append, Symb
"SymbolFileDWARF::FindFunctions (regex = '%s')",
regex.GetText());
- 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();
@@ -1988,35 +1815,9 @@ SymbolFileDWARF::FindFunctions(const RegularExpression& regex, bool append, Symb
if (!m_indexed)
Index ();
- // 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_full_name_to_function_die.GetSize();
- SymbolContext sc;
- for (size_t i=0; i<num_entries; i++)
- {
- if (!regex.Execute(m_full_name_to_function_die.GetCStringAtIndex (i)))
- continue;
-
- 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);
- if (die)
- {
- if (GetFunction (cu_sp.get(), die, sc))
- {
- // We found the function, so we should find the line table
- // and line table entry as well
- LineTable *line_table = sc.comp_unit->GetLineTable();
-
- if (line_table != NULL)
- line_table->FindLineEntryByAddress (sc.function->GetAddressRange().GetBaseAddress(), sc.line_entry);
-
+ FindFunctions (regex, m_function_basename_index, sc_list);
- sc_list.Append(sc);
- }
- }
- }
+ FindFunctions (regex, m_function_fullname_index, sc_list);
// Return the number of variable that were appended to the list
return sc_list.GetSize() - original_size;
@@ -2025,55 +1826,45 @@ SymbolFileDWARF::FindFunctions(const RegularExpression& regex, bool append, Symb
uint32_t
SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, bool append, uint32_t max_matches, TypeList& types)
{
+ DWARFDebugInfo* info = DebugInfo();
+ if (info == NULL)
+ return 0;
+
// If we aren't appending the results to this list, then clear the list
if (!append)
types.Clear();
- // Create the pubnames information so we can quickly lookup external symbols by name
- DWARFDebugPubnames* pubtypes = DebugPubtypes();
- if (pubtypes)
+ const uint32_t initial_types_size = types.GetSize();
+ DWARFCompileUnit* cu = NULL;
+ DWARFCompileUnit* prev_cu = NULL;
+ const DWARFDebugInfoEntry* die = NULL;
+ std::vector<NameToDIE::Info> die_info_array;
+ const size_t num_matches = m_types_index.Find (name, die_info_array);
+ for (size_t i=0; i<num_matches; ++i, prev_cu = cu)
{
- std::vector<dw_offset_t> die_offsets;
- if (!pubtypes->Find(name.AsCString(), false, die_offsets))
+ cu = info->GetCompileUnitAtIndex(die_info_array[i].cu_idx);
+
+ if (cu != prev_cu)
+ cu->ExtractDIEsIfNeeded (false);
+
+ die = cu->GetDIEAtIndexUnchecked(die_info_array[i].die_idx);
+
+ Type *matching_type = ResolveType (cu, die);
+ if (matching_type)
{
-// DWARFDebugPubnames* pub_base_types = DebugPubBaseTypes();
-// if (pub_base_types && !pub_base_types->Find(name.AsCString(), false, die_offsets))
- return 0;
+ // We found a type pointer, now find the shared pointer form our type list
+ TypeSP type_sp (m_obj_file->GetModule()->GetTypeList()->FindType(matching_type->GetID()));
+ assert (type_sp.get() != NULL);
+ types.InsertUnique (type_sp);
+ if (types.GetSize() >= max_matches)
+ break;
}
- return FindTypes(die_offsets, max_matches, types);
}
- return 0;
+ return types.GetSize() - initial_types_size;
}
-//uint32_t
-//SymbolFileDWARF::FindTypes(const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types)
-//{
-// // If we aren't appending the results to this list, then clear the list
-// if (!append)
-// types.Clear();
-//
-// // Create the pubnames information so we can quickly lookup external symbols by name
-// DWARFDebugPubnames* pubtypes = DebugPubtypes();
-// if (pubtypes)
-// {
-// std::vector<dw_offset_t> die_offsets;
-// if (!pubtypes->Find(regex, die_offsets))
-// {
-// DWARFDebugPubnames* pub_base_types = DebugPubBaseTypes();
-// if (pub_base_types && !pub_base_types->Find(regex, die_offsets))
-// return 0;
-// }
-//
-// return FindTypes(die_offsets, max_matches, encoding, udt_uid, types);
-// }
-//
-// return 0;
-//}
-//
-
-
uint32_t
SymbolFileDWARF::FindTypes(std::vector<dw_offset_t> die_offsets, uint32_t max_matches, TypeList& types)
{
@@ -3344,10 +3135,12 @@ SymbolFileDWARF::ParseVariablesForContext (const SymbolContext& sc)
if (!m_indexed)
Index ();
- const size_t num_globals = dwarf_cu->GetNumGlobals();
+
+ std::vector<NameToDIE::Info> global_die_info_array;
+ const size_t num_globals = m_global_index.FindAllEntriesForCompileUnitWithIndex (sc.comp_unit->GetID(), global_die_info_array);
for (size_t idx=0; idx<num_globals; ++idx)
{
- VariableSP var_sp (ParseVariableDIE(sc, dwarf_cu, dwarf_cu->GetGlobalDIEAtIndex (idx), LLDB_INVALID_ADDRESS));
+ 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);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 2d86359f010..e901c7b3df8 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -31,6 +31,7 @@
// Project includes
#include "DWARFDefines.h"
+#include "NameToDIE.h"
//----------------------------------------------------------------------
@@ -92,7 +93,8 @@ public:
virtual size_t ParseTypes (const lldb_private::SymbolContext& sc);
virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc);
- virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid);
+ virtual lldb_private::Type* ResolveTypeUID(lldb::user_id_t type_uid);
+ virtual lldb_private::Type* ResolveType (DWARFCompileUnit* cu, const DWARFDebugInfoEntry* type_die);
virtual clang::DeclContext* GetClangDeclContextForTypeUID (lldb::user_id_t type_uid);
virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc);
@@ -134,14 +136,10 @@ public:
//virtual CompUnitSP GetCompUnitAtIndex(size_t cu_idx) = 0;
const lldb_private::DataExtractor& get_debug_abbrev_data();
- const lldb_private::DataExtractor& get_debug_aranges_data();
const lldb_private::DataExtractor& get_debug_frame_data();
const lldb_private::DataExtractor& get_debug_info_data();
const lldb_private::DataExtractor& get_debug_line_data();
const lldb_private::DataExtractor& get_debug_loc_data();
- const lldb_private::DataExtractor& get_debug_macinfo_data();
- const lldb_private::DataExtractor& get_debug_pubnames_data();
- const lldb_private::DataExtractor& get_debug_pubtypes_data();
const lldb_private::DataExtractor& get_debug_ranges_data();
const lldb_private::DataExtractor& get_debug_str_data();
@@ -154,19 +152,6 @@ public:
DWARFDebugInfo* DebugInfo();
const DWARFDebugInfo* DebugInfo() const;
-// These shouldn't be used unless we want to dump the DWARF line tables.
-// DWARFDebugLine* DebugLine();
-// const DWARFDebugLine* DebugLine() const;
-
-// DWARFDebugPubnames* DebugPubnames();
-// const DWARFDebugPubnames* DebugPubnames() const;
-//
-// DWARFDebugPubnames* DebugPubBaseTypes();
-// const DWARFDebugPubnames* DebugPubBaseTypes() const;
-//
- DWARFDebugPubnames* DebugPubtypes();
-// const DWARFDebugPubnames* DebugPubtypes() const;
-
DWARFDebugRanges* DebugRanges();
const DWARFDebugRanges* DebugRanges() const;
@@ -286,7 +271,12 @@ protected:
void FindFunctions(
const lldb_private::ConstString &name,
- lldb_private::UniqueCStringMap<dw_offset_t> &name_to_die,
+ const NameToDIE &name_to_die,
+ lldb_private::SymbolContextList& sc_list);
+
+ void FindFunctions (
+ const lldb_private::RegularExpression &regex,
+ const NameToDIE &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);
@@ -298,14 +288,10 @@ protected:
lldb_private::Flags m_flags;
lldb_private::DataExtractor m_dwarf_data;
lldb_private::DataExtractor m_data_debug_abbrev;
- lldb_private::DataExtractor m_data_debug_aranges;
lldb_private::DataExtractor m_data_debug_frame;
lldb_private::DataExtractor m_data_debug_info;
lldb_private::DataExtractor m_data_debug_line;
lldb_private::DataExtractor m_data_debug_loc;
- lldb_private::DataExtractor m_data_debug_macinfo;
- lldb_private::DataExtractor m_data_debug_pubnames;
- lldb_private::DataExtractor m_data_debug_pubtypes;
lldb_private::DataExtractor m_data_debug_ranges;
lldb_private::DataExtractor m_data_debug_str;
@@ -315,31 +301,19 @@ protected:
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_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
+ NameToDIE m_function_basename_index; // All concrete functions
+ NameToDIE m_function_fullname_index; // All concrete functions
+ NameToDIE m_function_method_index; // All inlined functions
+ NameToDIE m_function_selector_index; // All method names for functions of classes
+ NameToDIE m_global_index; // Global and static variables
+ NameToDIE m_types_index; // All type DIE offsets
bool m_indexed;
-// std::auto_ptr<DWARFDebugPubnames> m_pubnames;
-// std::auto_ptr<DWARFDebugPubnames> m_pubbasetypes; // Just like m_pubtypes, but for DW_TAG_base_type DIEs
- std::auto_ptr<DWARFDebugPubnames> m_pubtypes;
std::auto_ptr<DWARFDebugRanges> m_ranges;
typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> DIEToDeclContextMap;
DIEToDeclContextMap m_die_to_decl_ctx;
-// TypeFixupColl m_type_fixups;
-// std::vector<Type*> m_indirect_fixups;
-
-//#define LLDB_SYMBOL_FILE_DWARF_SHRINK_TEST 1
-#if defined(LLDB_SYMBOL_FILE_DWARF_SHRINK_TEST)
-
- typedef std::map<FileSpec, DWARFDIECollection> FSToDIES;
- void ShrinkDSYM(CompileUnit *dc_cu, DWARFCompileUnit *dw_cu, const FileSpec& cu_fspec, const FileSpec& base_types_cu_fspec, FSToDIES& fs_to_dies, const DWARFDebugInfoEntry *die);
-#endif
};
#endif // liblldb_SymbolFileDWARF_h_
OpenPOWER on IntegriCloud