Skip to content

Commit debd58e

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

File tree

13 files changed

+123
-4
lines changed

13 files changed

+123
-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/Symbol/SymbolFile.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,13 @@ 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 time taken to parse the debug information.
426+
virtual void ResetDebugInfoParseTime() {}
427+
428+
/// Reset the time it took to index the debug information in the object
429+
/// file.
430+
virtual void ResetDebugInfoIndexTime() {}
431+
425432
/// Get the additional modules that this symbol file uses to parse debug info.
426433
///
427434
/// Some debug info is stored in stand alone object files that are represented

lldb/include/lldb/Symbol/SymbolFileOnDemand.h

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

185+
void ResetDebugInfoParseTime() override;
186+
void ResetDebugInfoIndexTime() override;
187+
185188
uint32_t GetAbilities() override;
186189

187190
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/Core/Debugger.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ void Debugger::Destroy(DebuggerSP &debugger_sp) {
789789
(*debugger_sp->GetAsyncErrorStream()) << result.GetErrorData() << '\n';
790790
}
791791

792+
DebuggerStats::ResetStatistics(*debugger_sp, nullptr);
792793
debugger_sp->Clear();
793794

794795
if (g_debugger_list_ptr && g_debugger_list_mutex_ptr) {

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 ResetIndexTime() { m_index_time.reset(); }
87+
8688
protected:
8789
Module &m_module;
8890
StatsDuration m_index_time;

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4464,6 +4464,11 @@ StatsDuration::Duration SymbolFileDWARF::GetDebugInfoIndexTime() {
44644464
return {};
44654465
}
44664466

4467+
void SymbolFileDWARF::ResetDebugInfoIndexTime() {
4468+
if (m_index)
4469+
return m_index->ResetIndexTime();
4470+
}
4471+
44674472
Status SymbolFileDWARF::CalculateFrameVariableError(StackFrame &frame) {
44684473
std::lock_guard<std::recursive_mutex> guard(GetModuleMutex());
44694474
CompileUnit *cu = frame.GetSymbolContext(eSymbolContextCompUnit).comp_unit;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,9 @@ class SymbolFileDWARF : public SymbolFileCommon {
318318

319319
StatsDuration &GetDebugInfoParseTimeRef() { return m_parse_time; }
320320

321+
void ResetDebugInfoParseTime() override { m_parse_time.reset(); }
322+
void ResetDebugInfoIndexTime() override;
323+
321324
virtual lldb::offset_t
322325
GetVendorDWARFOpcodeSize(const DataExtractor &data,
323326
const lldb::offset_t data_offset,

lldb/source/Symbol/SymbolFileOnDemand.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,18 @@ StatsDuration::Duration SymbolFileOnDemand::GetDebugInfoIndexTime() {
555555
return m_sym_file_impl->GetDebugInfoIndexTime();
556556
}
557557

558+
void SymbolFileOnDemand::ResetDebugInfoParseTime() {
559+
LLDB_LOG(GetLog(), "[{0}] {1} is not skipped", GetSymbolFileName(),
560+
__FUNCTION__);
561+
return m_sym_file_impl->ResetDebugInfoParseTime();
562+
}
563+
564+
void SymbolFileOnDemand::ResetDebugInfoIndexTime() {
565+
LLDB_LOG(GetLog(), "[{0}] {1} is not skipped", GetSymbolFileName(),
566+
__FUNCTION__);
567+
return m_sym_file_impl->ResetDebugInfoIndexTime();
568+
}
569+
558570
void SymbolFileOnDemand::SetLoadDebugInfoEnabled() {
559571
if (m_debug_info_enabled)
560572
return;

0 commit comments

Comments
 (0)