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.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@184251 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp
index f3a8417..9f74877 100644
--- a/source/API/SBCompileUnit.cpp
+++ b/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 @@
{
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 @@
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/source/API/SBModule.cpp b/source/API/SBModule.cpp
index 3938fa8..47540b6 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -561,6 +561,24 @@
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)