File tree Expand file tree Collapse file tree 5 files changed +54
-0
lines changed
source/Plugins/SymbolFile/DWARF Expand file tree Collapse file tree 5 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 3030
3131#include < mutex>
3232#include < optional>
33+ #include < unordered_map>
3334
3435#if defined(LLDB_CONFIGURATION_DEBUG)
3536#define ASSERT_MODULE_LOCK (expr ) (expr->AssertModuleLock ())
@@ -435,9 +436,20 @@ class SymbolFile : public PluginInterface {
435436
436437 virtual lldb::TypeSP CopyType (const lldb::TypeSP &other_type) = 0;
437438
439+ // / Returns a map of compilation unit to the compile option arguments
440+ // / associated with that compilation unit.
441+ std::unordered_map<lldb::CompUnitSP, Args> GetCompileOptions () {
442+ std::unordered_map<lldb::CompUnitSP, Args> args;
443+ GetCompileOptions (args);
444+ return args;
445+ }
446+
438447protected:
439448 void AssertModuleLock ();
440449
450+ virtual void GetCompileOptions (
451+ std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {}
452+
441453private:
442454 SymbolFile (const SymbolFile &) = delete ;
443455 const SymbolFile &operator =(const SymbolFile &) = delete ;
Original file line number Diff line number Diff line change @@ -4255,3 +4255,30 @@ Status SymbolFileDWARF::CalculateFrameVariableError(StackFrame &frame) {
42554255 return Status (" no variable information is available in debug info for this "
42564256 " compile unit" );
42574257}
4258+
4259+ void SymbolFileDWARF::GetCompileOptions (
4260+ std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {
4261+
4262+ const uint32_t num_compile_units = GetNumCompileUnits ();
4263+
4264+ for (uint32_t cu_idx = 0 ; cu_idx < num_compile_units; ++cu_idx) {
4265+ lldb::CompUnitSP comp_unit = GetCompileUnitAtIndex (cu_idx);
4266+ if (!comp_unit)
4267+ continue ;
4268+
4269+ DWARFUnit *dwarf_cu = GetDWARFCompileUnit (comp_unit.get ());
4270+ if (!dwarf_cu)
4271+ continue ;
4272+
4273+ const DWARFBaseDIE die = dwarf_cu->GetUnitDIEOnly ();
4274+ if (!die)
4275+ continue ;
4276+
4277+ const char *flags = die.GetAttributeValueAsString (DW_AT_APPLE_flags, NULL );
4278+
4279+ if (!flags)
4280+ continue ;
4281+ args.insert ({comp_unit, Args (flags)});
4282+ }
4283+ }
4284+
Original file line number Diff line number Diff line change @@ -523,6 +523,9 @@ class SymbolFileDWARF : public lldb_private::SymbolFileCommon {
523523
524524 void InitializeFirstCodeAddress ();
525525
526+ void GetCompileOptions (
527+ std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) override ;
528+
526529 lldb::ModuleWP m_debug_map_module_wp;
527530 SymbolFileDWARFDebugMap *m_debug_map_symfile;
528531
Original file line number Diff line number Diff line change @@ -1549,3 +1549,12 @@ Status SymbolFileDWARFDebugMap::CalculateFrameVariableError(StackFrame &frame) {
15491549 }
15501550 return Status ();
15511551}
1552+
1553+ void SymbolFileDWARFDebugMap::GetCompileOptions (
1554+ std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {
1555+
1556+ ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) -> bool {
1557+ oso_dwarf->GetCompileOptions (args);
1558+ return false ;
1559+ });
1560+ }
Original file line number Diff line number Diff line change @@ -153,6 +153,9 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFileCommon {
153153 // Statistics overrides.
154154 lldb_private::ModuleList GetDebugInfoModules () override ;
155155
156+ void GetCompileOptions (
157+ std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) override ;
158+
156159protected:
157160 enum { kHaveInitializedOSOs = (1 << 0 ), kNumFlags };
158161
You can’t perform that action at this time.
0 commit comments