14
14
#include " lldb/Core/Module.h"
15
15
#include " lldb/Core/ModuleList.h"
16
16
#include " lldb/Core/PluginManager.h"
17
+ #include " lldb/Core/Progress.h"
17
18
#include " lldb/Core/Section.h"
18
19
#include " lldb/Host/FileSystem.h"
19
20
#include " lldb/Utility/RangeMap.h"
31
32
#include " lldb/Symbol/TypeMap.h"
32
33
#include " lldb/Symbol/VariableList.h"
33
34
#include " llvm/ADT/STLExtras.h"
35
+ #include " llvm/ADT/StringRef.h"
34
36
#include " llvm/Support/ScopedPrinter.h"
35
37
36
38
#include " lldb/Target/StackFrame.h"
@@ -716,6 +718,27 @@ bool SymbolFileDWARFDebugMap::ParseDebugMacros(CompileUnit &comp_unit) {
716
718
return false ;
717
719
}
718
720
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
+
719
742
bool SymbolFileDWARFDebugMap::ForEachExternalModule (
720
743
CompileUnit &comp_unit,
721
744
llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
@@ -804,9 +827,9 @@ SymbolFileDWARFDebugMap::GetDynamicArrayInfoForUID(
804
827
bool SymbolFileDWARFDebugMap::CompleteType (CompilerType &compiler_type) {
805
828
bool success = false ;
806
829
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);
810
833
success = true ;
811
834
return IterationAction::Stop;
812
835
}
@@ -924,59 +947,61 @@ void SymbolFileDWARFDebugMap::FindGlobalVariables(
924
947
std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
925
948
uint32_t total_matches = 0 ;
926
949
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
+ }
947
971
948
- return IterationAction::Continue;
949
- });
972
+ return IterationAction::Continue;
973
+ });
950
974
}
951
975
952
976
void SymbolFileDWARFDebugMap::FindGlobalVariables (
953
977
const RegularExpression ®ex, uint32_t max_matches,
954
978
VariableList &variables) {
955
979
std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
956
980
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
+ }
977
1002
978
- return IterationAction::Continue;
979
- });
1003
+ return IterationAction::Continue;
1004
+ });
980
1005
}
981
1006
982
1007
int SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (
@@ -1079,10 +1104,10 @@ void SymbolFileDWARFDebugMap::FindFunctions(
1079
1104
LLDB_SCOPED_TIMERF (" SymbolFileDWARFDebugMap::FindFunctions (name = %s)" ,
1080
1105
lookup_info.GetLookupName ().GetCString ());
1081
1106
1082
- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1107
+ ForEachSymbolFile (" Looking up functions " , [&](SymbolFileDWARF & oso_dwarf) {
1083
1108
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);
1086
1111
if (!sc_list.IsEmpty ()) {
1087
1112
RemoveFunctionsWithModuleNotEqualTo (m_objfile_sp->GetModule (), sc_list,
1088
1113
sc_idx);
@@ -1098,10 +1123,10 @@ void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex,
1098
1123
LLDB_SCOPED_TIMERF (" SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')" ,
1099
1124
regex.GetText ().str ().c_str ());
1100
1125
1101
- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1126
+ ForEachSymbolFile (" Looking up functions " , [&](SymbolFileDWARF & oso_dwarf) {
1102
1127
uint32_t sc_idx = sc_list.GetSize ();
1103
1128
1104
- oso_dwarf-> FindFunctions (regex, include_inlines, sc_list);
1129
+ oso_dwarf. FindFunctions (regex, include_inlines, sc_list);
1105
1130
if (!sc_list.IsEmpty ()) {
1106
1131
RemoveFunctionsWithModuleNotEqualTo (m_objfile_sp->GetModule (), sc_list,
1107
1132
sc_idx);
@@ -1129,8 +1154,8 @@ void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,
1129
1154
oso_dwarf->GetTypes (sc_scope, type_mask, type_list);
1130
1155
}
1131
1156
} 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);
1134
1159
return IterationAction::Continue;
1135
1160
});
1136
1161
}
@@ -1148,16 +1173,16 @@ SymbolFileDWARFDebugMap::ParseCallEdgesInFunction(
1148
1173
1149
1174
DWARFDIE SymbolFileDWARFDebugMap::FindDefinitionDIE (const DWARFDIE &die) {
1150
1175
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
+ });
1155
1181
return result;
1156
1182
}
1157
1183
1158
1184
TypeSP 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) {
1161
1186
// If we have a debug map, we will have an Objective-C symbol whose name is
1162
1187
// the type name and whose type is eSymbolTypeObjCClass. If we can find that
1163
1188
// symbol and find its containing parent, we can locate the .o file that will
@@ -1208,11 +1233,12 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
1208
1233
if (!must_be_implementation) {
1209
1234
TypeSP type_sp;
1210
1235
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
+ });
1216
1242
1217
1243
return type_sp;
1218
1244
}
@@ -1222,8 +1248,8 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
1222
1248
void SymbolFileDWARFDebugMap::FindTypes (const TypeQuery &query,
1223
1249
TypeResults &results) {
1224
1250
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);
1227
1253
return results.Done (query) ? IterationAction::Stop
1228
1254
: IterationAction::Continue;
1229
1255
});
@@ -1235,9 +1261,9 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
1235
1261
std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
1236
1262
CompilerDeclContext matching_namespace;
1237
1263
1238
- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1264
+ ForEachSymbolFile (" Looking up namespace " , [&](SymbolFileDWARF & oso_dwarf) {
1239
1265
matching_namespace =
1240
- oso_dwarf-> FindNamespace (name, parent_decl_ctx, only_root_namespaces);
1266
+ oso_dwarf. FindNamespace (name, parent_decl_ctx, only_root_namespaces);
1241
1267
1242
1268
return matching_namespace ? IterationAction::Stop
1243
1269
: IterationAction::Continue;
@@ -1247,8 +1273,8 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
1247
1273
}
1248
1274
1249
1275
void 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);
1252
1278
// The underlying assumption is that DumpClangAST(...) will obtain the
1253
1279
// AST from the underlying TypeSystem and therefore we only need to do
1254
1280
// this once and can stop after the first iteration hence we return true.
@@ -1294,7 +1320,8 @@ bool SymbolFileDWARFDebugMap::GetSeparateDebugInfo(
1294
1320
}
1295
1321
1296
1322
lldb::CompUnitSP
1297
- SymbolFileDWARFDebugMap::GetCompileUnit (SymbolFileDWARF *oso_dwarf, DWARFCompileUnit &dwarf_cu) {
1323
+ SymbolFileDWARFDebugMap::GetCompileUnit (SymbolFileDWARF *oso_dwarf,
1324
+ DWARFCompileUnit &dwarf_cu) {
1298
1325
if (oso_dwarf) {
1299
1326
const uint32_t cu_count = GetNumCompileUnits ();
1300
1327
for (uint32_t cu_idx = 0 ; cu_idx < cu_count; ++cu_idx) {
@@ -1344,7 +1371,8 @@ void SymbolFileDWARFDebugMap::SetCompileUnit(SymbolFileDWARF *oso_dwarf,
1344
1371
} else {
1345
1372
assert (cu_sp->GetID () == 0 &&
1346
1373
" 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 ;
1348
1376
compile_units_sps.push_back (cu_sp);
1349
1377
m_compile_unit_infos[cu_idx].id_to_index_map .insert (
1350
1378
{cu_sp->GetID (), compile_units_sps.size () - 1 });
@@ -1382,8 +1410,8 @@ SymbolFileDWARFDebugMap::GetCompilerContextForUID(lldb::user_id_t type_uid) {
1382
1410
1383
1411
void SymbolFileDWARFDebugMap::ParseDeclsForContext (
1384
1412
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);
1387
1415
return IterationAction::Continue;
1388
1416
});
1389
1417
}
@@ -1512,8 +1540,8 @@ SymbolFileDWARFDebugMap::AddOSOARanges(SymbolFileDWARF *dwarf2Data,
1512
1540
1513
1541
ModuleList SymbolFileDWARFDebugMap::GetDebugInfoModules () {
1514
1542
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 ();
1517
1545
if (oso_objfile) {
1518
1546
ModuleSP module_sp = oso_objfile->GetModule ();
1519
1547
if (module_sp)
@@ -1573,8 +1601,8 @@ Status SymbolFileDWARFDebugMap::CalculateFrameVariableError(StackFrame &frame) {
1573
1601
void SymbolFileDWARFDebugMap::GetCompileOptions (
1574
1602
std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {
1575
1603
1576
- ForEachSymbolFile ([&](SymbolFileDWARF * oso_dwarf) {
1577
- oso_dwarf-> GetCompileOptions (args);
1604
+ ForEachSymbolFile (" Parsing compile options " , [&](SymbolFileDWARF & oso_dwarf) {
1605
+ oso_dwarf. GetCompileOptions (args);
1578
1606
return IterationAction::Continue;
1579
1607
});
1580
1608
}
0 commit comments