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 return target_metrics_json;
235 json::Array json_targets;
236 json::Array json_modules;
237 double symtab_parse_time = 0.0;
238 double symtab_index_time = 0.0;
239 double debug_parse_time = 0.0;
240 double debug_index_time = 0.0;
241 uint32_t symtabs_loaded = 0;
242 uint32_t symtabs_saved = 0;
243 uint32_t debug_index_loaded = 0;
244 uint32_t debug_index_saved = 0;
245 uint64_t debug_info_size = 0;
247 std::vector<ModuleStats> modules;
248 std::lock_guard<std::recursive_mutex> guard(
251 uint32_t num_debug_info_enabled_modules = 0;
252 uint32_t num_modules_has_debug_info = 0;
253 uint32_t num_modules_with_variable_errors = 0;
254 uint32_t num_modules_with_incomplete_types = 0;
255 uint32_t num_stripped_modules = 0;
256 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
277 for (
const auto &symbol_module : symbol_modules.
Modules())
283 ++debug_index_loaded;
294 ++num_stripped_modules;
300 ++num_debug_info_enabled_modules;
302 ++num_modules_has_debug_info;
304 ++num_modules_with_variable_errors;
312 if (
auto stats = ts->ReportStatistics())
314 if (ts->GetHasForcefullyCompletedTypes())
319 ++num_modules_with_incomplete_types;
321 if (include_modules) {
325 module_stat.
path.append(1,
'(');
326 module_stat.
path.append(object_name.GetStringRef().str());
327 module_stat.
path.append(1,
')');
331 json_modules.emplace_back(module_stat.
ToJSON());
335 json::Object global_stats{
336 {
"totalSymbolTableParseTime", symtab_parse_time},
337 {
"totalSymbolTableIndexTime", symtab_index_time},
338 {
"totalSymbolTablesLoadedFromCache", symtabs_loaded},
339 {
"totalSymbolTablesSavedToCache", symtabs_saved},
340 {
"totalDebugInfoParseTime", debug_parse_time},
341 {
"totalDebugInfoIndexTime", debug_index_time},
342 {
"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
343 {
"totalDebugInfoIndexSavedToCache", debug_index_saved},
344 {
"totalDebugInfoByteSize", debug_info_size},
345 {
"totalModuleCount", num_modules},
346 {
"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
347 {
"totalModuleCountWithVariableErrors", num_modules_with_variable_errors},
348 {
"totalModuleCountWithIncompleteTypes",
349 num_modules_with_incomplete_types},
350 {
"totalDebugInfoEnabled", num_debug_info_enabled_modules},
351 {
"totalSymbolTableStripped", num_stripped_modules},
354 if (include_targets) {
361 global_stats.try_emplace(
"targets", std::move(json_targets));
365 json::Object json_memory{
366 {
"strings", const_string_stats.
ToJSON()},
368 global_stats.try_emplace(
"memory", std::move(json_memory));
371 global_stats.try_emplace(
"commands", std::move(cmd_stats));
374 if (include_modules) {
375 global_stats.try_emplace(
"modules", std::move(json_modules));
378 if (include_transcript) {
398 if (transcript.
GetSize() != 0) {
400 llvm::raw_string_ostream ss(buffer);
401 json::OStream json_os(ss);
403 if (
auto json_transcript = llvm::json::parse(ss.str()))
404 global_stats.try_emplace(
"transcript",
405 std::move(json_transcript.get()));
409 return std::move(global_stats);
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 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.
ModuleIterable Modules() const
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
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()
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 SetFirstPrivateStopTime()
StatsSuccessFail m_expr_eval
std::vector< intptr_t > m_module_identifiers
void SetFirstPublicStopTime()
void SetLaunchOrAttachTime()
std::optional< StatsTimepoint > m_first_private_stop_time
BreakpointList & GetBreakpointList(bool internal=false)
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