Skip to content

Commit abf234c

Browse files
author
jeffreytan81
committed
Report statistics per target
1 parent 61a4678 commit abf234c

File tree

16 files changed

+127
-4
lines changed

16 files changed

+127
-4
lines changed

lldb/include/lldb/API/SBDebugger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,8 @@ class LLDB_API SBDebugger {
426426

427427
SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier);
428428

429+
void ResetStatistics();
430+
429431
#ifndef SWIG
430432
/// Run the command interpreter.
431433
///

lldb/include/lldb/API/SBTarget.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ class LLDB_API SBTarget {
101101
/// A SBStructuredData with the statistics collected.
102102
lldb::SBStructuredData GetStatistics(SBStatisticsOptions options);
103103

104+
/// Reset the statistics collected for this target.
105+
void ResetStatistics();
106+
104107
/// Return the platform object associated with the target.
105108
///
106109
/// After return, the platform object should be checked for

lldb/include/lldb/Core/Module.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,8 @@ class Module : public std::enable_shared_from_this<Module>,
880880
/// ElapsedTime RAII object.
881881
StatsDuration &GetSymtabIndexTime() { return m_symtab_index_time; }
882882

883+
void ResetStatistics();
884+
883885
/// \class LookupInfo Module.h "lldb/Core/Module.h"
884886
/// A class that encapsulates name lookup information.
885887
///

lldb/include/lldb/Symbol/SymbolFile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ class SymbolFile : public PluginInterface {
422422
/// hasn't been indexed yet, or a valid duration if it has.
423423
virtual StatsDuration::Duration GetDebugInfoIndexTime() { return {}; }
424424

425+
/// Reset the statistics for the symbol file.
426+
virtual void ResetStatistics() {}
427+
425428
/// Get the additional modules that this symbol file uses to parse debug info.
426429
///
427430
/// Some debug info is stored in stand alone object files that are represented

lldb/include/lldb/Symbol/SymbolFileOnDemand.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ class SymbolFileOnDemand : public lldb_private::SymbolFile {
182182
lldb_private::StatsDuration::Duration GetDebugInfoParseTime() override;
183183
lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override;
184184

185+
void ResetStatistics() override;
186+
185187
uint32_t GetAbilities() override;
186188

187189
Symtab *GetSymtab() override { return m_sym_file_impl->GetSymtab(); }

lldb/include/lldb/Target/Statistics.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class StatsDuration {
4141
}
4242
operator Duration() const { return get(); }
4343

44+
void reset() { value.store(0, std::memory_order_relaxed); }
45+
4446
StatsDuration &operator+=(Duration dur) {
4547
value.fetch_add(std::chrono::duration_cast<InternalDuration>(dur).count(),
4648
std::memory_order_relaxed);
@@ -311,6 +313,16 @@ class DebuggerStats {
311313
ReportStatistics(Debugger &debugger, Target *target,
312314
const lldb_private::StatisticsOptions &options);
313315

316+
/// Reset metrics associated with one or all targets in a debugger.
317+
///
318+
/// \param debugger
319+
/// The debugger to reset the target list from if \a target is NULL.
320+
///
321+
/// \param target
322+
/// The target to reset statistics for, or if null, reset statistics
323+
/// for all targets
324+
static void ResetStatistics(Debugger &debugger, Target *target);
325+
314326
protected:
315327
// Collecting stats can be set to true to collect stats that are expensive
316328
// to collect. By default all stats that are cheap to collect are enabled.

lldb/source/API/SBDebugger.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1667,6 +1667,12 @@ SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) {
16671667
DataVisualization::GetSyntheticForType(type_name.GetSP()));
16681668
}
16691669

1670+
void SBDebugger::ResetStatistics() {
1671+
LLDB_INSTRUMENT_VA(this);
1672+
if (m_opaque_sp)
1673+
DebuggerStats::ResetStatistics(*m_opaque_sp, nullptr);
1674+
}
1675+
16701676
static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) {
16711677
if (categories == nullptr)
16721678
return {};

lldb/source/API/SBTarget.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ SBStructuredData SBTarget::GetStatistics(SBStatisticsOptions options) {
220220
return data;
221221
}
222222

223+
void SBTarget::ResetStatistics() {
224+
LLDB_INSTRUMENT_VA(this);
225+
TargetSP target_sp(GetSP());
226+
if (target_sp)
227+
DebuggerStats::ResetStatistics(target_sp->GetDebugger(), target_sp.get());
228+
}
229+
223230
void SBTarget::SetCollectingStats(bool v) {
224231
LLDB_INSTRUMENT_VA(this, v);
225232

lldb/source/Core/Module.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,6 +1600,15 @@ bool Module::MergeArchitecture(const ArchSpec &arch_spec) {
16001600
return SetArchitecture(merged_arch);
16011601
}
16021602

1603+
void Module::ResetStatistics() {
1604+
m_symtab_parse_time.reset();
1605+
m_symtab_index_time.reset();
1606+
SymbolFile *sym_file = GetSymbolFile();
1607+
if (sym_file) {
1608+
sym_file->ResetStatistics();
1609+
}
1610+
}
1611+
16031612
llvm::VersionTuple Module::GetVersion() {
16041613
if (ObjectFile *obj_file = GetObjectFile())
16051614
return obj_file->GetVersion();

lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ class DWARFIndex {
8383

8484
StatsDuration::Duration GetIndexTime() { return m_index_time; }
8585

86+
void ResetStatistics() { m_index_time.reset(); }
87+
8688
protected:
8789
Module &m_module;
8890
StatsDuration m_index_time;

0 commit comments

Comments
 (0)