26 const std::string &str) {
29 if (LLVM_LIKELY(llvm::json::isUTF8(str)))
30 obj.try_emplace(key, str);
32 obj.try_emplace(key, llvm::json::fixUTF8(str));
41 end.time_since_epoch() - start.time_since_epoch();
64 module.try_emplace(
"debugInfoIndexLoadedFromCache",
66 module.try_emplace(
"debugInfoIndexSavedToCache",
69 module.try_emplace(
"debugInfoHadVariableErrors",
71 module.try_emplace(
"debugInfoHadIncompleteTypes",
78 json::Array symfile_ids;
80 symfile_ids.emplace_back(symfile_id);
81 module.try_emplace(
"symbolFileModuleIdentifiers", std::move(symfile_ids));
85 json::Array type_systems;
88 obj.try_emplace(entry.first().str(), entry.second);
89 type_systems.emplace_back(std::move(obj));
91 module.try_emplace(
"typeSystemInfo", std::move(type_systems));
108 json::Object target_metrics_json;
115 json::Array json_module_uuid_array;
117 json_module_uuid_array.emplace_back(module_identifier);
122 target_metrics_json.try_emplace(
"moduleIdentifiers",
123 std::move(json_module_uuid_array));
126 double elapsed_time =
128 target_metrics_json.try_emplace(
"launchOrAttachTime", elapsed_time);
131 double elapsed_time =
133 target_metrics_json.try_emplace(
"firstStopTime", elapsed_time);
135 target_metrics_json.try_emplace(
"targetCreateTime",
138 json::Array breakpoints_array;
139 double totalBreakpointResolveTime = 0.0;
141 for (
int i = 0; i < 2; ++i) {
143 std::unique_lock<std::recursive_mutex> lock;
145 size_t num_breakpoints = breakpoints.
GetSize();
146 for (
size_t i = 0; i < num_breakpoints; i++) {
152 target_metrics_json.try_emplace(
"breakpoints",
153 std::move(breakpoints_array));
154 target_metrics_json.try_emplace(
"totalBreakpointResolveTime",
155 totalBreakpointResolveTime);
158 UnixSignalsSP unix_signals_sp = process_sp->GetUnixSignals();
160 target_metrics_json.try_emplace(
161 "signals", unix_signals_sp->GetHitCountStatistics());
168 uint32_t shared_library_event_breakpoint_hit_count = 0;
171 std::unique_lock<std::recursive_mutex> lock;
173 size_t num_breakpoints = breakpoints.
GetSize();
174 for (
size_t i = 0; i < num_breakpoints; i++) {
177 shared_library_event_breakpoint_hit_count += bp->
GetHitCount();
180 target_metrics_json.try_emplace(
"totalSharedLibraryEventHitCount",
181 shared_library_event_breakpoint_hit_count);
185 uint32_t stop_id = process_sp->GetStopID();
186 target_metrics_json.try_emplace(
"stopCount", stop_id);
188 llvm::StringRef dyld_plugin_name;
189 if (process_sp->GetDynamicLoader())
190 dyld_plugin_name = process_sp->GetDynamicLoader()->GetPluginName();
191 target_metrics_json.try_emplace(
"dyldPluginName", dyld_plugin_name);
193 target_metrics_json.try_emplace(
"sourceMapDeduceCount",
195 target_metrics_json.try_emplace(
"sourceRealpathAttemptCount",
197 target_metrics_json.try_emplace(
"sourceRealpathCompatibleCount",
199 target_metrics_json.try_emplace(
"summaryProviderStatistics",
201 return target_metrics_json;
209 for (
int i = 0; i < 2; ++i) {
211 std::unique_lock<std::recursive_mutex> lock;
213 size_t num_breakpoints = breakpoints.
GetSize();
214 for (
size_t i = 0; i < num_breakpoints; i++) {
258 std::lock_guard<std::recursive_mutex> guard(
260 const uint64_t num_modules = target !=
nullptr
263 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
264 Module *module = target !=
nullptr
267 if (module ==
nullptr)
289 json::Array json_targets;
290 json::Array json_modules;
291 double symtab_parse_time = 0.0;
292 double symtab_index_time = 0.0;
293 double debug_parse_time = 0.0;
294 double debug_index_time = 0.0;
295 uint32_t symtabs_loaded = 0;
296 uint32_t symtabs_saved = 0;
297 uint32_t debug_index_loaded = 0;
298 uint32_t debug_index_saved = 0;
299 uint64_t debug_info_size = 0;
301 std::vector<ModuleStats> modules;
302 std::lock_guard<std::recursive_mutex> guard(
304 const uint64_t num_modules = target !=
nullptr
307 uint32_t num_debug_info_enabled_modules = 0;
308 uint32_t num_modules_has_debug_info = 0;
309 uint32_t num_modules_with_variable_errors = 0;
310 uint32_t num_modules_with_incomplete_types = 0;
311 uint32_t num_stripped_modules = 0;
312 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
313 Module *module = target !=
nullptr
335 for (
const auto &symbol_module : symbol_modules.
Modules())
341 ++debug_index_loaded;
352 ++num_stripped_modules;
358 ++num_debug_info_enabled_modules;
360 ++num_modules_has_debug_info;
362 ++num_modules_with_variable_errors;
370 if (
auto stats = ts->ReportStatistics())
372 if (ts->GetHasForcefullyCompletedTypes())
377 ++num_modules_with_incomplete_types;
379 if (include_modules) {
383 module_stat.
path.append(1,
'(');
384 module_stat.
path.append(object_name.GetStringRef().str());
385 module_stat.
path.append(1,
')');
389 json_modules.emplace_back(module_stat.
ToJSON());
393 json::Object global_stats{
394 {
"totalSymbolTableParseTime", symtab_parse_time},
395 {
"totalSymbolTableIndexTime", symtab_index_time},
396 {
"totalSymbolTablesLoadedFromCache", symtabs_loaded},
397 {
"totalSymbolTablesSavedToCache", symtabs_saved},
398 {
"totalDebugInfoParseTime", debug_parse_time},
399 {
"totalDebugInfoIndexTime", debug_index_time},
400 {
"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
401 {
"totalDebugInfoIndexSavedToCache", debug_index_saved},
402 {
"totalDebugInfoByteSize", debug_info_size},
403 {
"totalModuleCount", num_modules},
404 {
"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
405 {
"totalModuleCountWithVariableErrors", num_modules_with_variable_errors},
406 {
"totalModuleCountWithIncompleteTypes",
407 num_modules_with_incomplete_types},
408 {
"totalDebugInfoEnabled", num_debug_info_enabled_modules},
409 {
"totalSymbolTableStripped", num_stripped_modules},
412 if (include_targets) {
419 global_stats.try_emplace(
"targets", std::move(json_targets));
423 json::Object json_memory{
424 {
"strings", const_string_stats.
ToJSON()},
426 global_stats.try_emplace(
"memory", std::move(json_memory));
429 global_stats.try_emplace(
"commands", std::move(cmd_stats));
432 if (include_modules) {
433 global_stats.try_emplace(
"modules", std::move(json_modules));
436 if (include_transcript) {
456 if (transcript.
GetSize() != 0) {
458 llvm::raw_string_ostream ss(buffer);
459 json::OStream json_os(ss);
461 if (
auto json_transcript = llvm::json::parse(buffer))
462 global_stats.try_emplace(
"transcript",
463 std::move(json_transcript.get()));
467 return std::move(global_stats);
471 return json::Object{{
481 json::Array json_summary_stats;
483 json_summary_stats.emplace_back(summary_stat.second->ToJSON());
485 return json_summary_stats;
490 summary_stat.second->Reset();
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
static void EmplaceSafeString(llvm::json::Object &obj, llvm::StringRef key, const std::string &str)
llvm::Triple & GetTriple()
Architecture triple accessor.
General Outline: Allows adding and removing breakpoints and find by ID and index.
void GetListMutex(std::unique_lock< std::recursive_mutex > &lock)
Sets the passed in Locker to hold the Breakpoint List mutex.
size_t GetSize() const
Returns the number of elements in this breakpoint list.
lldb::BreakpointSP GetBreakpointAtIndex(size_t i) const
Returns a shared pointer to the breakpoint with index i.
General Outline: A breakpoint has four main parts, a filter, a resolver, the list of breakpoint locat...
llvm::json::Value GetStatistics()
Get statistics associated with this breakpoint in JSON format.
const char * GetBreakpointKind() const
Return the "kind" description for a breakpoint.
uint32_t GetHitCount() const
Return the current hit count for all locations.
StatsDuration::Duration GetResolveTime() const
Get the time it took to resolve all locations in this breakpoint.
llvm::json::Value GetStatistics()
const StructuredData::Array & GetTranscript() const
A uniqued constant string class.
static bool g_collecting_stats
static void ResetStatistics(Debugger &debugger, Target *target)
Reset metrics associated with one or all targets in a debugger.
static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target, const lldb_private::StatisticsOptions &options)
Get metrics associated with one or all targets in a debugger in JSON format.
A class to manage flag bits.
CommandInterpreter & GetCommandInterpreter()
TargetList & GetTargetList()
Get accessor for the target list.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
A collection class for Module objects.
lldb::ModuleSP GetModuleAtIndex(size_t idx) const
Get the module shared pointer for the module at index idx.
ModuleIterable Modules() const
size_t GetSize() const
Gets the size of the module list.
A class that describes an executable image and its associated object and symbol files.
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
ConstString GetObjectName() const
static Module * GetAllocatedModuleAtIndex(size_t idx)
static std::recursive_mutex & GetAllocationModuleCollectionMutex()
static size_t GetNumberAllocatedModules()
void ForEachTypeSystem(llvm::function_ref< bool(lldb::TypeSystemSP)> callback)
Call callback for each TypeSystem in this Module.
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
StatsDuration & GetSymtabIndexTime()
Accessor for the symbol table index time metric.
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
StatsDuration & GetSymtabParseTime()
Accessor for the symbol table parse time metric.
virtual bool IsStripped()=0
Detect if this object file has been stripped of local symbols.
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
std::chrono::duration< double > Duration
void Serialize(llvm::json::OStream &s) const override
llvm::StringMap< SummaryStatisticsSP > m_summary_stats_map
llvm::json::Value ToJSON()
double GetTotalTime() const
llvm::json::Value ToJSON() const
std::string GetSummaryKindName() const
std::string GetName() const
uint64_t GetSummaryCount() const
Provides public interface for all SymbolFiles.
virtual uint64_t GetDebugInfoSize(bool load_all_debug_info=false)=0
Metrics gathering functions.
virtual bool GetDebugInfoIndexWasLoadedFromCache() const =0
Accessors for the bool that indicates if the debug info index was loaded from, or saved to the module...
virtual bool GetDebugInfoIndexWasSavedToCache() const =0
virtual StatsDuration::Duration GetDebugInfoParseTime()
Return the time taken to parse the debug information.
virtual bool GetLoadDebugInfoEnabled()
Whether debug info will be loaded or not.
virtual bool GetDebugInfoHadFrameVariableErrors() const =0
Accessors for the bool that indicates if there was debug info, but errors stopped variables from bein...
virtual ModuleList GetDebugInfoModules()
Get the additional modules that this symbol file uses to parse debug info.
virtual StatsDuration::Duration GetDebugInfoIndexTime()
Return the time it took to index the debug information in the object file.
virtual ObjectFile * GetObjectFile()=0
bool GetWasLoadedFromCache() const
Accessors for the bool that indicates if the debug info index was loaded from, or saved to the module...
bool GetWasSavedToCache() const
void IncreaseSourceMapDeduceCount()
void Reset(Target &target)
StatsSuccessFail m_frame_var
std::optional< StatsTimepoint > m_launch_or_attach_time
uint32_t m_source_map_deduce_count
void CollectStats(Target &target)
llvm::json::Value ToJSON(Target &target, const lldb_private::StatisticsOptions &options)
StatsDuration m_create_time
std::optional< StatsTimepoint > m_first_public_stop_time
void IncreaseSourceRealpathAttemptCount(uint32_t count)
uint32_t m_source_realpath_compatible_count
void SetFirstPrivateStopTime()
StatsSuccessFail m_expr_eval
std::vector< intptr_t > m_module_identifiers
void SetFirstPublicStopTime()
uint32_t m_source_realpath_attempt_count
void SetLaunchOrAttachTime()
void IncreaseSourceRealpathCompatibleCount(uint32_t count)
std::optional< StatsTimepoint > m_first_private_stop_time
BreakpointList & GetBreakpointList(bool internal=false)
lldb_private::SummaryStatisticsCache & GetSummaryStatisticsCache()
const lldb::ProcessSP & GetProcessSP() const
llvm::json::Value ReportStatistics(const lldb_private::StatisticsOptions &options)
Get metrics associated with this target in JSON format.
const ModuleList & GetImages() const
Get accessor for the images for this process.
std::string GetAsString(llvm::StringRef separator="-") const
A class that represents a running process on the host machine.
std::chrono::time_point< StatsClock > StatsTimepoint
std::shared_ptr< lldb_private::TypeSystem > TypeSystemSP
std::shared_ptr< lldb_private::UnixSignals > UnixSignalsSP
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Module > ModuleSP
ConstString::MemoryStats stats
llvm::json::Value ToJSON() const
size_t GetBytesUnused() const
size_t GetBytesTotal() const
size_t GetBytesUsed() const
A class that represents statistics for a since lldb_private::Module.
bool debug_info_index_saved_to_cache
bool debug_info_had_variable_errors
llvm::json::Value ToJSON() const
llvm::StringMap< llvm::json::Value > type_system_stats
bool debug_info_had_incomplete_types
bool symtab_saved_to_cache
std::vector< intptr_t > symfile_modules
bool symtab_loaded_from_cache
bool debug_info_index_loaded_from_cache
bool GetIncludeTranscript() const
bool GetIncludeModules() const
bool GetSummaryOnly() const
bool GetIncludeTargets() const
bool GetLoadAllDebugInfo() const
llvm::json::Value ToJSON() const