9#ifndef LLDB_TARGET_STATISTICS_H
10#define LLDB_TARGET_STATISTICS_H
17#include "llvm/ADT/StringMap.h"
18#include "llvm/Support/JSON.h"
37 using Duration = std::chrono::duration<double>;
44 void reset() {
value.store(0, std::memory_order_relaxed); }
47 value.fetch_add(std::chrono::duration_cast<InternalDuration>(dur).count(),
48 std::memory_order_relaxed);
96 void add(llvm::StringRef key,
double value) {
99 auto it =
map.find(key);
101 map.try_emplace(key, value);
106 for (
const auto &entry : map_to_merge.
map) {
107 add(entry.first(), entry.second);
110 llvm::StringMap<double>
map;
120 llvm::json::Value
ToJSON()
const;
147 llvm::json::Value
ToJSON()
const;
179 llvm::json::Value
ToJSON()
const;
244 return m_count.load(std::memory_order_relaxed);
251 llvm::json::Value
ToJSON()
const;
293 return iterator->second;
297 std::make_shared<SummaryStatistics>(provider.
GetName(),
299 return it.first->second;
302 llvm::json::Value
ToJSON();
364 static llvm::json::Value
static double elapsed(const StatsTimepoint &start, const StatsTimepoint &end)
static MemoryStats GetMemoryStats()
static void SetCollectingStats(bool enable)
static bool GetCollectingStats()
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.
A class that measures elapsed time in an exception safe way.
StatsDuration & m_elapsed_time
Elapsed time in seconds to increment when this object goes out of scope.
ElapsedTime(StatsDuration &opt_time)
StatsTimepoint m_start_time
Set to the start time when the object is created.
A class to count time for plugins.
llvm::StringMap< double > map
void add(llvm::StringRef key, double value)
void merge(StatisticsMap map_to_merge)
std::atomic< uint64_t > value
std::chrono::duration< double > Duration
StatsDuration & operator+=(Duration dur)
std::chrono::duration< uint64_t, std::micro > InternalDuration
A class that wraps a std::map of SummaryStatistics objects behind a mutex.
llvm::StringMap< SummaryStatisticsSP > m_summary_stats_map
llvm::json::Value ToJSON()
SummaryStatisticsSP GetSummaryStatisticsForProvider(lldb_private::TypeSummaryImpl &provider)
Get the SummaryStatistics object for a given provider name, or insert if statistics for that provider...
SummaryStatisticsSP m_stats
SummaryInvocation & operator=(const SummaryInvocation &)=delete
ElapsedTime m_elapsed_time
SummaryInvocation(const SummaryInvocation &)=delete
Delete the copy constructor and assignment operator to prevent accidental double counting.
SummaryInvocation(SummaryStatisticsSP summary_stats)
A class that represents statistics about a TypeSummaryProviders invocations.
double GetTotalTime() const
void OnInvoked() noexcept
const std::string m_impl_type
llvm::json::Value ToJSON() const
std::string GetSummaryKindName() const
SummaryStatistics(std::string name, std::string impl_type)
std::atomic< uint64_t > m_count
std::string GetName() const
uint64_t GetSummaryCount() const
StatsDuration & GetDurationReference()
lldb_private::StatsDuration m_total_time
A class that represents statistics for a since lldb_private::Target.
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)
StatsSuccessFail & GetFrameVariableStats()
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)
StatsDuration & GetCreateTime()
uint32_t m_source_realpath_compatible_count
void SetFirstPrivateStopTime()
StatsSuccessFail & GetExpressionStats()
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
virtual std::string GetName()=0
Get the name of the Type Summary Provider, either a C++ class, a summary string, or a script function...
virtual std::string GetSummaryKindName()
Get the name of the kind of Summary Provider, either c++, summary string, script or python.
A class that represents a running process on the host machine.
std::chrono::high_resolution_clock StatsClock
std::shared_ptr< SummaryStatistics > SummaryStatisticsSP
std::chrono::time_point< StatsClock > StatsTimepoint
ConstString::MemoryStats stats
llvm::json::Value ToJSON() const
Holds statistics about DWO (Debug With Object) files.
friend DWOStats operator+(DWOStats lhs, const DWOStats &rhs)
DWOStats & operator+=(const DWOStats &rhs)
uint32_t loaded_dwo_file_count
A class that represents statistics for a since lldb_private::Module.
bool debug_info_index_saved_to_cache
bool debug_info_had_variable_errors
uint32_t symtab_symbol_count
llvm::json::Value ToJSON() const
llvm::StringMap< llvm::json::Value > type_system_stats
StatisticsMap symbol_locator_time
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
void SetIncludePlugins(bool value)
bool GetIncludeModules() const
std::optional< bool > m_load_all_debug_info
bool GetIncludePlugins() const
void SetIncludeTranscript(bool value)
void SetSummaryOnly(bool value)
std::optional< bool > m_include_plugins
bool GetSummaryOnly() const
std::optional< bool > m_include_modules
std::optional< bool > m_include_transcript
void SetIncludeModules(bool value)
bool GetIncludeTargets() const
bool GetLoadAllDebugInfo() const
std::optional< bool > m_summary_only
std::optional< bool > m_include_targets
void SetLoadAllDebugInfo(bool value)
void SetIncludeTargets(bool value)
A class to count success/fail statistics.
StatsSuccessFail(llvm::StringRef n)
llvm::json::Value ToJSON() const