1414#include " lldb/Core/Module.h"
1515#include " lldb/Core/ModuleList.h"
1616#include " lldb/Core/PluginManager.h"
17+ #include " lldb/Core/Progress.h"
1718#include " lldb/Core/Section.h"
1819#include " lldb/Host/FileSystem.h"
1920#include " lldb/Utility/RangeMap.h"
3132#include " lldb/Symbol/TypeMap.h"
3233#include " lldb/Symbol/VariableList.h"
3334#include " llvm/ADT/STLExtras.h"
35+ #include " llvm/ADT/StringRef.h"
3436#include " llvm/Support/ScopedPrinter.h"
3537
3638#include " lldb/Target/StackFrame.h"
@@ -716,6 +718,27 @@ bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) {
716718 return false ;
717719}
718720
721+ void SymbolFileDWARFDebugMap::ForEachSymbolFile (
722+ std::string description,
723+ std::function<IterationAction(SymbolFileDWARF &)> closure) {
724+ const size_t num_oso_idxs = m_compile_unit_infos.size ();
725+ Progress progress (std::move (description), " " , num_oso_idxs,
726+ /* debugger=*/ nullptr ,
727+ /* minimum_report_time=*/ std::chrono::milliseconds (20 ));
728+ for (uint32_t oso_idx = 0 ; oso_idx < num_oso_idxs; ++oso_idx) {
729+ if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) {
730+ progress.Increment (oso_idx, oso_dwarf->GetObjectFile ()
731+ ? oso_dwarf->GetObjectFile ()
732+ ->GetFileSpec ()
733+ .GetFilename ()
734+ .GetString ()
735+ : " " );
736+ if (closure (*oso_dwarf) == IterationAction::Stop)
737+ return ;
738+ }
739+ }
740+ }
741+
719742bool SymbolFileDWARFDebugMap::ForEachExternalModule (
720743 CompileUnit &comp_unit,
721744 llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
@@ -804,9 +827,9 @@ SymbolFileDWARFDebugMap::GetDynamicArrayInfoForUID(
804827bool SymbolFileDWARFDebugMap::CompleteType (CompilerType &compiler_type) {
805828 bool success = false ;
806829 if (compiler_type) {
807- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
808- if (oso_dwarf-> HasForwardDeclForCompilerType (compiler_type)) {
809- oso_dwarf-> CompleteType (compiler_type);
830+ ForEachSymbolFile (" Completing type " , [&](SymbolFileDWARF & oso_dwarf) {
831+ if (oso_dwarf. HasForwardDeclForCompilerType (compiler_type)) {
832+ oso_dwarf. CompleteType (compiler_type);
810833 success = true ;
811834 return IterationAction::Stop;
812835 }
@@ -924,59 +947,61 @@ void SymbolFileDWARFDebugMap::FindGlobalVariables(
924947 std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
925948 uint32_t total_matches = 0 ;
926949
927- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
928- const uint32_t old_size = variables.GetSize ();
929- oso_dwarf->FindGlobalVariables (name, parent_decl_ctx, max_matches,
930- variables);
931- const uint32_t oso_matches = variables.GetSize () - old_size;
932- if (oso_matches > 0 ) {
933- total_matches += oso_matches;
934-
935- // Are we getting all matches?
936- if (max_matches == UINT32_MAX)
937- return IterationAction::Continue; // Yep, continue getting everything
938-
939- // If we have found enough matches, lets get out
940- if (max_matches >= total_matches)
941- return IterationAction::Stop;
942-
943- // Update the max matches for any subsequent calls to find globals in any
944- // other object files with DWARF
945- max_matches -= oso_matches;
946- }
950+ ForEachSymbolFile (
951+ " Looking up global variables" , [&](SymbolFileDWARF &oso_dwarf) {
952+ const uint32_t old_size = variables.GetSize ();
953+ oso_dwarf.FindGlobalVariables (name, parent_decl_ctx, max_matches,
954+ variables);
955+ const uint32_t oso_matches = variables.GetSize () - old_size;
956+ if (oso_matches > 0 ) {
957+ total_matches += oso_matches;
958+
959+ // If we are getting all matches, keep going.
960+ if (max_matches == UINT32_MAX)
961+ return IterationAction::Continue;
962+
963+ // If we have found enough matches, lets get out
964+ if (max_matches >= total_matches)
965+ return IterationAction::Stop;
966+
967+ // Update the max matches for any subsequent calls to find globals in
968+ // any other object files with DWARF
969+ max_matches -= oso_matches;
970+ }
947971
948- return IterationAction::Continue;
949- });
972+ return IterationAction::Continue;
973+ });
950974}
951975
952976void SymbolFileDWARFDebugMap::FindGlobalVariables (
953977 const RegularExpression ®ex, uint32_t max_matches,
954978 VariableList &variables) {
955979 std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
956980 uint32_t total_matches = 0 ;
957- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
958- const uint32_t old_size = variables.GetSize ();
959- oso_dwarf->FindGlobalVariables (regex, max_matches, variables);
960-
961- const uint32_t oso_matches = variables.GetSize () - old_size;
962- if (oso_matches > 0 ) {
963- total_matches += oso_matches;
964-
965- // Are we getting all matches?
966- if (max_matches == UINT32_MAX)
967- return IterationAction::Continue; // Yep, continue getting everything
968-
969- // If we have found enough matches, lets get out
970- if (max_matches >= total_matches)
971- return IterationAction::Stop;
972-
973- // Update the max matches for any subsequent calls to find globals in any
974- // other object files with DWARF
975- max_matches -= oso_matches;
976- }
981+ ForEachSymbolFile (
982+ " Looking up global variables" , [&](SymbolFileDWARF &oso_dwarf) {
983+ const uint32_t old_size = variables.GetSize ();
984+ oso_dwarf.FindGlobalVariables (regex, max_matches, variables);
985+
986+ const uint32_t oso_matches = variables.GetSize () - old_size;
987+ if (oso_matches > 0 ) {
988+ total_matches += oso_matches;
989+
990+ // If we are getting all matches, keep going.
991+ if (max_matches == UINT32_MAX)
992+ return IterationAction::Continue;
993+
994+ // If we have found enough matches, lets get out
995+ if (max_matches >= total_matches)
996+ return IterationAction::Stop;
997+
998+ // Update the max matches for any subsequent calls to find globals in
999+ // any other object files with DWARF
1000+ max_matches -= oso_matches;
1001+ }
9771002
978- return IterationAction::Continue;
979- });
1003+ return IterationAction::Continue;
1004+ });
9801005}
9811006
9821007int SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (
@@ -1079,10 +1104,10 @@ void SymbolFileDWARFDebugMap::FindFunctions(
10791104 LLDB_SCOPED_TIMERF (" SymbolFileDWARFDebugMap::FindFunctions (name = %s)" ,
10801105 lookup_info.GetLookupName ().GetCString ());
10811106
1082- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1107+ ForEachSymbolFile (" Looking up functions " , [&](SymbolFileDWARF & oso_dwarf) {
10831108 uint32_t sc_idx = sc_list.GetSize ();
1084- oso_dwarf-> FindFunctions (lookup_info, parent_decl_ctx, include_inlines,
1085- sc_list);
1109+ oso_dwarf. FindFunctions (lookup_info, parent_decl_ctx, include_inlines,
1110+ sc_list);
10861111 if (!sc_list.IsEmpty ()) {
10871112 RemoveFunctionsWithModuleNotEqualTo (m_objfile_sp->GetModule (), sc_list,
10881113 sc_idx);
@@ -1098,10 +1123,10 @@ void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex,
10981123 LLDB_SCOPED_TIMERF (" SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')" ,
10991124 regex.GetText ().str ().c_str ());
11001125
1101- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1126+ ForEachSymbolFile (" Looking up functions " , [&](SymbolFileDWARF & oso_dwarf) {
11021127 uint32_t sc_idx = sc_list.GetSize ();
11031128
1104- oso_dwarf-> FindFunctions (regex, include_inlines, sc_list);
1129+ oso_dwarf. FindFunctions (regex, include_inlines, sc_list);
11051130 if (!sc_list.IsEmpty ()) {
11061131 RemoveFunctionsWithModuleNotEqualTo (m_objfile_sp->GetModule (), sc_list,
11071132 sc_idx);
@@ -1129,8 +1154,8 @@ void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,
11291154 oso_dwarf->GetTypes (sc_scope, type_mask, type_list);
11301155 }
11311156 } else {
1132- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1133- oso_dwarf-> GetTypes (sc_scope, type_mask, type_list);
1157+ ForEachSymbolFile (" Looking up types " , [&](SymbolFileDWARF & oso_dwarf) {
1158+ oso_dwarf. GetTypes (sc_scope, type_mask, type_list);
11341159 return IterationAction::Continue;
11351160 });
11361161 }
@@ -1148,16 +1173,16 @@ SymbolFileDWARFDebugMap::ParseCallEdgesInFunction(
11481173
11491174DWARFDIE SymbolFileDWARFDebugMap::FindDefinitionDIE (const DWARFDIE &die) {
11501175 DWARFDIE result;
1151- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1152- result = oso_dwarf->FindDefinitionDIE (die);
1153- return result ? IterationAction::Stop : IterationAction::Continue;
1154- });
1176+ ForEachSymbolFile (
1177+ " Looking up type definition" , [&](SymbolFileDWARF &oso_dwarf) {
1178+ result = oso_dwarf.FindDefinitionDIE (die);
1179+ return result ? IterationAction::Stop : IterationAction::Continue;
1180+ });
11551181 return result;
11561182}
11571183
11581184TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (
1159- const DWARFDIE &die, ConstString type_name,
1160- bool must_be_implementation) {
1185+ const DWARFDIE &die, ConstString type_name, bool must_be_implementation) {
11611186 // If we have a debug map, we will have an Objective-C symbol whose name is
11621187 // the type name and whose type is eSymbolTypeObjCClass. If we can find that
11631188 // symbol and find its containing parent, we can locate the .o file that will
@@ -1208,11 +1233,12 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
12081233 if (!must_be_implementation) {
12091234 TypeSP type_sp;
12101235
1211- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1212- type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE (
1213- die, type_name, must_be_implementation);
1214- return type_sp ? IterationAction::Stop : IterationAction::Continue;
1215- });
1236+ ForEachSymbolFile (
1237+ " Looking up Objective-C definition" , [&](SymbolFileDWARF &oso_dwarf) {
1238+ type_sp = oso_dwarf.FindCompleteObjCDefinitionTypeForDIE (
1239+ die, type_name, must_be_implementation);
1240+ return type_sp ? IterationAction::Stop : IterationAction::Continue;
1241+ });
12161242
12171243 return type_sp;
12181244 }
@@ -1222,8 +1248,8 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
12221248void SymbolFileDWARFDebugMap::FindTypes (const TypeQuery &query,
12231249 TypeResults &results) {
12241250 std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
1225- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1226- oso_dwarf-> FindTypes (query, results);
1251+ ForEachSymbolFile (" Looking up type " , [&](SymbolFileDWARF & oso_dwarf) {
1252+ oso_dwarf. FindTypes (query, results);
12271253 return results.Done (query) ? IterationAction::Stop
12281254 : IterationAction::Continue;
12291255 });
@@ -1235,9 +1261,9 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
12351261 std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
12361262 CompilerDeclContext matching_namespace;
12371263
1238- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1264+ ForEachSymbolFile (" Looking up namespace " , [&](SymbolFileDWARF & oso_dwarf) {
12391265 matching_namespace =
1240- oso_dwarf-> FindNamespace (name, parent_decl_ctx, only_root_namespaces);
1266+ oso_dwarf. FindNamespace (name, parent_decl_ctx, only_root_namespaces);
12411267
12421268 return matching_namespace ? IterationAction::Stop
12431269 : IterationAction::Continue;
@@ -1247,8 +1273,8 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
12471273}
12481274
12491275void SymbolFileDWARFDebugMap::DumpClangAST (Stream &s) {
1250- ForEachSymbolFile ([&s](SymbolFileDWARF * oso_dwarf) {
1251- oso_dwarf-> DumpClangAST (s);
1276+ ForEachSymbolFile (" Dumping clang AST " , [&s](SymbolFileDWARF & oso_dwarf) {
1277+ oso_dwarf. DumpClangAST (s);
12521278 // The underlying assumption is that DumpClangAST(...) will obtain the
12531279 // AST from the underlying TypeSystem and therefore we only need to do
12541280 // this once and can stop after the first iteration hence we return true.
@@ -1294,7 +1320,8 @@ bool SymbolFileDWARFDebugMap::GetSeparateDebugInfo(
12941320}
12951321
12961322lldb::CompUnitSP
1297- SymbolFileDWARFDebugMap::GetCompileUnit (SymbolFileDWARF *oso_dwarf, DWARFCompileUnit &dwarf_cu) {
1323+ SymbolFileDWARFDebugMap::GetCompileUnit (SymbolFileDWARF *oso_dwarf,
1324+ DWARFCompileUnit &dwarf_cu) {
12981325 if (oso_dwarf) {
12991326 const uint32_t cu_count = GetNumCompileUnits ();
13001327 for (uint32_t cu_idx = 0 ; cu_idx < cu_count; ++cu_idx) {
@@ -1344,7 +1371,8 @@ void SymbolFileDWARFDebugMap::SetCompileUnit(SymbolFileDWARF *oso_dwarf,
13441371 } else {
13451372 assert (cu_sp->GetID () == 0 &&
13461373 " Setting first compile unit but with id different than 0!" );
1347- auto &compile_units_sps = m_compile_unit_infos[cu_idx].compile_units_sps ;
1374+ auto &compile_units_sps =
1375+ m_compile_unit_infos[cu_idx].compile_units_sps ;
13481376 compile_units_sps.push_back (cu_sp);
13491377 m_compile_unit_infos[cu_idx].id_to_index_map .insert (
13501378 {cu_sp->GetID (), compile_units_sps.size () - 1 });
@@ -1382,8 +1410,8 @@ SymbolFileDWARFDebugMap::GetCompilerContextForUID(lldb::user_id_t type_uid) {
13821410
13831411void SymbolFileDWARFDebugMap::ParseDeclsForContext (
13841412 lldb_private::CompilerDeclContext decl_ctx) {
1385- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1386- oso_dwarf-> ParseDeclsForContext (decl_ctx);
1413+ ForEachSymbolFile (" Parsing declarations " , [&](SymbolFileDWARF & oso_dwarf) {
1414+ oso_dwarf. ParseDeclsForContext (decl_ctx);
13871415 return IterationAction::Continue;
13881416 });
13891417}
@@ -1512,8 +1540,8 @@ SymbolFileDWARFDebugMap::AddOSOARanges(SymbolFileDWARF *dwarf2Data,
15121540
15131541ModuleList SymbolFileDWARFDebugMap::GetDebugInfoModules () {
15141542 ModuleList oso_modules;
1515- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1516- ObjectFile *oso_objfile = oso_dwarf-> GetObjectFile ();
1543+ ForEachSymbolFile (" Parsing modules " , [&](SymbolFileDWARF & oso_dwarf) {
1544+ ObjectFile *oso_objfile = oso_dwarf. GetObjectFile ();
15171545 if (oso_objfile) {
15181546 ModuleSP module_sp = oso_objfile->GetModule ();
15191547 if (module_sp)
@@ -1573,8 +1601,8 @@ Status SymbolFileDWARFDebugMap::CalculateFrameVariableError(StackFrame &frame) {
15731601void SymbolFileDWARFDebugMap::GetCompileOptions (
15741602 std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {
15751603
1576- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1577- oso_dwarf-> GetCompileOptions (args);
1604+ ForEachSymbolFile (" Parsing compile options " , [&](SymbolFileDWARF & oso_dwarf) {
1605+ oso_dwarf. GetCompileOptions (args);
15781606 return IterationAction::Continue;
15791607 });
15801608}
0 commit comments