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
+ const size_t update_rate = std::max<size_t >(1 , num_oso_idxs / 100 );
726
+ Progress progress (std::move (description), " " , num_oso_idxs);
727
+ for (uint32_t oso_idx = 0 ; oso_idx < num_oso_idxs; ++oso_idx) {
728
+ if (SymbolFileDWARF *oso_dwarf = GetSymbolFileByOSOIndex (oso_idx)) {
729
+ if (oso_idx % update_rate == 0 )
730
+ progress.Increment (oso_idx, oso_dwarf->GetObjectFile ()
731
+ ? oso_dwarf->GetObjectFile ()
732
+ ->GetFileSpec ()
733
+ .GetFilename ()
734
+ .GetString ()
735
+ : std::string ());
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,7 +827,7 @@ 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) {
830
+ ForEachSymbolFile (" Completing type " , [&](SymbolFileDWARF *oso_dwarf) {
808
831
if (oso_dwarf->HasForwardDeclForCompilerType (compiler_type)) {
809
832
oso_dwarf->CompleteType (compiler_type);
810
833
success = true ;
@@ -924,59 +947,63 @@ 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
+ // Are we getting all matches?
960
+ if (max_matches == UINT32_MAX)
961
+ return IterationAction::Continue; // Yep, continue getting
962
+ // everything
963
+
964
+ // If we have found enough matches, lets get out
965
+ if (max_matches >= total_matches)
966
+ return IterationAction::Stop;
967
+
968
+ // Update the max matches for any subsequent calls to find globals in
969
+ // any other object files with DWARF
970
+ max_matches -= oso_matches;
971
+ }
947
972
948
- return IterationAction::Continue;
949
- });
973
+ return IterationAction::Continue;
974
+ });
950
975
}
951
976
952
977
void SymbolFileDWARFDebugMap::FindGlobalVariables (
953
978
const RegularExpression ®ex, uint32_t max_matches,
954
979
VariableList &variables) {
955
980
std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
956
981
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
- }
982
+ ForEachSymbolFile (
983
+ " Looking up global variables" , [&](SymbolFileDWARF *oso_dwarf) {
984
+ const uint32_t old_size = variables.GetSize ();
985
+ oso_dwarf->FindGlobalVariables (regex, max_matches, variables);
986
+
987
+ const uint32_t oso_matches = variables.GetSize () - old_size;
988
+ if (oso_matches > 0 ) {
989
+ total_matches += oso_matches;
990
+
991
+ // Are we getting all matches?
992
+ if (max_matches == UINT32_MAX)
993
+ return IterationAction::Continue; // Yep, continue getting
994
+ // everything
995
+
996
+ // If we have found enough matches, lets get out
997
+ if (max_matches >= total_matches)
998
+ return IterationAction::Stop;
999
+
1000
+ // Update the max matches for any subsequent calls to find globals in
1001
+ // any other object files with DWARF
1002
+ max_matches -= oso_matches;
1003
+ }
977
1004
978
- return IterationAction::Continue;
979
- });
1005
+ return IterationAction::Continue;
1006
+ });
980
1007
}
981
1008
982
1009
int SymbolFileDWARFDebugMap::SymbolContainsSymbolWithIndex (
@@ -1079,7 +1106,7 @@ void SymbolFileDWARFDebugMap::FindFunctions(
1079
1106
LLDB_SCOPED_TIMERF (" SymbolFileDWARFDebugMap::FindFunctions (name = %s)" ,
1080
1107
lookup_info.GetLookupName ().GetCString ());
1081
1108
1082
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1109
+ ForEachSymbolFile (" Looking up functions " , [&](SymbolFileDWARF *oso_dwarf) {
1083
1110
uint32_t sc_idx = sc_list.GetSize ();
1084
1111
oso_dwarf->FindFunctions (lookup_info, parent_decl_ctx, include_inlines,
1085
1112
sc_list);
@@ -1098,7 +1125,7 @@ void SymbolFileDWARFDebugMap::FindFunctions(const RegularExpression ®ex,
1098
1125
LLDB_SCOPED_TIMERF (" SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')" ,
1099
1126
regex.GetText ().str ().c_str ());
1100
1127
1101
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1128
+ ForEachSymbolFile (" Looking up functions " , [&](SymbolFileDWARF *oso_dwarf) {
1102
1129
uint32_t sc_idx = sc_list.GetSize ();
1103
1130
1104
1131
oso_dwarf->FindFunctions (regex, include_inlines, sc_list);
@@ -1129,7 +1156,7 @@ void SymbolFileDWARFDebugMap::GetTypes(SymbolContextScope *sc_scope,
1129
1156
oso_dwarf->GetTypes (sc_scope, type_mask, type_list);
1130
1157
}
1131
1158
} else {
1132
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1159
+ ForEachSymbolFile (" Looking up types " , [&](SymbolFileDWARF *oso_dwarf) {
1133
1160
oso_dwarf->GetTypes (sc_scope, type_mask, type_list);
1134
1161
return IterationAction::Continue;
1135
1162
});
@@ -1148,16 +1175,16 @@ SymbolFileDWARFDebugMap::ParseCallEdgesInFunction(
1148
1175
1149
1176
DWARFDIE SymbolFileDWARFDebugMap::FindDefinitionDIE (const DWARFDIE &die) {
1150
1177
DWARFDIE result;
1151
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1152
- result = oso_dwarf->FindDefinitionDIE (die);
1153
- return result ? IterationAction::Stop : IterationAction::Continue;
1154
- });
1178
+ ForEachSymbolFile (
1179
+ " Looking up type definition" , [&](SymbolFileDWARF *oso_dwarf) {
1180
+ result = oso_dwarf->FindDefinitionDIE (die);
1181
+ return result ? IterationAction::Stop : IterationAction::Continue;
1182
+ });
1155
1183
return result;
1156
1184
}
1157
1185
1158
1186
TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE (
1159
- const DWARFDIE &die, ConstString type_name,
1160
- bool must_be_implementation) {
1187
+ const DWARFDIE &die, ConstString type_name, bool must_be_implementation) {
1161
1188
// If we have a debug map, we will have an Objective-C symbol whose name is
1162
1189
// the type name and whose type is eSymbolTypeObjCClass. If we can find that
1163
1190
// symbol and find its containing parent, we can locate the .o file that will
@@ -1208,11 +1235,12 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
1208
1235
if (!must_be_implementation) {
1209
1236
TypeSP type_sp;
1210
1237
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
- });
1238
+ ForEachSymbolFile (
1239
+ " Looking up Objective-C definition" , [&](SymbolFileDWARF *oso_dwarf) {
1240
+ type_sp = oso_dwarf->FindCompleteObjCDefinitionTypeForDIE (
1241
+ die, type_name, must_be_implementation);
1242
+ return type_sp ? IterationAction::Stop : IterationAction::Continue;
1243
+ });
1216
1244
1217
1245
return type_sp;
1218
1246
}
@@ -1222,7 +1250,7 @@ TypeSP SymbolFileDWARFDebugMap::FindCompleteObjCDefinitionTypeForDIE(
1222
1250
void SymbolFileDWARFDebugMap::FindTypes (const TypeQuery &query,
1223
1251
TypeResults &results) {
1224
1252
std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
1225
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1253
+ ForEachSymbolFile (" Looking up type " , [&](SymbolFileDWARF *oso_dwarf) {
1226
1254
oso_dwarf->FindTypes (query, results);
1227
1255
return results.Done (query) ? IterationAction::Stop
1228
1256
: IterationAction::Continue;
@@ -1235,7 +1263,7 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
1235
1263
std::lock_guard<std::recursive_mutex> guard (GetModuleMutex ());
1236
1264
CompilerDeclContext matching_namespace;
1237
1265
1238
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1266
+ ForEachSymbolFile (" Looking up namespace " , [&](SymbolFileDWARF *oso_dwarf) {
1239
1267
matching_namespace =
1240
1268
oso_dwarf->FindNamespace (name, parent_decl_ctx, only_root_namespaces);
1241
1269
@@ -1247,7 +1275,7 @@ CompilerDeclContext SymbolFileDWARFDebugMap::FindNamespace(
1247
1275
}
1248
1276
1249
1277
void SymbolFileDWARFDebugMap::DumpClangAST (Stream &s) {
1250
- ForEachSymbolFile ([&s](SymbolFileDWARF *oso_dwarf) {
1278
+ ForEachSymbolFile (" Dumping clang AST " , [&s](SymbolFileDWARF *oso_dwarf) {
1251
1279
oso_dwarf->DumpClangAST (s);
1252
1280
// The underlying assumption is that DumpClangAST(...) will obtain the
1253
1281
// AST from the underlying TypeSystem and therefore we only need to do
@@ -1294,7 +1322,8 @@ bool SymbolFileDWARFDebugMap::GetSeparateDebugInfo(
1294
1322
}
1295
1323
1296
1324
lldb::CompUnitSP
1297
- SymbolFileDWARFDebugMap::GetCompileUnit (SymbolFileDWARF *oso_dwarf, DWARFCompileUnit &dwarf_cu) {
1325
+ SymbolFileDWARFDebugMap::GetCompileUnit (SymbolFileDWARF *oso_dwarf,
1326
+ DWARFCompileUnit &dwarf_cu) {
1298
1327
if (oso_dwarf) {
1299
1328
const uint32_t cu_count = GetNumCompileUnits ();
1300
1329
for (uint32_t cu_idx = 0 ; cu_idx < cu_count; ++cu_idx) {
@@ -1344,7 +1373,8 @@ void SymbolFileDWARFDebugMap::SetCompileUnit(SymbolFileDWARF *oso_dwarf,
1344
1373
} else {
1345
1374
assert (cu_sp->GetID () == 0 &&
1346
1375
" Setting first compile unit but with id different than 0!" );
1347
- auto &compile_units_sps = m_compile_unit_infos[cu_idx].compile_units_sps ;
1376
+ auto &compile_units_sps =
1377
+ m_compile_unit_infos[cu_idx].compile_units_sps ;
1348
1378
compile_units_sps.push_back (cu_sp);
1349
1379
m_compile_unit_infos[cu_idx].id_to_index_map .insert (
1350
1380
{cu_sp->GetID (), compile_units_sps.size () - 1 });
@@ -1382,7 +1412,7 @@ SymbolFileDWARFDebugMap::GetCompilerContextForUID(lldb::user_id_t type_uid) {
1382
1412
1383
1413
void SymbolFileDWARFDebugMap::ParseDeclsForContext (
1384
1414
lldb_private::CompilerDeclContext decl_ctx) {
1385
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1415
+ ForEachSymbolFile (" Parsing declarations " , [&](SymbolFileDWARF *oso_dwarf) {
1386
1416
oso_dwarf->ParseDeclsForContext (decl_ctx);
1387
1417
return IterationAction::Continue;
1388
1418
});
@@ -1512,7 +1542,7 @@ SymbolFileDWARFDebugMap::AddOSOARanges(SymbolFileDWARF *dwarf2Data,
1512
1542
1513
1543
ModuleList SymbolFileDWARFDebugMap::GetDebugInfoModules () {
1514
1544
ModuleList oso_modules;
1515
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1545
+ ForEachSymbolFile (" Parsing modules " , [&](SymbolFileDWARF *oso_dwarf) {
1516
1546
ObjectFile *oso_objfile = oso_dwarf->GetObjectFile ();
1517
1547
if (oso_objfile) {
1518
1548
ModuleSP module_sp = oso_objfile->GetModule ();
@@ -1573,7 +1603,7 @@ Status SymbolFileDWARFDebugMap::CalculateFrameVariableError(StackFrame &frame) {
1573
1603
void SymbolFileDWARFDebugMap::GetCompileOptions (
1574
1604
std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {
1575
1605
1576
- ForEachSymbolFile ([&](SymbolFileDWARF *oso_dwarf) {
1606
+ ForEachSymbolFile (" Parsing compile options " , [&](SymbolFileDWARF *oso_dwarf) {
1577
1607
oso_dwarf->GetCompileOptions (args);
1578
1608
return IterationAction::Continue;
1579
1609
});
0 commit comments