summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/API/SBCompileUnit.h18
-rw-r--r--lldb/include/lldb/API/SBModule.h19
-rw-r--r--lldb/include/lldb/API/SBType.h2
-rw-r--r--lldb/include/lldb/Core/MappedHash.h25
-rw-r--r--lldb/include/lldb/Core/UniqueCStringMap.h6
-rw-r--r--lldb/include/lldb/Symbol/SymbolFile.h3
-rw-r--r--lldb/include/lldb/Symbol/SymbolVendor.h5
-rw-r--r--lldb/include/lldb/Symbol/Type.h21
-rw-r--r--lldb/include/lldb/Symbol/TypeList.h6
-rw-r--r--lldb/include/lldb/lldb-enumerations.h2
-rw-r--r--lldb/scripts/Python/interface/SBCompileUnit.i20
-rw-r--r--lldb/scripts/Python/interface/SBModule.i19
-rw-r--r--lldb/source/API/SBCompileUnit.cpp42
-rw-r--r--lldb/source/API/SBModule.cpp18
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h23
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp12
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h6
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp181
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h15
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp37
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h9
-rw-r--r--lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp6
-rw-r--r--lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h6
-rw-r--r--lldb/source/Symbol/SymbolVendor.cpp15
-rw-r--r--lldb/source/Symbol/Type.cpp27
-rw-r--r--lldb/source/Symbol/TypeList.cpp21
26 files changed, 550 insertions, 14 deletions
diff --git a/lldb/include/lldb/API/SBCompileUnit.h b/lldb/include/lldb/API/SBCompileUnit.h
index e6aba8286c0..95af3d4722c 100644
--- a/lldb/include/lldb/API/SBCompileUnit.h
+++ b/lldb/include/lldb/API/SBCompileUnit.h
@@ -59,6 +59,24 @@ public:
uint32_t
FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full);
+
+ //------------------------------------------------------------------
+ /// Get all types matching \a type_mask from debug info in this
+ /// compile unit.
+ ///
+ /// @param[in] type_mask
+ /// A bitfield that consists of one or more bits logically OR'ed
+ /// together from the lldb::TypeClass enumeration. This allows
+ /// you to request only structure types, or only class, struct
+ /// and union types. Passing in lldb::eTypeClassAny will return
+ /// all types found in the debug information for this compile
+ /// unit.
+ ///
+ /// @return
+ /// A list of types in this compile unit that match \a type_mask
+ //------------------------------------------------------------------
+ lldb::SBTypeList
+ GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
bool
operator == (const lldb::SBCompileUnit &rhs) const;
diff --git a/lldb/include/lldb/API/SBModule.h b/lldb/include/lldb/API/SBModule.h
index c75c4a151d3..53d2d711d8b 100644
--- a/lldb/include/lldb/API/SBModule.h
+++ b/lldb/include/lldb/API/SBModule.h
@@ -199,7 +199,24 @@ public:
lldb::SBType
GetBasicType(lldb::BasicType type);
-
+
+ //------------------------------------------------------------------
+ /// Get all types matching \a type_mask from debug info in this
+ /// module.
+ ///
+ /// @param[in] type_mask
+ /// A bitfield that consists of one or more bits logically OR'ed
+ /// together from the lldb::TypeClass enumeration. This allows
+ /// you to request only structure types, or only class, struct
+ /// and union types. Passing in lldb::eTypeClassAny will return
+ /// all types found in the debug information for this module.
+ ///
+ /// @return
+ /// A list of types in this module that match \a type_mask
+ //------------------------------------------------------------------
+ lldb::SBTypeList
+ GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
+
//------------------------------------------------------------------
/// Get the module version numbers.
///
diff --git a/lldb/include/lldb/API/SBType.h b/lldb/include/lldb/API/SBType.h
index 701ba7bc8a2..78c8f8d3ab4 100644
--- a/lldb/include/lldb/API/SBType.h
+++ b/lldb/include/lldb/API/SBType.h
@@ -235,6 +235,8 @@ public:
private:
std::unique_ptr<lldb_private::TypeListImpl> m_opaque_ap;
+ friend class SBModule;
+ friend class SBCompileUnit;
};
diff --git a/lldb/include/lldb/Core/MappedHash.h b/lldb/include/lldb/Core/MappedHash.h
index dd4999a0d2f..80d249d4cc9 100644
--- a/lldb/include/lldb/Core/MappedHash.h
+++ b/lldb/include/lldb/Core/MappedHash.h
@@ -486,6 +486,10 @@ public:
virtual const char *
GetStringForKeyType (KeyType key) const = 0;
+
+ virtual bool
+ ReadHashData (uint32_t hash_data_offset,
+ HashData &hash_data) const = 0;
// This method must be implemented in any subclasses and it must try to
// read one "Pair" at the offset pointed to by the "hash_data_offset_ptr"
@@ -514,6 +518,27 @@ public:
return m_header;
}
+
+ void
+ ForEach (std::function <bool(const HashData &hash_data)> const &callback) const
+ {
+ const size_t num_hash_offsets = m_header.hashes_count;
+ for (size_t i=0; i<num_hash_offsets; ++i)
+ {
+ uint32_t hash_data_offset = GetHashDataOffset (i);
+ if (hash_data_offset != UINT32_MAX)
+ {
+ HashData hash_data;
+ if (ReadHashData (hash_data_offset, hash_data))
+ {
+ // If the callback returns false, then we are done and should stop
+ if (callback(hash_data) == false)
+ return;
+ }
+ }
+ }
+ }
+
protected:
// Implementation agnostic information
HeaderType m_header;
diff --git a/lldb/include/lldb/Core/UniqueCStringMap.h b/lldb/include/lldb/Core/UniqueCStringMap.h
index 05eebfb33eb..972c0d53ea9 100644
--- a/lldb/include/lldb/Core/UniqueCStringMap.h
+++ b/lldb/include/lldb/Core/UniqueCStringMap.h
@@ -121,6 +121,12 @@ public:
return false;
}
+ const char *
+ GetCStringAtIndexUnchecked (uint32_t idx) const
+ {
+ return m_map[idx].cstring;
+ }
+
// Use this function if you have simple types in your map that you
// can easily copy when accessing values by index.
T
diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h
index bac886aa9f5..ef433d33684 100644
--- a/lldb/include/lldb/Symbol/SymbolFile.h
+++ b/lldb/include/lldb/Symbol/SymbolFile.h
@@ -140,6 +140,9 @@ public:
virtual uint32_t FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, TypeList& types) = 0;
// virtual uint32_t FindTypes (const SymbolContext& sc, const RegularExpression& regex, bool append, uint32_t max_matches, TypeList& types) = 0;
virtual TypeList * GetTypeList ();
+ virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list) = 0;
virtual ClangASTContext &
GetClangASTContext ();
virtual ClangNamespaceDecl
diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h
index 4c17e0f55cd..212fceb8f10 100644
--- a/lldb/include/lldb/Symbol/SymbolVendor.h
+++ b/lldb/include/lldb/Symbol/SymbolVendor.h
@@ -153,6 +153,11 @@ public:
return m_type_list;
}
+ virtual size_t
+ GetTypes (lldb_private::SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list);
+
SymbolFile *
GetSymbolFile()
{
diff --git a/lldb/include/lldb/Symbol/Type.h b/lldb/include/lldb/Symbol/Type.h
index a85d1cd31f2..e95441b5e30 100644
--- a/lldb/include/lldb/Symbol/Type.h
+++ b/lldb/include/lldb/Symbol/Type.h
@@ -474,6 +474,27 @@ public:
m_content.push_back(type);
}
+ class AppendVisitor
+ {
+ public:
+ AppendVisitor(TypeListImpl &type_list) :
+ m_type_list(type_list)
+ {
+ }
+
+ void
+ operator() (const lldb::TypeImplSP& type)
+ {
+ m_type_list.Append(type);
+ }
+
+ private:
+ TypeListImpl &m_type_list;
+ };
+
+ void
+ Append (const lldb_private::TypeList &type_list);
+
lldb::TypeImplSP
GetTypeAtIndex(size_t idx)
{
diff --git a/lldb/include/lldb/Symbol/TypeList.h b/lldb/include/lldb/Symbol/TypeList.h
index cd32b11ce33..9c74db6bf1f 100644
--- a/lldb/include/lldb/Symbol/TypeList.h
+++ b/lldb/include/lldb/Symbol/TypeList.h
@@ -51,6 +51,12 @@ public:
lldb::TypeSP
GetTypeAtIndex(uint32_t idx);
+ void
+ ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &callback) const;
+
+ void
+ ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback);
+
bool
RemoveTypeWithUID (lldb::user_id_t uid);
diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h
index cfc68f19732..3b3ff087b66 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -610,7 +610,7 @@ namespace lldb {
eTypeClassOther = (1u << 31),
// Define a mask that can be used for any type when finding types
eTypeClassAny = (0xffffffffu)
- }TypeClass;
+ } TypeClass;
typedef enum TemplateArgumentKind
{
diff --git a/lldb/scripts/Python/interface/SBCompileUnit.i b/lldb/scripts/Python/interface/SBCompileUnit.i
index 3bfaf70b997..a7e76cb1183 100644
--- a/lldb/scripts/Python/interface/SBCompileUnit.i
+++ b/lldb/scripts/Python/interface/SBCompileUnit.i
@@ -86,6 +86,26 @@ public:
uint32_t
FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full);
+ %feature("docstring", "
+ //------------------------------------------------------------------
+ /// Get all types matching \a type_mask from debug info in this
+ /// compile unit.
+ ///
+ /// @param[in] type_mask
+ /// A bitfield that consists of one or more bits logically OR'ed
+ /// together from the lldb::TypeClass enumeration. This allows
+ /// you to request only structure types, or only class, struct
+ /// and union types. Passing in lldb::eTypeClassAny will return
+ /// all types found in the debug information for this compile
+ /// unit.
+ ///
+ /// @return
+ /// A list of types in this compile unit that match \a type_mask
+ //------------------------------------------------------------------
+ ") GetTypes;
+ lldb::SBTypeList
+ GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
+
bool
GetDescription (lldb::SBStream &description);
diff --git a/lldb/scripts/Python/interface/SBModule.i b/lldb/scripts/Python/interface/SBModule.i
index cb970d6af36..aa2571c1090 100644
--- a/lldb/scripts/Python/interface/SBModule.i
+++ b/lldb/scripts/Python/interface/SBModule.i
@@ -227,6 +227,25 @@ public:
%feature("docstring", "
//------------------------------------------------------------------
+ /// Get all types matching \a type_mask from debug info in this
+ /// module.
+ ///
+ /// @param[in] type_mask
+ /// A bitfield that consists of one or more bits logically OR'ed
+ /// together from the lldb::TypeClass enumeration. This allows
+ /// you to request only structure types, or only class, struct
+ /// and union types. Passing in lldb::eTypeClassAny will return
+ /// all types found in the debug information for this module.
+ ///
+ /// @return
+ /// A list of types in this module that match \a type_mask
+ //------------------------------------------------------------------
+ ") GetTypes;
+ lldb::SBTypeList
+ GetTypes (uint32_t type_mask = lldb::eTypeClassAny);
+
+ %feature("docstring", "
+ //------------------------------------------------------------------
/// Find global and static variables by name.
///
/// @param[in] target
diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp
index f3a8417d720..9f7487746a8 100644
--- a/lldb/source/API/SBCompileUnit.cpp
+++ b/lldb/source/API/SBCompileUnit.cpp
@@ -10,10 +10,13 @@
#include "lldb/API/SBCompileUnit.h"
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBStream.h"
+#include "lldb/Core/Log.h"
+#include "lldb/Core/Module.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/LineEntry.h"
#include "lldb/Symbol/LineTable.h"
-#include "lldb/Core/Log.h"
+#include "lldb/Symbol/SymbolVendor.h"
+#include "lldb/Symbol/Type.h"
using namespace lldb;
using namespace lldb_private;
@@ -148,12 +151,39 @@ SBCompileUnit::GetNumSupportFiles () const
{
if (m_opaque_ptr)
{
- FileSpecList& support_files = m_opaque_ptr->GetSupportFiles ();
- return support_files.GetSize();
+ FileSpecList& support_files = m_opaque_ptr->GetSupportFiles ();
+ return support_files.GetSize();
}
return 0;
}
+
+
+lldb::SBTypeList
+SBCompileUnit::GetTypes (uint32_t type_mask)
+{
+ SBTypeList sb_type_list;
+
+ if (m_opaque_ptr)
+ {
+ ModuleSP module_sp (m_opaque_ptr->GetModule());
+ if (module_sp)
+ {
+ SymbolVendor* vendor = module_sp->GetSymbolVendor();
+ if (vendor)
+ {
+ TypeList type_list;
+ vendor->GetTypes (m_opaque_ptr, type_mask, type_list);
+ sb_type_list.m_opaque_ap->Append(type_list);
+ }
+ }
+ }
+ return sb_type_list;
+}
+
+
+
+
SBFileSpec
SBCompileUnit::GetSupportFileAtIndex (uint32_t idx) const
{
@@ -162,9 +192,9 @@ SBCompileUnit::GetSupportFileAtIndex (uint32_t idx) const
SBFileSpec sb_file_spec;
if (m_opaque_ptr)
{
- FileSpecList &support_files = m_opaque_ptr->GetSupportFiles ();
- FileSpec file_spec = support_files.GetFileSpecAtIndex(idx);
- sb_file_spec.SetFileSpec(file_spec);
+ FileSpecList &support_files = m_opaque_ptr->GetSupportFiles ();
+ FileSpec file_spec = support_files.GetFileSpecAtIndex(idx);
+ sb_file_spec.SetFileSpec(file_spec);
}
if (log)
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 3938fa8846d..47540b6f511 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -561,6 +561,24 @@ SBModule::FindTypes (const char *type)
return retval;
}
+lldb::SBTypeList
+SBModule::GetTypes (uint32_t type_mask)
+{
+ SBTypeList sb_type_list;
+
+ ModuleSP module_sp (GetSP ());
+ if (module_sp)
+ {
+ SymbolVendor* vendor = module_sp->GetSymbolVendor();
+ if (vendor)
+ {
+ TypeList type_list;
+ vendor->GetTypes (NULL, type_mask, type_list);
+ sb_type_list.m_opaque_ap->Append(type_list);
+ }
+ }
+ return sb_type_list;
+}
SBSection
SBModule::FindSection (const char *sect_name)
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
index 4b8a1fd8a30..c31cbaf3ca2 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.h
@@ -607,9 +607,30 @@ struct DWARFMappedHash
return m_string_table.PeekCStr (key);
}
+ virtual bool
+ ReadHashData (uint32_t hash_data_offset,
+ HashData &hash_data) const
+ {
+ lldb::offset_t offset = hash_data_offset;
+ offset += 4; // Skip string table offset that contains offset of hash name in .debug_str
+ const uint32_t count = m_data.GetU32 (&offset);
+ if (count > 0)
+ {
+ hash_data.resize(count);
+ for (uint32_t i=0; i<count; ++i)
+ {
+ if (!m_header.Read(m_data, &offset, hash_data[i]))
+ return false;
+ }
+ }
+ else
+ hash_data.clear();
+ return true;
+ }
+
virtual Result
GetHashDataForName (const char *name,
- lldb::offset_t* hash_data_offset_ptr,
+ lldb::offset_t* hash_data_offset_ptr,
Pair &pair) const
{
pair.key = m_data.GetU32 (hash_data_offset_ptr);
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
index 069009e62f3..5514469d075 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp
@@ -73,3 +73,15 @@ NameToDIE::Dump (Stream *s)
s->Printf("%p: {0x%8.8x} \"%s\"\n", cstr, m_map.GetValueAtIndexUnchecked(i), cstr);
}
}
+
+void
+NameToDIE::ForEach (std::function <bool(const char *name, uint32_t die_offset)> const &callback) const
+{
+ const uint32_t size = m_map.GetSize();
+ for (uint32_t i=0; i<size; ++i)
+ {
+ if (!callback(m_map.GetCStringAtIndexUnchecked(i),
+ m_map.GetValueAtIndexUnchecked (i)))
+ break;
+ }
+}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
index 43fb8a54ce9..f9a12736bf9 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h
@@ -11,6 +11,9 @@
#define SymbolFileDWARF_NameToDIE_h_
#include "lldb/Core/UniqueCStringMap.h"
+
+#include <functional>
+
#include "lldb/lldb-defines.h"
class SymbolFileDWARF;
@@ -51,6 +54,9 @@ public:
uint32_t cu_end_offset,
DIEArray &info_array) const;
+ void
+ ForEach (std::function <bool(const char *name, uint32_t die_offset)> const &callback) const;
+
protected:
lldb_private::UniqueCStringMap<uint32_t> m_map;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 392d2c93c3d..624d45d6262 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -235,6 +235,187 @@ SymbolFileDWARF::GetTypeList ()
return m_obj_file->GetModule()->GetTypeList();
}
+void
+SymbolFileDWARF::GetTypes (DWARFCompileUnit* cu,
+ const DWARFDebugInfoEntry *die,
+ dw_offset_t min_die_offset,
+ dw_offset_t max_die_offset,
+ uint32_t type_mask,
+ TypeSet &type_set)
+{
+ if (cu)
+ {
+ if (die)
+ {
+ const dw_offset_t die_offset = die->GetOffset();
+
+ if (die_offset >= max_die_offset)
+ return;
+
+ if (die_offset >= min_die_offset)
+ {
+ const dw_tag_t tag = die->Tag();
+
+ bool add_type = false;
+
+ switch (tag)
+ {
+ case DW_TAG_array_type: add_type = (type_mask & eTypeClassArray ) != 0; break;
+ case DW_TAG_unspecified_type:
+ case DW_TAG_base_type: add_type = (type_mask & eTypeClassBuiltin ) != 0; break;
+ case DW_TAG_class_type: add_type = (type_mask & eTypeClassClass ) != 0; break;
+ case DW_TAG_structure_type: add_type = (type_mask & eTypeClassStruct ) != 0; break;
+ case DW_TAG_union_type: add_type = (type_mask & eTypeClassUnion ) != 0; break;
+ case DW_TAG_enumeration_type: add_type = (type_mask & eTypeClassEnumeration ) != 0; break;
+ case DW_TAG_subroutine_type:
+ case DW_TAG_subprogram:
+ case DW_TAG_inlined_subroutine: add_type = (type_mask & eTypeClassFunction ) != 0; break;
+ case DW_TAG_pointer_type: add_type = (type_mask & eTypeClassPointer ) != 0; break;
+ case DW_TAG_rvalue_reference_type:
+ case DW_TAG_reference_type: add_type = (type_mask & eTypeClassReference ) != 0; break;
+ case DW_TAG_typedef: add_type = (type_mask & eTypeClassTypedef ) != 0; break;
+ case DW_TAG_ptr_to_member_type: add_type = (type_mask & eTypeClassMemberPointer ) != 0; break;
+ }
+
+ if (add_type)
+ {
+ const bool assert_not_being_parsed = true;
+ Type *type = ResolveTypeUID (cu, die, assert_not_being_parsed);
+ if (type)
+ {
+ if (type_set.find(type) == type_set.end())
+ type_set.insert(type);
+ }
+ }
+ }
+
+ for (const DWARFDebugInfoEntry *child_die = die->GetFirstChild();
+ child_die != NULL;
+ child_die = child_die->GetSibling())
+ {
+ GetTypes (cu, child_die, min_die_offset, max_die_offset, type_mask, type_set);
+ }
+ }
+ }
+}
+
+size_t
+SymbolFileDWARF::GetTypes (SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ TypeList &type_list)
+
+{
+ TypeSet type_set;
+
+ CompileUnit *comp_unit = NULL;
+ DWARFCompileUnit* dwarf_cu = NULL;
+ if (sc_scope)
+ comp_unit = sc_scope->CalculateSymbolContextCompileUnit();
+
+ if (comp_unit)
+ {
+ dwarf_cu = GetDWARFCompileUnit(comp_unit);
+ if (dwarf_cu == 0)
+ return 0;
+ GetTypes (dwarf_cu,
+ dwarf_cu->DIE(),
+ dwarf_cu->GetOffset(),
+ dwarf_cu->GetNextCompileUnitOffset(),
+ type_mask,
+ type_set);
+ }
+ else
+ {
+ DWARFDebugInfo* info = DebugInfo();
+ if (info)
+ {
+ const size_t num_cus = info->GetNumCompileUnits();
+ for (size_t cu_idx=0; cu_idx<num_cus; ++cu_idx)
+ {
+ dwarf_cu = info->GetCompileUnitAtIndex(cu_idx);
+ if (dwarf_cu)
+ {
+ GetTypes (dwarf_cu,
+ dwarf_cu->DIE(),
+ 0,
+ UINT32_MAX,
+ type_mask,
+ type_set);
+ }
+ }
+ }
+ }
+// if (m_using_apple_tables)
+// {
+// DWARFMappedHash::MemoryTable *apple_types = m_apple_types_ap.get();
+// if (apple_types)
+// {
+// apple_types->ForEach([this, &type_set, apple_types, type_mask](const DWARFMappedHash::DIEInfoArray &die_info_array) -> bool {
+//
+// for (auto die_info: die_info_array)
+// {
+// bool add_type = TagMatchesTypeMask (type_mask, 0);
+// if (!add_type)
+// {
+// dw_tag_t tag = die_info.tag;
+// if (tag == 0)
+// {
+// const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtr(die_info.offset, NULL);
+// tag = die->Tag();
+// }
+// add_type = TagMatchesTypeMask (type_mask, tag);
+// }
+// if (add_type)
+// {
+// Type *type = ResolveTypeUID(die_info.offset);
+//
+// if (type_set.find(type) == type_set.end())
+// type_set.insert(type);
+// }
+// }
+// return true; // Keep iterating
+// });
+// }
+// }
+// else
+// {
+// if (!m_indexed)
+// Index ();
+//
+// m_type_index.ForEach([this, &type_set, type_mask](const char *name, uint32_t die_offset) -> bool {
+//
+// bool add_type = TagMatchesTypeMask (type_mask, 0);
+//
+// if (!add_type)
+// {
+// const DWARFDebugInfoEntry *die = DebugInfo()->GetDIEPtr(die_offset, NULL);
+// if (die)
+// {
+// const dw_tag_t tag = die->Tag();
+// add_type = TagMatchesTypeMask (type_mask, tag);
+// }
+// }
+//
+// if (add_type)
+// {
+// Type *type = ResolveTypeUID(die_offset);
+//
+// if (type_set.find(type) == type_set.end())
+// type_set.insert(type);
+// }
+// return true; // Keep iterating
+// });
+// }
+
+ size_t num_types_added = 0;
+ for (Type *type : type_set)
+ {
+ type_list.Insert (type->shared_from_this());
+ ++num_types_added;
+ }
+ return num_types_added;
+}
+
//----------------------------------------------------------------------
// Gets the first parent that is a lexical block, function or inlined
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
index 87f86b80bbb..0370bc3f595 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
@@ -14,6 +14,7 @@
// C++ Includes
#include <list>
#include <map>
+#include <set>
#include <vector>
// Other libraries and framework includes
@@ -121,6 +122,10 @@ public:
virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types);
virtual lldb_private::TypeList *
GetTypeList ();
+ virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list);
+
virtual lldb_private::ClangASTContext &
GetClangASTContext ();
@@ -545,6 +550,16 @@ protected:
bool
FixupAddress (lldb_private::Address &addr);
+ typedef std::set<lldb_private::Type *> TypeSet;
+
+ void
+ GetTypes (DWARFCompileUnit* dwarf_cu,
+ const DWARFDebugInfoEntry *die,
+ dw_offset_t min_die_offset,
+ dw_offset_t max_die_offset,
+ uint32_t type_mask,
+ TypeSet &type_set);
+
lldb::ModuleWP m_debug_map_module_wp;
SymbolFileDWARFDebugMap * m_debug_map_symfile;
clang::TranslationUnitDecl * m_clang_tu_decl;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
index 61f95f355cf..8816b3ea925 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
@@ -1120,6 +1120,43 @@ SymbolFileDWARFDebugMap::FindFunctions (const RegularExpression& regex, bool inc
return sc_list.GetSize() - initial_size;
}
+size_t
+SymbolFileDWARFDebugMap::GetTypes (SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ TypeList &type_list)
+{
+ Timer scoped_timer (__PRETTY_FUNCTION__,
+ "SymbolFileDWARFDebugMap::GetTypes (type_mask = 0x%8.8x)",
+ type_mask);
+
+
+ uint32_t initial_size = type_list.GetSize();
+ SymbolFileDWARF *oso_dwarf = NULL;
+ if (sc_scope)
+ {
+ SymbolContext sc;
+ sc_scope->CalculateSymbolContext(&sc);
+
+ CompileUnitInfo *cu_info = GetCompUnitInfo (sc);
+ if (cu_info)
+ {
+ oso_dwarf = GetSymbolFileByCompUnitInfo (cu_info);
+ if (oso_dwarf)
+ oso_dwarf->GetTypes (sc_scope, type_mask, type_list);
+ }
+ }
+ else
+ {
+ uint32_t oso_idx = 0;
+ while ((oso_dwarf = GetSymbolFileByOSOIndex (oso_idx++)) != NULL)
+ {
+ oso_dwarf->GetTypes (sc_scope, type_mask, type_list);
+ }
+ }
+ return type_list.GetSize() - initial_size;
+}
+
+
TypeSP
SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext (const DWARFDeclContext &die_decl_ctx)
{
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
index 07f8e415c78..9db2a93f63a 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
@@ -85,9 +85,12 @@ public:
virtual uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool include_inlines, bool append, lldb_private::SymbolContextList& sc_list);
virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, lldb_private::TypeList& types);
virtual lldb_private::ClangNamespaceDecl
- FindNamespace (const lldb_private::SymbolContext& sc,
- const lldb_private::ConstString &name,
- const lldb_private::ClangNamespaceDecl *parent_namespace_decl);
+ FindNamespace (const lldb_private::SymbolContext& sc,
+ const lldb_private::ConstString &name,
+ const lldb_private::ClangNamespaceDecl *parent_namespace_decl);
+ virtual size_t GetTypes (lldb_private::SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list);
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
index 46460fe79d5..28078693b35 100644
--- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
+++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
@@ -60,6 +60,12 @@ SymbolFileSymtab::CreateInstance (ObjectFile* obj_file)
return new SymbolFileSymtab(obj_file);
}
+size_t
+SymbolFileSymtab::GetTypes (SymbolContextScope *sc_scope, uint32_t type_mask, lldb_private::TypeList &type_list)
+{
+ return 0;
+}
+
SymbolFileSymtab::SymbolFileSymtab(ObjectFile* obj_file) :
SymbolFile(obj_file),
m_source_indexes(),
diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
index ede3447ee99..99f0eb16c60 100644
--- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
+++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
@@ -102,8 +102,10 @@ public:
virtual uint32_t
FindTypes (const lldb_private::SymbolContext& sc,const lldb_private::ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, 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_private::TypeList& types);
+ virtual size_t
+ GetTypes (lldb_private::SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list);
virtual lldb_private::ClangNamespaceDecl
FindNamespace (const lldb_private::SymbolContext& sc,
diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp
index c39261903fa..7b49ab22fed 100644
--- a/lldb/source/Symbol/SymbolVendor.cpp
+++ b/lldb/source/Symbol/SymbolVendor.cpp
@@ -352,6 +352,21 @@ SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const
return 0;
}
+size_t
+SymbolVendor::GetTypes (SymbolContextScope *sc_scope,
+ uint32_t type_mask,
+ lldb_private::TypeList &type_list)
+{
+ ModuleSP module_sp(GetModule());
+ if (module_sp)
+ {
+ lldb_private::Mutex::Locker locker(module_sp->GetMutex());
+ if (m_sym_file_ap.get())
+ return m_sym_file_ap->GetTypes (sc_scope, type_mask, type_list);
+ }
+ return 0;
+}
+
ClangNamespaceDecl
SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *parent_namespace_decl)
{
diff --git a/lldb/source/Symbol/Type.cpp b/lldb/source/Symbol/Type.cpp
index 4d540c8dd1b..0646a40b5b4 100644
--- a/lldb/source/Symbol/Type.cpp
+++ b/lldb/source/Symbol/Type.cpp
@@ -33,6 +33,33 @@
using namespace lldb;
using namespace lldb_private;
+class TypeAppendVisitor
+{
+public:
+ TypeAppendVisitor(TypeListImpl &type_list) :
+ m_type_list(type_list)
+ {
+ }
+
+ bool
+ operator() (const lldb::TypeSP& type)
+ {
+ m_type_list.Append(TypeImplSP(new TypeImpl(type)));
+ return true;
+ }
+
+private:
+ TypeListImpl &m_type_list;
+};
+
+void
+TypeListImpl::Append (const lldb_private::TypeList &type_list)
+{
+ TypeAppendVisitor cb(*this);
+ type_list.ForEach(cb);
+}
+
+
Type *
SymbolFileType::GetType ()
{
diff --git a/lldb/source/Symbol/TypeList.cpp b/lldb/source/Symbol/TypeList.cpp
index 7c1d969b84e..df0723e48f2 100644
--- a/lldb/source/Symbol/TypeList.cpp
+++ b/lldb/source/Symbol/TypeList.cpp
@@ -135,6 +135,27 @@ TypeList::GetTypeAtIndex(uint32_t idx)
return TypeSP();
}
+void
+TypeList::ForEach (std::function <bool(const lldb::TypeSP &type_sp)> const &callback) const
+{
+ for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+ {
+ if (!callback(pos->second))
+ break;
+ }
+}
+
+void
+TypeList::ForEach (std::function <bool(lldb::TypeSP &type_sp)> const &callback)
+{
+ for (auto pos = m_types.begin(), end = m_types.end(); pos != end; ++pos)
+ {
+ if (!callback(pos->second))
+ break;
+ }
+}
+
+
bool
TypeList::RemoveTypeWithUID (user_id_t uid)
{
OpenPOWER on IntegriCloud