Skip to content
This repository was archived by the owner on May 21, 2019. It is now read-only.

Commit b451f5f

Browse files
author
Johnny Chen
committedMar 16, 2012
Patch from [email protected]:
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
1 parent e1219bf commit b451f5f

File tree

4 files changed

+86
-0
lines changed

4 files changed

+86
-0
lines changed
 

‎include/lldb/API/SBCompileUnit.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ class SBCompileUnit
5151
lldb::SBFileSpec *inline_file_spec,
5252
bool exact) const;
5353

54+
SBFileSpec
55+
GetSupportFileAtIndex (uint32_t idx) const;
56+
57+
uint32_t
58+
GetNumSupportFiles () const;
59+
60+
uint32_t
61+
FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full);
62+
5463
bool
5564
operator == (const lldb::SBCompileUnit &rhs) const;
5665

@@ -64,6 +73,7 @@ class SBCompileUnit
6473
friend class SBAddress;
6574
friend class SBFrame;
6675
friend class SBSymbolContext;
76+
friend class SBModule;
6777

6878
SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr);
6979

‎include/lldb/API/SBModule.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ class SBModule
108108
bool
109109
GetDescription (lldb::SBStream &description);
110110

111+
uint32_t
112+
GetNumCompileUnits();
113+
114+
lldb::SBCompileUnit
115+
GetCompileUnitAtIndex (uint32_t);
116+
111117
size_t
112118
GetNumSymbols ();
113119

‎source/API/SBCompileUnit.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,52 @@ SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec
143143
return index;
144144
}
145145

146+
uint32_t
147+
SBCompileUnit::GetNumSupportFiles () const
148+
{
149+
if (m_opaque_ptr)
150+
{
151+
FileSpecList& support_files = m_opaque_ptr->GetSupportFiles ();
152+
return support_files.GetSize();
153+
}
154+
return 0;
155+
}
156+
157+
SBFileSpec
158+
SBCompileUnit::GetSupportFileAtIndex (uint32_t idx) const
159+
{
160+
LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
161+
162+
SBFileSpec sb_file_spec;
163+
if (m_opaque_ptr)
164+
{
165+
FileSpecList &support_files = m_opaque_ptr->GetSupportFiles ();
166+
FileSpec file_spec = support_files.GetFileSpecAtIndex(idx);
167+
sb_file_spec.SetFileSpec(file_spec);
168+
}
169+
170+
if (log)
171+
{
172+
SBStream sstr;
173+
sb_file_spec.GetDescription (sstr);
174+
log->Printf ("SBCompileUnit(%p)::GetGetFileSpecAtIndex (idx=%u) => SBFileSpec(%p): '%s'",
175+
m_opaque_ptr, idx, sb_file_spec.get(), sstr.GetData());
176+
}
177+
178+
return sb_file_spec;
179+
}
180+
181+
uint32_t
182+
SBCompileUnit::FindSupportFileIndex (uint32_t start_idx, const SBFileSpec &sb_file, bool full)
183+
{
184+
if (m_opaque_ptr)
185+
{
186+
FileSpecList &support_files = m_opaque_ptr->GetSupportFiles ();
187+
return support_files.FindFileIndex(start_idx, sb_file.ref(), full);
188+
}
189+
return 0;
190+
}
191+
146192
bool
147193
SBCompileUnit::IsValid () const
148194
{

‎source/API/SBModule.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,30 @@ SBModule::GetDescription (SBStream &description)
266266
return true;
267267
}
268268

269+
uint32_t
270+
SBModule::GetNumCompileUnits()
271+
{
272+
ModuleSP module_sp (GetSP ());
273+
if (module_sp)
274+
{
275+
return module_sp->GetNumCompileUnits ();
276+
}
277+
return 0;
278+
}
279+
280+
SBCompileUnit
281+
SBModule::GetCompileUnitAtIndex (uint32_t index)
282+
{
283+
SBCompileUnit sb_cu;
284+
ModuleSP module_sp (GetSP ());
285+
if (module_sp)
286+
{
287+
CompUnitSP cu_sp = module_sp->GetCompileUnitAtIndex (index);
288+
sb_cu.reset(cu_sp.get());
289+
}
290+
return sb_cu;
291+
}
292+
269293
size_t
270294
SBModule::GetNumSymbols ()
271295
{

0 commit comments

Comments
 (0)