23 const std::string &str) {
26 if (LLVM_LIKELY(llvm::json::isUTF8(str)))
27 obj.try_emplace(key, str);
29 obj.try_emplace(key, llvm::json::fixUTF8(str));
38 end.time_since_epoch() - start.time_since_epoch();
61 module.try_emplace(
"debugInfoIndexLoadedFromCache",
63 module.try_emplace(
"debugInfoIndexSavedToCache",
66 module.try_emplace(
"debugInfoHadVariableErrors",
68 module.try_emplace(
"debugInfoHadIncompleteTypes",
75 json::Array symfile_ids;
77 symfile_ids.emplace_back(symfile_id);
78 module.try_emplace(
"symbolFileModuleIdentifiers", std::move(symfile_ids));
82 json::Array type_systems;
85 obj.try_emplace(entry.first().str(), entry.second);
86 type_systems.emplace_back(std::move(obj));
88 module.try_emplace(
"typeSystemInfo", std::move(type_systems));
105 json::Array json_module_uuid_array;
107 json_module_uuid_array.emplace_back(module_identifier);
109 json::Object target_metrics_json{
112 {
"moduleIdentifiers", std::move(json_module_uuid_array)}};
115 double elapsed_time =
117 target_metrics_json.try_emplace(
"launchOrAttachTime", elapsed_time);
120 double elapsed_time =
122 target_metrics_json.try_emplace(
"firstStopTime", elapsed_time);
124 target_metrics_json.try_emplace(
"targetCreateTime",
127 json::Array breakpoints_array;
128 double totalBreakpointResolveTime = 0.0;
130 for (
int i = 0; i < 2; ++i) {
132 std::unique_lock<std::recursive_mutex> lock;
134 size_t num_breakpoints = breakpoints.
GetSize();
135 for (
size_t i = 0; i < num_breakpoints; i++) {
144 UnixSignalsSP unix_signals_sp = process_sp->GetUnixSignals();
146 target_metrics_json.try_emplace(
"signals",
147 unix_signals_sp->GetHitCountStatistics());
148 uint32_t stop_id = process_sp->GetStopID();
149 target_metrics_json.try_emplace(
"stopCount", stop_id);
151 target_metrics_json.try_emplace(
"breakpoints", std::move(breakpoints_array));
152 target_metrics_json.try_emplace(
"totalBreakpointResolveTime",
153 totalBreakpointResolveTime);
156 return target_metrics_json;
188 json::Array json_targets;
189 json::Array json_modules;
190 double symtab_parse_time = 0.0;
191 double symtab_index_time = 0.0;
192 double debug_parse_time = 0.0;
193 double debug_index_time = 0.0;
194 uint32_t symtabs_loaded = 0;
195 uint32_t symtabs_saved = 0;
196 uint32_t debug_index_loaded = 0;
197 uint32_t debug_index_saved = 0;
198 uint64_t debug_info_size = 0;
205 std::vector<ModuleStats> modules;
206 std::lock_guard<std::recursive_mutex> guard(
209 uint32_t num_debug_info_enabled_modules = 0;
210 uint32_t num_modules_has_debug_info = 0;
211 uint32_t num_modules_with_variable_errors = 0;
212 uint32_t num_modules_with_incomplete_types = 0;
213 uint32_t num_stripped_modules = 0;
214 for (
size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
220 module_stat.
path.append(1,
'(');
221 module_stat.
path.append(object_name.GetStringRef().str());
222 module_stat.
path.append(1,
')');
249 ++debug_index_loaded;
255 for (
const auto &symbol_module: symbol_modules.
Modules())
259 ++num_stripped_modules;
265 ++num_debug_info_enabled_modules;
267 ++num_modules_has_debug_info;
269 ++num_modules_with_variable_errors;
277 if (
auto stats = ts->ReportStatistics())
279 if (ts->GetHasForcefullyCompletedTypes())
284 ++num_modules_with_incomplete_types;
286 json_modules.emplace_back(module_stat.
ToJSON());
290 json::Object json_memory{
291 {
"strings", const_string_stats.
ToJSON()},
294 json::Object global_stats{
295 {
"targets", std::move(json_targets)},
296 {
"modules", std::move(json_modules)},
297 {
"memory", std::move(json_memory)},
298 {
"totalSymbolTableParseTime", symtab_parse_time},
299 {
"totalSymbolTableIndexTime", symtab_index_time},
300 {
"totalSymbolTablesLoadedFromCache", symtabs_loaded},
301 {
"totalSymbolTablesSavedToCache", symtabs_saved},
302 {
"totalDebugInfoParseTime", debug_parse_time},
303 {
"totalDebugInfoIndexTime", debug_index_time},
304 {
"totalDebugInfoIndexLoadedFromCache", debug_index_loaded},
305 {
"totalDebugInfoIndexSavedToCache", debug_index_saved},
306 {
"totalDebugInfoByteSize", debug_info_size},
307 {
"totalModuleCount", num_modules},
308 {
"totalModuleCountHasDebugInfo", num_modules_has_debug_info},
309 {
"totalModuleCountWithVariableErrors", num_modules_with_variable_errors},
310 {
"totalModuleCountWithIncompleteTypes", num_modules_with_incomplete_types},
311 {
"totalDebugInfoEnabled", num_debug_info_enabled_modules},
312 {
"totalSymbolTableStripped", num_stripped_modules},
314 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.
StatsDuration::Duration GetResolveTime() const
Get the time it took to resolve all locations in this breakpoint.
A uniqued constant string class.
static bool g_collecting_stats
static llvm::json::Value ReportStatistics(Debugger &debugger, Target *target)
Get metrics associated with one or all targets in a debugger in JSON format.
A class to manage flag bits.
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
Provides public interface for all SymbolFiles.
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 uint64_t GetDebugInfoSize()=0
Metrics gathering functions.
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()
llvm::json::Value ToJSON(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)
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
const ModuleList & GetImages() const
Get accessor for the images for this process.
llvm::json::Value ReportStatistics()
Get metrics associated with this target in JSON format.
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
llvm::json::Value ToJSON() const