diff options
Diffstat (limited to 'source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp')
-rw-r--r-- | source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp | 182 |
1 files changed, 99 insertions, 83 deletions
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index 39c70d146524..2c1e6416a935 100644 --- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -7,10 +7,6 @@ // //===----------------------------------------------------------------------===// -// C Includes -// C++ Includes -// Other libraries and framework includes -// Project includes #include "SymbolFileDWARFDebugMap.h" #include "DWARFDebugAranges.h" @@ -90,11 +86,10 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap( const uint32_t oso_end_idx = comp_unit_info->last_symbol_index + 1; for (uint32_t idx = comp_unit_info->first_symbol_index + 2; // Skip the N_SO and N_OSO - idx < oso_end_idx; - ++idx) { + idx < oso_end_idx; ++idx) { Symbol *exe_symbol = exe_symtab->SymbolAtIndex(idx); if (exe_symbol) { - if (exe_symbol->IsDebug() == false) + if (!exe_symbol->IsDebug()) continue; switch (exe_symbol->GetType()) { @@ -184,7 +179,7 @@ public: GetSymbolVendor(bool can_create = true, lldb_private::Stream *feedback_strm = NULL) override { // Scope for locker - if (m_symfile_ap.get() || can_create == false) + if (m_symfile_ap.get() || !can_create) return m_symfile_ap.get(); ModuleSP exe_module_sp(m_exe_module_wp.lock()); @@ -351,7 +346,7 @@ void SymbolFileDWARFDebugMap::InitOSO() { so_symbol->GetType() == eSymbolTypeSourceFile && oso_symbol->GetType() == eSymbolTypeObjectFile) { m_compile_unit_infos[i].so_file.SetFile( - so_symbol->GetName().AsCString(), false, FileSpec::Style::native); + so_symbol->GetName().AsCString(), FileSpec::Style::native); m_compile_unit_infos[i].oso_path = oso_symbol->GetName(); m_compile_unit_infos[i].oso_mod_time = llvm::sys::toTimePoint(oso_symbol->GetIntegerValue(0)); @@ -421,10 +416,13 @@ Module *SymbolFileDWARFDebugMap::GetModuleByCompUnitInfo( m_oso_map[{comp_unit_info->oso_path, comp_unit_info->oso_mod_time}] = comp_unit_info->oso_sp; const char *oso_path = comp_unit_info->oso_path.GetCString(); - FileSpec oso_file(oso_path, false); + FileSpec oso_file(oso_path); ConstString oso_object; - if (oso_file.Exists()) { - auto oso_mod_time = FileSystem::GetModificationTime(oso_file); + if (FileSystem::Instance().Exists(oso_file)) { + // The modification time returned by the FS can have a higher precision + // than the one from the CU. + auto oso_mod_time = std::chrono::time_point_cast<std::chrono::seconds>( + FileSystem::Instance().GetModificationTime(oso_file)); if (oso_mod_time != comp_unit_info->oso_mod_time) { obj_file->GetModule()->ReportError( "debug map object file '%s' has changed (actual time is " @@ -490,7 +488,12 @@ ObjectFile *SymbolFileDWARFDebugMap::GetObjectFileByOSOIndex(uint32_t oso_idx) { SymbolFileDWARF * SymbolFileDWARFDebugMap::GetSymbolFile(const SymbolContext &sc) { - CompileUnitInfo *comp_unit_info = GetCompUnitInfo(sc); + return GetSymbolFile(*sc.comp_unit); +} + +SymbolFileDWARF * +SymbolFileDWARFDebugMap::GetSymbolFile(const CompileUnit &comp_unit) { + CompileUnitInfo *comp_unit_info = GetCompUnitInfo(comp_unit); if (comp_unit_info) return GetSymbolFileByCompUnitInfo(comp_unit_info); return NULL; @@ -518,7 +521,8 @@ uint32_t SymbolFileDWARFDebugMap::GetCompUnitInfoIndex( SymbolFileDWARF * SymbolFileDWARFDebugMap::GetSymbolFileByOSOIndex(uint32_t oso_idx) { - if (oso_idx < m_compile_unit_infos.size()) + unsigned size = m_compile_unit_infos.size(); + if (oso_idx < size) return GetSymbolFileByCompUnitInfo(&m_compile_unit_infos[oso_idx]); return NULL; } @@ -597,9 +601,14 @@ CompUnitSP SymbolFileDWARFDebugMap::ParseCompileUnitAtIndex(uint32_t cu_idx) { SymbolFileDWARFDebugMap::CompileUnitInfo * SymbolFileDWARFDebugMap::GetCompUnitInfo(const SymbolContext &sc) { + return GetCompUnitInfo(*sc.comp_unit); +} + +SymbolFileDWARFDebugMap::CompileUnitInfo * +SymbolFileDWARFDebugMap::GetCompUnitInfo(const CompileUnit &comp_unit) { const uint32_t cu_count = GetNumCompileUnits(); for (uint32_t i = 0; i < cu_count; ++i) { - if (sc.comp_unit == m_compile_unit_infos[i].compile_unit_sp.get()) + if (comp_unit == m_compile_unit_infos[i].compile_unit_sp.get()) return &m_compile_unit_infos[i]; } return NULL; @@ -617,50 +626,46 @@ size_t SymbolFileDWARFDebugMap::GetCompUnitInfosForModule( } lldb::LanguageType -SymbolFileDWARFDebugMap::ParseCompileUnitLanguage(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +SymbolFileDWARFDebugMap::ParseLanguage(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitLanguage(sc); + return oso_dwarf->ParseLanguage(comp_unit); return eLanguageTypeUnknown; } -size_t -SymbolFileDWARFDebugMap::ParseCompileUnitFunctions(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +size_t SymbolFileDWARFDebugMap::ParseFunctions(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitFunctions(sc); + return oso_dwarf->ParseFunctions(comp_unit); return 0; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitLineTable( - const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseLineTable(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitLineTable(sc); + return oso_dwarf->ParseLineTable(comp_unit); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitDebugMacros( - const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitDebugMacros(sc); + return oso_dwarf->ParseDebugMacros(comp_unit); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitSupportFiles( - const SymbolContext &sc, FileSpecList &support_files) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseSupportFiles(CompileUnit &comp_unit, + FileSpecList &support_files) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitSupportFiles(sc, support_files); + return oso_dwarf->ParseSupportFiles(comp_unit, support_files); return false; } -bool SymbolFileDWARFDebugMap::ParseCompileUnitIsOptimized( - const lldb_private::SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +bool SymbolFileDWARFDebugMap::ParseIsOptimized(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseCompileUnitIsOptimized(sc); + return oso_dwarf->ParseIsOptimized(comp_unit); return false; } @@ -672,17 +677,21 @@ bool SymbolFileDWARFDebugMap::ParseImportedModules( return false; } -size_t SymbolFileDWARFDebugMap::ParseFunctionBlocks(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +size_t SymbolFileDWARFDebugMap::ParseBlocksRecursive(Function &func) { + CompileUnit *comp_unit = func.GetCompileUnit(); + if (!comp_unit) + return 0; + + SymbolFileDWARF *oso_dwarf = GetSymbolFile(*comp_unit); if (oso_dwarf) - return oso_dwarf->ParseFunctionBlocks(sc); + return oso_dwarf->ParseBlocksRecursive(func); return 0; } -size_t SymbolFileDWARFDebugMap::ParseTypes(const SymbolContext &sc) { - SymbolFileDWARF *oso_dwarf = GetSymbolFile(sc); +size_t SymbolFileDWARFDebugMap::ParseTypes(CompileUnit &comp_unit) { + SymbolFileDWARF *oso_dwarf = GetSymbolFile(comp_unit); if (oso_dwarf) - return oso_dwarf->ParseTypes(sc); + return oso_dwarf->ParseTypes(comp_unit); return 0; } @@ -702,6 +711,16 @@ Type *SymbolFileDWARFDebugMap::ResolveTypeUID(lldb::user_id_t type_uid) { return NULL; } +llvm::Optional<SymbolFile::ArrayInfo> +SymbolFileDWARFDebugMap::GetDynamicArrayInfoForUID( + lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) { + const uint64_t oso_idx = GetOSOIndexFromUserID(type_uid); + SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx); + if (oso_dwarf) + return oso_dwarf->GetDynamicArrayInfoForUID(type_uid, exe_ctx); + return llvm::None; +} + bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) { bool success = false; if (compiler_type) { @@ -717,8 +736,10 @@ bool SymbolFileDWARFDebugMap::CompleteType(CompilerType &compiler_type) { return success; } -uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( - const Address &exe_so_addr, uint32_t resolve_scope, SymbolContext &sc) { +uint32_t +SymbolFileDWARFDebugMap::ResolveSymbolContext(const Address &exe_so_addr, + SymbolContextItem resolve_scope, + SymbolContext &sc) { uint32_t resolved_flags = 0; Symtab *symtab = m_obj_file->GetSymtab(); if (symtab) { @@ -760,7 +781,7 @@ uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( uint32_t SymbolFileDWARFDebugMap::ResolveSymbolContext( const FileSpec &file_spec, uint32_t line, bool check_inlines, - uint32_t resolve_scope, SymbolContextList &sc_list) { + SymbolContextItem resolve_scope, SymbolContextList &sc_list) { const uint32_t initial = sc_list.GetSize(); const uint32_t cu_count = GetNumCompileUnits(); @@ -792,8 +813,7 @@ uint32_t SymbolFileDWARFDebugMap::PrivateFindGlobalVariables( const ConstString &name, const CompilerDeclContext *parent_decl_ctx, const std::vector<uint32_t> &indexes, // Indexes into the symbol table that match "name" - uint32_t max_matches, - VariableList &variables) { + uint32_t max_matches, VariableList &variables) { const uint32_t original_size = variables.GetSize(); const size_t match_count = indexes.size(); for (size_t i = 0; i < match_count; ++i) { @@ -977,7 +997,7 @@ static void RemoveFunctionsWithModuleNotEqualTo(const ModuleSP &module_sp, uint32_t SymbolFileDWARFDebugMap::FindFunctions( const ConstString &name, const CompilerDeclContext *parent_decl_ctx, - uint32_t name_type_mask, bool include_inlines, bool append, + FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, @@ -1032,7 +1052,7 @@ uint32_t SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex, } size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, - uint32_t type_mask, + lldb::TypeClass type_mask, TypeList &type_list) { static Timer::Category func_cat(LLVM_PRETTY_FUNCTION); Timer scoped_timer(func_cat, @@ -1060,6 +1080,15 @@ size_t SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope, return type_list.GetSize() - initial_size; } +std::vector<lldb_private::CallEdge> +SymbolFileDWARFDebugMap::ParseCallEdgesInFunction(UserID func_id) { + uint32_t oso_idx = GetOSOIndexFromUserID(func_id.GetID()); + SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex(oso_idx); + if (oso_dwarf) + return oso_dwarf->ParseCallEdgesInFunction(func_id); + return {}; +} + TypeSP SymbolFileDWARFDebugMap::FindDefinitionTypeForDWARFDeclContext( const DWARFDeclContext &die_decl_ctx) { TypeSP type_sp; @@ -1136,7 +1165,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE( // Only search all .o files for the definition if we don't need the // implementation because otherwise, with a valid debug map we should have // the ObjC class symbol and the code above should have found it. - if (must_be_implementation == false) { + if (!must_be_implementation) { TypeSP type_sp; ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { @@ -1151,32 +1180,20 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE( } uint32_t SymbolFileDWARFDebugMap::FindTypes( - const SymbolContext &sc, const ConstString &name, - const CompilerDeclContext *parent_decl_ctx, bool append, - uint32_t max_matches, + const ConstString &name, const CompilerDeclContext *parent_decl_ctx, + bool append, uint32_t max_matches, llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types) { if (!append) types.Clear(); const uint32_t initial_types_size = types.GetSize(); - SymbolFileDWARF *oso_dwarf; - if (sc.comp_unit) { - oso_dwarf = GetSymbolFile(sc); - if (oso_dwarf) - return oso_dwarf->FindTypes(sc, name, parent_decl_ctx, append, - max_matches, searched_symbol_files, types); - } else { - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - oso_dwarf->FindTypes(sc, name, parent_decl_ctx, append, max_matches, - searched_symbol_files, types); - if (types.GetSize() >= max_matches) - return true; - else - return false; - }); - } + ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { + oso_dwarf->FindTypes(name, parent_decl_ctx, append, max_matches, + searched_symbol_files, types); + return types.GetSize() >= max_matches; + }); return types.GetSize() - initial_types_size; } @@ -1195,27 +1212,26 @@ uint32_t SymbolFileDWARFDebugMap::FindTypes( //} CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace( - const lldb_private::SymbolContext &sc, const lldb_private::ConstString &name, const CompilerDeclContext *parent_decl_ctx) { CompilerDeclContext matching_namespace; - SymbolFileDWARF *oso_dwarf; - if (sc.comp_unit) { - oso_dwarf = GetSymbolFile(sc); - if (oso_dwarf) - matching_namespace = oso_dwarf->FindNamespace(sc, name, parent_decl_ctx); - } else { - ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { - matching_namespace = oso_dwarf->FindNamespace(sc, name, parent_decl_ctx); + ForEachSymbolFile([&](SymbolFileDWARF *oso_dwarf) -> bool { + matching_namespace = oso_dwarf->FindNamespace(name, parent_decl_ctx); - return (bool)matching_namespace; - }); - } + return (bool)matching_namespace; + }); return matching_namespace; } +void SymbolFileDWARFDebugMap::DumpClangAST(Stream &s) { + ForEachSymbolFile([&s](SymbolFileDWARF *oso_dwarf) -> bool { + oso_dwarf->DumpClangAST(s); + return true; + }); +} + //------------------------------------------------------------------ // PluginInterface protocol //------------------------------------------------------------------ |