58 module.try_emplace("identifier", identifier);
59 module.try_emplace("symbolTableParseTime", symtab_parse_time);
60 module.try_emplace("symbolTableIndexTime", symtab_index_time);
61 module.try_emplace("symbolTableLoadedFromCache", symtab_loaded_from_cache);
62 module.try_emplace("symbolTableParsedFromObjectFile",
63 symtab_parsed_from_object_file);
64 module.try_emplace("symbolTableSavedToCache", symtab_saved_to_cache);
65 module.try_emplace("symbolTableSymbolFileAddedSymbols",
66 symtab_symbol_file_added_symbols);
67 module.try_emplace("debugInfoParseTime", debug_parse_time);
68 module.try_emplace("debugInfoIndexTime", debug_index_time);
69 module.try_emplace("debugInfoByteSize", (int64_t)debug_info_size);
70 module.try_emplace("debugInfoIndexLoadedFromCache",
71 debug_info_index_loaded_from_cache);
72 module.try_emplace("debugInfoIndexSavedToCache",
73 debug_info_index_saved_to_cache);
74 module.try_emplace("debugInfoEnabled", debug_info_enabled);
75 module.try_emplace("debugInfoHadVariableErrors",
76 debug_info_had_variable_errors);
77 module.try_emplace("debugInfoHadIncompleteTypes",
78 debug_info_had_incomplete_types);
79 module.try_emplace("symbolTableStripped", symtab_stripped);
80 module.try_emplace("symbolTableSymbolCount", symtab_symbol_count);
81 module.try_emplace("dwoFileCount", dwo_stats.dwo_file_count);
82 module.try_emplace("loadedDwoFileCount", dwo_stats.loaded_dwo_file_count);
83 module.try_emplace("dwoErrorCount", dwo_stats.dwo_error_count);
88 obj.try_emplace(entry.first().str(), entry.second);
89 module.try_emplace("symbolLocatorTime", std::move(obj));
93 module.try_emplace("symbolFilePath", symfile_path);
96 json::Array symfile_ids;
98 symfile_ids.emplace_back(symfile_id);
99 module.try_emplace("symbolFileModuleIdentifiers", std::move(symfile_ids));
103 json::Array type_systems;
106 obj.try_emplace(entry.first().str(), entry.second);
107 type_systems.emplace_back(std::move(obj));
109 module.try_emplace("typeSystemInfo", std::move(type_systems));
126 json::Object target_metrics_json;
133 json::Array json_module_uuid_array;
135 json_module_uuid_array.emplace_back(module_identifier);
137 target_metrics_json.try_emplace(
"expressionEvaluation",
139 target_metrics_json.try_emplace(
"frameVariable",
m_frame_var.ToJSON());
141 target_metrics_json.try_emplace(
"moduleIdentifiers",
142 std::move(json_module_uuid_array));
145 double elapsed_time =
147 target_metrics_json.try_emplace(
"launchOrAttachTime", elapsed_time);
150 double elapsed_time =
152 target_metrics_json.try_emplace(
"firstStopTime", elapsed_time);
154 target_metrics_json.try_emplace(
"targetCreateTime",
158 target_metrics_json.try_emplace(
"loadCoreTime",
162 json::Array breakpoints_array;
163 double totalBreakpointResolveTime = 0.0;
165 for (
int i = 0; i < 2; ++i) {
167 std::unique_lock<std::recursive_mutex> lock;
169 size_t num_breakpoints = breakpoints.
GetSize();
170 for (
size_t i = 0; i < num_breakpoints; i++) {
176 target_metrics_json.try_emplace(
"breakpoints",
177 std::move(breakpoints_array));
178 target_metrics_json.try_emplace(
"totalBreakpointResolveTime",
179 totalBreakpointResolveTime);
182 UnixSignalsSP unix_signals_sp = process_sp->GetUnixSignals();
184 target_metrics_json.try_emplace(
185 "signals", unix_signals_sp->GetHitCountStatistics());
192 uint32_t shared_library_event_breakpoint_hit_count = 0;
195 std::unique_lock<std::recursive_mutex> lock;
197 size_t num_breakpoints = breakpoints.
GetSize();
198 for (
size_t i = 0; i < num_breakpoints; i++) {
201 shared_library_event_breakpoint_hit_count += bp->
GetHitCount();
204 target_metrics_json.try_emplace(
"totalSharedLibraryEventHitCount",
205 shared_library_event_breakpoint_hit_count);
209 uint32_t stop_id = process_sp->GetStopID();
210 target_metrics_json.try_emplace(
"stopCount", stop_id);
212 llvm::StringRef dyld_plugin_name;
213 if (process_sp->GetDynamicLoader())
214 dyld_plugin_name = process_sp->GetDynamicLoader()->GetPluginName();
215 target_metrics_json.try_emplace(
"dyldPluginName", dyld_plugin_name);
217 if (process_sp->GetCoreFile())
218 target_metrics_json.try_emplace(
219 "coreFile", process_sp->GetCoreFile().GetFilename().str());
221 target_metrics_json.try_emplace(
"sourceMapDeduceCount",
223 target_metrics_json.try_emplace(
"sourceRealpathAttemptCount",
225 target_metrics_json.try_emplace(
"sourceRealpathCompatibleCount",
227 target_metrics_json.try_emplace(
"summaryProviderStatistics",
229 return target_metrics_json;
318 json::Array json_targets;
319 json::Array json_modules;
321 double symtab_parse_time = 0.0;
322 double symtab_index_time = 0.0;
323 double debug_parse_time = 0.0;
324 double debug_index_time = 0.0;
325 uint32_t symtabs_loaded = 0;
326 uint32_t symtabs_loaded_from_cache = 0;
327 uint32_t symtabs_parsed_from_object_file = 0;
328 uint32_t symtabs_saved_to_cache = 0;
329 uint32_t symtabs_symbol_file_added_symbols = 0;
330 uint32_t debug_index_loaded = 0;
331 uint32_t debug_index_saved = 0;
332 uint64_t debug_info_size = 0;
334 std::lock_guard<std::recursive_mutex> guard(
336 const uint64_t num_modules = target !=
nullptr
339 uint32_t num_debug_info_enabled_modules = 0;
340 uint32_t num_modules_has_debug_info = 0;
341 uint32_t num_modules_with_variable_errors = 0;
342 uint32_t num_modules_with_incomplete_types = 0;
343 uint32_t num_stripped_modules = 0;
344 uint32_t symtab_symbol_count = 0;
346 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
347 Module *module = target !=
nullptr
355 Symtab *symtab =
module->GetSymtab(false);
360 const uint32_t state = symtab->
GetState();
362 state & eSymtabStateLoadedFromCache;
364 ++symtabs_loaded_from_cache;
366 state & eSymtabStateParsedFromObjectFile;
368 ++symtabs_parsed_from_object_file;
371 ++symtabs_saved_to_cache;
373 state & eSymtabStateSymbolFileAddedSymbols;
375 ++symtabs_symbol_file_added_symbols;
377 SymbolFile *sym_file =
module->GetSymbolFile(false);
381 if (!summary_only && include_modules) {
386 for (
const auto &symbol_module : symbol_modules.
Modules())
390 module_stat.
dwo_stats += current_dwo_stats;
391 total_dwo_stats += current_dwo_stats;
395 ++debug_index_loaded;
406 ++num_stripped_modules;
412 ++num_debug_info_enabled_modules;
414 ++num_modules_has_debug_info;
416 ++num_modules_with_variable_errors;
423 module->ForEachTypeSystem([&](lldb::TypeSystemSP ts) {
424 if (auto stats = ts->ReportStatistics())
425 module_stat.type_system_stats.insert({ts->GetPluginName(), *stats});
426 if (ts->GetHasForcefullyCompletedTypes())
430 if (module_stat.debug_info_had_incomplete_types)
431 ++num_modules_with_incomplete_types;
433 if (include_modules) {
434 module_stat.identifier = (intptr_t)module;
435 module_stat.path =
module->GetFileSpec().GetPath();
436 if (llvm::StringRef object_name = module->GetObjectName();
437 !object_name.empty()) {
438 module_stat.path.append(1,
'(');
439 module_stat.path.append(object_name.str());
440 module_stat.path.append(1,
')');
442 module_stat.uuid =
module->GetUUID().GetAsString();
443 module_stat.triple =
module->GetArchitecture().GetTriple().str();
444 json_modules.emplace_back(module_stat.ToJSON());
448 json::Object global_stats{
449 {
"totalSymbolTableParseTime", symtab_parse_time},
450 {
"totalSymbolTableIndexTime", symtab_index_time},
451 {
"totalSymbolTablesLoaded", symtabs_loaded},
452 {
"totalSymbolTablesLoadedFromCache", symtabs_loaded_from_cache},
453 {
"totalSymbolTablesParsedFromObjectFile",
454 symtabs_parsed_from_object_file},
455 {
"totalSymbolTablesSavedToCache", symtabs_saved_to_cache},
456 {
"totalSymbolTablesSymbolFileAddedSymbols",
457 symtabs_symbol_file_added_symbols},
458 {
"totalDebugInfoParseTime", debug_parse_time},
459 {
"totalDebugInfoIndexTime", debug_index_time},
460 {
"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
461 {
"totalDebugInfoIndexSavedToCache", debug_index_saved},
462 {
"totalDebugInfoByteSize", debug_info_size},
463 {
"totalModuleCount", num_modules},
464 {
"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
465 {
"totalModuleCountWithVariableErrors", num_modules_with_variable_errors},
466 {
"totalModuleCountWithIncompleteTypes",
467 num_modules_with_incomplete_types},
468 {
"totalDebugInfoEnabled", num_debug_info_enabled_modules},
469 {
"totalSymbolTableStripped", num_stripped_modules},
470 {
"totalSymbolTableSymbolCount", symtab_symbol_count},
471 {
"totalLoadedDwoFileCount", total_dwo_stats.loaded_dwo_file_count},
472 {
"totalDwoFileCount", total_dwo_stats.dwo_file_count},
473 {
"totalDwoErrorCount", total_dwo_stats.dwo_error_count},
476 if (include_targets) {
478 json_targets.emplace_back(target->ReportStatistics(options));
480 for (
const auto &target : debugger.GetTargetList().Targets())
481 json_targets.emplace_back(target->ReportStatistics(options));
483 global_stats.try_emplace(
"targets", std::move(json_targets));
486 if (!symbol_locator_total_time.map.empty()) {
488 for (
const auto &entry : symbol_locator_total_time.map)
489 obj.try_emplace(entry.first().str(), entry.second);
490 global_stats.try_emplace(
"totalSymbolLocatorTime", std::move(obj));
494 json::Object json_memory{
495 {
"strings", const_string_stats.
ToJSON()},
497 global_stats.try_emplace(
"memory", std::move(json_memory));
499 json::Value cmd_stats = debugger.GetCommandInterpreter().GetStatistics();
500 global_stats.try_emplace(
"commands", std::move(cmd_stats));
503 if (include_modules) {
504 global_stats.try_emplace(
"modules", std::move(json_modules));
507 if (include_transcript) {
526 debugger.GetCommandInterpreter().GetTranscript();
527 if (transcript.
GetSize() != 0) {
529 llvm::raw_string_ostream ss(buffer);
530 json::OStream json_os(ss);
532 if (
auto json_transcript = llvm::json::parse(buffer))
533 global_stats.try_emplace(
"transcript",
534 std::move(json_transcript.get()));
537 "failed to parse transcript JSON: {0}");
541 if (include_plugins) {
545 return std::move(global_stats);