forked from OSchip/llvm-project
Added the ability to get a list of types from a SBModule or SBCompileUnit. Sebastien Metrot wanted this, and sent a hollowed out patch. I filled in the blanks and did the low level implementation. The new functions are:
//------------------------------------------------------------------ /// 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 SBModule::GetTypes (uint32_t type_mask) //------------------------------------------------------------------ /// 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 SBCompileUnit::GetTypes (uint32_t type_mask = lldb::eTypeClassAny); This lets you request types by filling out a mask that contains one or more bits from the lldb::TypeClass enumerations, so you can only get the types you really want. llvm-svn: 184251
This commit is contained in:
parent
5f508953bc
commit
f02500c74c
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
|
|
@ -235,6 +235,8 @@ public:
|
|||
|
||||
private:
|
||||
std::unique_ptr<lldb_private::TypeListImpl> m_opaque_ap;
|
||||
friend class SBModule;
|
||||
friend class SBCompileUnit;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -225,6 +225,25 @@ public:
|
|||
lldb::SBType
|
||||
GetBasicType(lldb::BasicType type);
|
||||
|
||||
%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.
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 ()
|
||||
{
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue