Patch from dawn@burble.org:
GetSupportFileAtIndex(), GetNumSupportFiles(), FindSupportFileIndex():
Add API support for getting the list of files in a compilation unit.
GetNumCompileUnits(), GetCompileUnitAtIndex():
Add API support for retrieving the compilation units in a module.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@152942 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBCompileUnit.cpp b/source/API/SBCompileUnit.cpp
index b1bb447..7852fc8 100644
--- a/source/API/SBCompileUnit.cpp
+++ b/source/API/SBCompileUnit.cpp
@@ -143,6 +143,52 @@
return index;
}
+uint32_t
+SBCompileUnit::GetNumSupportFiles () const
+{
+ if (m_opaque_ptr)
+ {
+ FileSpecList& support_files = m_opaque_ptr->GetSupportFiles ();
+ return support_files.GetSize();
+ }
+ return 0;
+}
+
+SBFileSpec
+SBCompileUnit::GetSupportFileAtIndex (uint32_t idx) const
+{
+ LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+ 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);
+ }
+
+ if (log)
+ {
+ SBStream sstr;
+ sb_file_spec.GetDescription (sstr);
+ log->Printf ("SBCompileUnit(%p)::GetGetFileSpecAtIndex (idx=%u) => SBFileSpec(%p): '%s'",
+ m_opaque_ptr, idx, sb_file_spec.get(), sstr.GetData());
+ }
+
+ return sb_file_spec;
+}
+
+uint32_t
+SBCompileUnit::FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full)
+{
+ if (m_opaque_ptr)
+ {
+ FileSpecList &support_files = m_opaque_ptr->GetSupportFiles ();
+ return support_files.FindFileIndex(start_idx, sb_file.ref(), full);
+ }
+ return 0;
+}
+
bool
SBCompileUnit::IsValid () const
{
diff --git a/source/API/SBModule.cpp b/source/API/SBModule.cpp
index c23a35e..3090fb4 100644
--- a/source/API/SBModule.cpp
+++ b/source/API/SBModule.cpp
@@ -266,6 +266,30 @@
return true;
}
+uint32_t
+SBModule::GetNumCompileUnits()
+{
+ ModuleSP module_sp (GetSP ());
+ if (module_sp)
+ {
+ return module_sp->GetNumCompileUnits ();
+ }
+ return 0;
+}
+
+SBCompileUnit
+SBModule::GetCompileUnitAtIndex (uint32_t index)
+{
+ SBCompileUnit sb_cu;
+ ModuleSP module_sp (GetSP ());
+ if (module_sp)
+ {
+ CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex (index);
+ sb_cu.reset(cu_sp.get());
+ }
+ return sb_cu;
+}
+
size_t
SBModule::GetNumSymbols ()
{