diff options
| -rw-r--r-- | lldb/include/lldb/Symbol/CompileUnit.h | 20 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/SymbolFile.h | 5 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/SymbolVendor.h | 5 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp | 20 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h | 7 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 21 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h | 2 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp | 3 | ||||
| -rw-r--r-- | lldb/source/Symbol/CompileUnit.cpp | 63 | ||||
| -rw-r--r-- | lldb/source/Symbol/SymbolVendor.cpp | 16 |
11 files changed, 113 insertions, 51 deletions
diff --git a/lldb/include/lldb/Symbol/CompileUnit.h b/lldb/include/lldb/Symbol/CompileUnit.h index 0c331c38f8c..2f596f89ec5 100644 --- a/lldb/include/lldb/Symbol/CompileUnit.h +++ b/lldb/include/lldb/Symbol/CompileUnit.h @@ -68,11 +68,16 @@ public: /// of this compile unit. /// /// @param[in] is_optimized - /// true if this compile unit was compiled with optimization. + /// A value that can initialized with eLazyBoolYes, eLazyBoolNo + /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then + /// an extra call into SymbolVendor will be made to calculate if + /// the compile unit is optimized will be made when + /// CompileUnit::GetIsOptimized() is called. /// /// @see lldb::LanguageType //------------------------------------------------------------------ - CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid, lldb::LanguageType language, bool is_optimized); + CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, lldb::user_id_t uid, + lldb::LanguageType language, lldb_private::LazyBool is_optimized); //------------------------------------------------------------------ /// Construct with a module, file spec, UID and language. @@ -103,11 +108,16 @@ public: /// of this compile unit. /// /// @param[in] is_optimized - /// true if this compile unit was compiled with optimization. + /// A value that can initialized with eLazyBoolYes, eLazyBoolNo + /// or eLazyBoolCalculate. If set to eLazyBoolCalculate, then + /// an extra call into SymbolVendor will be made to calculate if + /// the compile unit is optimized will be made when + /// CompileUnit::GetIsOptimized() is called. /// /// @see lldb::LanguageType //------------------------------------------------------------------ - CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid, lldb::LanguageType language, bool is_optimized); + CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &file_spec, lldb::user_id_t uid, + lldb::LanguageType language, lldb_private::LazyBool is_optimized); //------------------------------------------------------------------ /// Destructor @@ -446,7 +456,7 @@ protected: std::unique_ptr<LineTable> m_line_table_ap; ///< Line table that will get parsed on demand. DebugMacrosSP m_debug_macros_sp; ///< Debug macros that will get parsed on demand. lldb::VariableListSP m_variables; ///< Global and static variable list that will get parsed on demand. - bool m_is_optimized; /// eLazyBoolYes if this compile unit was compiled with optimization. + lldb_private::LazyBool m_is_optimized; /// eLazyBoolYes if this compile unit was compiled with optimization. private: enum diff --git a/lldb/include/lldb/Symbol/SymbolFile.h b/lldb/include/lldb/Symbol/SymbolFile.h index b555ecd4d13..db97ab4f9b6 100644 --- a/lldb/include/lldb/Symbol/SymbolFile.h +++ b/lldb/include/lldb/Symbol/SymbolFile.h @@ -127,6 +127,11 @@ public: virtual bool ParseCompileUnitLineTable (const SymbolContext& sc) = 0; virtual bool ParseCompileUnitDebugMacros (const SymbolContext& sc) = 0; virtual bool ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files) = 0; + virtual bool + ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) + { + return false; + } virtual bool ParseImportedModules (const SymbolContext &sc, std::vector<ConstString> &imported_modules) = 0; virtual size_t ParseFunctionBlocks (const SymbolContext& sc) = 0; virtual size_t ParseTypes (const SymbolContext& sc) = 0; diff --git a/lldb/include/lldb/Symbol/SymbolVendor.h b/lldb/include/lldb/Symbol/SymbolVendor.h index dbea8c96573..e992c5cde60 100644 --- a/lldb/include/lldb/Symbol/SymbolVendor.h +++ b/lldb/include/lldb/Symbol/SymbolVendor.h @@ -68,7 +68,10 @@ public: virtual bool ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files); - + + virtual bool + ParseCompileUnitIsOptimized(const SymbolContext &sc); + virtual bool ParseImportedModules (const SymbolContext &sc, std::vector<ConstString> &imported_modules); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index e0a5973f854..942a5d62d9b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -915,12 +915,8 @@ SymbolFileDWARF::ParseCompileUnit (DWARFCompileUnit* dwarf_cu, uint32_t cu_idx) LanguageType cu_language = DWARFCompileUnit::LanguageTypeFromDWARF(cu_die.GetAttributeValueAsUnsigned(DW_AT_language, 0)); bool is_optimized = dwarf_cu->GetIsOptimized (); - cu_sp.reset(new CompileUnit (module_sp, - dwarf_cu, - cu_file_spec, - dwarf_cu->GetID(), - cu_language, - is_optimized)); + cu_sp.reset(new CompileUnit(module_sp, dwarf_cu, cu_file_spec, dwarf_cu->GetID(), cu_language, + is_optimized ? eLazyBoolYes : eLazyBoolNo)); if (cu_sp) { // If we just created a compile unit with an invalid file spec, try and get the @@ -1070,7 +1066,17 @@ SymbolFileDWARF::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpec } bool -SymbolFileDWARF::ParseImportedModules (const lldb_private::SymbolContext &sc, std::vector<lldb_private::ConstString> &imported_modules) +SymbolFileDWARF::ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) +{ + DWARFCompileUnit *dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); + if (dwarf_cu) + return dwarf_cu->GetIsOptimized(); + return false; +} + +bool +SymbolFileDWARF::ParseImportedModules(const lldb_private::SymbolContext &sc, + std::vector<lldb_private::ConstString> &imported_modules) { assert (sc.comp_unit); DWARFCompileUnit* dwarf_cu = GetDWARFCompileUnit(sc.comp_unit); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index ae331978edf..865e5896270 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -137,8 +137,11 @@ public: lldb_private::FileSpecList& support_files) override; bool - ParseImportedModules (const lldb_private::SymbolContext &sc, - std::vector<lldb_private::ConstString> &imported_modules) override; + ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) override; + + bool + ParseImportedModules(const lldb_private::SymbolContext &sc, + std::vector<lldb_private::ConstString> &imported_modules) override; size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc) override; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 2cf497c9529..ca819624c71 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -637,13 +637,9 @@ SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) // zero in each .o file since each .o file can only have // one compile unit for now. lldb::user_id_t cu_id = 0; - m_compile_unit_infos[cu_idx].compile_unit_sp.reset(new CompileUnit (m_obj_file->GetModule(), - NULL, - so_file_spec, - cu_id, - eLanguageTypeUnknown, - false)); - + m_compile_unit_infos[cu_idx].compile_unit_sp.reset(new CompileUnit( + m_obj_file->GetModule(), NULL, so_file_spec, cu_id, eLanguageTypeUnknown, eLazyBoolCalculate)); + if (m_compile_unit_infos[cu_idx].compile_unit_sp) { // Let our symbol vendor know about this compile unit @@ -727,7 +723,16 @@ SymbolFileDWARFDebugMap::ParseCompileUnitSupportFiles (const SymbolContext& sc, } bool -SymbolFileDWARFDebugMap::ParseImportedModules (const SymbolContext &sc, std::vector<ConstString> &imported_modules) +SymbolFileDWARFDebugMap::ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) +{ + SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); + if (oso_dwarf) + return oso_dwarf->ParseCompileUnitIsOptimized(sc); + return false; +} + +bool +SymbolFileDWARFDebugMap::ParseImportedModules(const SymbolContext &sc, std::vector<ConstString> &imported_modules) { SymbolFileDWARF *oso_dwarf = GetSymbolFile (sc); if (oso_dwarf) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 544f0dab043..fcf02975a58 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -65,6 +65,8 @@ public: bool ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc) override; bool ParseCompileUnitDebugMacros (const lldb_private::SymbolContext& sc) override; bool ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, lldb_private::FileSpecList &support_files) override; + bool + ParseCompileUnitIsOptimized(const lldb_private::SymbolContext &sc) override; bool ParseImportedModules (const lldb_private::SymbolContext &sc, std::vector<lldb_private::ConstString> &imported_modules) override; size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc) override; size_t ParseTypes (const lldb_private::SymbolContext& sc) override; diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp index 8bdb3eacecb..d8092c011ac 100644 --- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp @@ -614,7 +614,7 @@ SymbolFilePDB::ParseCompileUnitForSymIndex(uint32_t id) lang = TranslateLanguage(details->getLanguage()); // Don't support optimized code for now, DebugInfoPDB does not return this information. - bool optimized = false; + LazyBool optimized = eLazyBoolNo; auto result = std::make_shared<CompileUnit>(m_obj_file->GetModule(), nullptr, path.c_str(), id, lang, optimized); m_comp_units.insert(std::make_pair(id, result)); return result; diff --git a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp index d3dd1ae923e..24175079c95 100644 --- a/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp +++ b/lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp @@ -153,7 +153,8 @@ SymbolFileSymtab::ParseCompileUnitAtIndex(uint32_t idx) { const Symbol *cu_symbol = m_obj_file->GetSymtab()->SymbolAtIndex(m_source_indexes[idx]); if (cu_symbol) - cu_sp.reset(new CompileUnit (m_obj_file->GetModule(), NULL, cu_symbol->GetName().AsCString(), 0, eLanguageTypeUnknown, false)); + cu_sp.reset(new CompileUnit(m_obj_file->GetModule(), NULL, cu_symbol->GetName().AsCString(), 0, + eLanguageTypeUnknown, eLazyBoolNo)); } return cu_sp; } diff --git a/lldb/source/Symbol/CompileUnit.cpp b/lldb/source/Symbol/CompileUnit.cpp index 50eda880637..259a450b716 100644 --- a/lldb/source/Symbol/CompileUnit.cpp +++ b/lldb/source/Symbol/CompileUnit.cpp @@ -17,36 +17,40 @@ using namespace lldb; using namespace lldb_private; -CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, bool is_optimized) : - ModuleChild(module_sp), - FileSpec (pathname, false), - UserID(cu_sym_id), - m_user_data (user_data), - m_language (language), - m_flags (0), - m_functions (), - m_support_files (), - m_line_table_ap (), - m_variables(), - m_is_optimized (is_optimized) +CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, + const lldb::user_id_t cu_sym_id, lldb::LanguageType language, + lldb_private::LazyBool is_optimized) + : ModuleChild(module_sp), + FileSpec(pathname, false), + UserID(cu_sym_id), + m_user_data(user_data), + m_language(language), + m_flags(0), + m_functions(), + m_support_files(), + m_line_table_ap(), + m_variables(), + m_is_optimized(is_optimized) { if (language != eLanguageTypeUnknown) m_flags.Set(flagsParsedLanguage); assert(module_sp); } -CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec, const lldb::user_id_t cu_sym_id, lldb::LanguageType language, bool is_optimized) : - ModuleChild(module_sp), - FileSpec (fspec), - UserID(cu_sym_id), - m_user_data (user_data), - m_language (language), - m_flags (0), - m_functions (), - m_support_files (), - m_line_table_ap (), - m_variables(), - m_is_optimized (is_optimized) +CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec, + const lldb::user_id_t cu_sym_id, lldb::LanguageType language, + lldb_private::LazyBool is_optimized) + : ModuleChild(module_sp), + FileSpec(fspec), + UserID(cu_sym_id), + m_user_data(user_data), + m_language(language), + m_flags(0), + m_functions(), + m_support_files(), + m_line_table_ap(), + m_variables(), + m_is_optimized(is_optimized) { if (language != eLanguageTypeUnknown) m_flags.Set(flagsParsedLanguage); @@ -468,6 +472,17 @@ CompileUnit::ResolveSymbolContext bool CompileUnit::GetIsOptimized () { + if (m_is_optimized == eLazyBoolCalculate) + { + m_is_optimized = eLazyBoolNo; + if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor()) + { + SymbolContext sc; + CalculateSymbolContext(&sc); + if (symbol_vendor->ParseCompileUnitIsOptimized(sc)) + m_is_optimized = eLazyBoolYes; + } + } return m_is_optimized; } diff --git a/lldb/source/Symbol/SymbolVendor.cpp b/lldb/source/Symbol/SymbolVendor.cpp index f168f016910..c569943b346 100644 --- a/lldb/source/Symbol/SymbolVendor.cpp +++ b/lldb/source/Symbol/SymbolVendor.cpp @@ -211,8 +211,20 @@ SymbolVendor::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecLis } bool -SymbolVendor::ParseImportedModules (const SymbolContext &sc, - std::vector<ConstString> &imported_modules) +SymbolVendor::ParseCompileUnitIsOptimized(const SymbolContext &sc) +{ + ModuleSP module_sp(GetModule()); + if (module_sp) + { + std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex()); + if (m_sym_file_ap.get()) + return m_sym_file_ap->ParseCompileUnitIsOptimized(sc); + } + return false; +} + +bool +SymbolVendor::ParseImportedModules(const SymbolContext &sc, std::vector<ConstString> &imported_modules) { ModuleSP module_sp(GetModule()); if (module_sp) |

