-
Notifications
You must be signed in to change notification settings - Fork 12.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix statistics dump to report per-target #113723
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,6 +101,11 @@ class LLDB_API SBTarget { | |
/// A SBStructuredData with the statistics collected. | ||
lldb::SBStructuredData GetStatistics(SBStatisticsOptions options); | ||
|
||
/// Reset the statistics collected for this target. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Document this a bit better with more explanation |
||
/// This includes clearing symbol table and debug info parsing/index time for | ||
/// all modules, breakpoint resolve time and target statistics. | ||
void ResetStatistics(); | ||
|
||
/// Return the platform object associated with the target. | ||
/// | ||
/// After return, the platform object should be checked for | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1667,6 +1667,12 @@ SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) { | |
DataVisualization::GetSyntheticForType(type_name.GetSP())); | ||
} | ||
|
||
void SBDebugger::ResetStatistics() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we add a |
||
LLDB_INSTRUMENT_VA(this); | ||
if (m_opaque_sp) | ||
DebuggerStats::ResetStatistics(*m_opaque_sp, nullptr); | ||
} | ||
|
||
static llvm::ArrayRef<const char *> GetCategoryArray(const char **categories) { | ||
if (categories == nullptr) | ||
return {}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -201,6 +201,24 @@ TargetStats::ToJSON(Target &target, | |
return target_metrics_json; | ||
} | ||
|
||
void TargetStats::Reset(Target &target) { | ||
m_launch_or_attach_time.reset(); | ||
m_first_private_stop_time.reset(); | ||
m_first_public_stop_time.reset(); | ||
// Report both the normal breakpoint list and the internal breakpoint list. | ||
for (int i = 0; i < 2; ++i) { | ||
BreakpointList &breakpoints = target.GetBreakpointList(i == 1); | ||
std::unique_lock<std::recursive_mutex> lock; | ||
breakpoints.GetListMutex(lock); | ||
size_t num_breakpoints = breakpoints.GetSize(); | ||
for (size_t i = 0; i < num_breakpoints; i++) { | ||
Breakpoint *bp = breakpoints.GetBreakpointAtIndex(i).get(); | ||
bp->ResetStatistics(); | ||
} | ||
} | ||
target.GetSummaryStatisticsCache().Reset(); | ||
} | ||
|
||
void TargetStats::SetLaunchOrAttachTime() { | ||
m_launch_or_attach_time = StatsClock::now(); | ||
m_first_private_stop_time = std::nullopt; | ||
|
@@ -236,6 +254,28 @@ void TargetStats::IncreaseSourceRealpathCompatibleCount(uint32_t count) { | |
|
||
bool DebuggerStats::g_collecting_stats = false; | ||
|
||
void DebuggerStats::ResetStatistics(Debugger &debugger, Target *target) { | ||
std::lock_guard<std::recursive_mutex> guard( | ||
Module::GetAllocationModuleCollectionMutex()); | ||
const uint64_t num_modules = target != nullptr | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to lock the |
||
? target->GetImages().GetSize() | ||
: Module::GetNumberAllocatedModules(); | ||
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { | ||
Module *module = target != nullptr | ||
? target->GetImages().GetModuleAtIndex(image_idx).get() | ||
: Module::GetAllocatedModuleAtIndex(image_idx); | ||
if (module == nullptr) | ||
continue; | ||
module->ResetStatistics(); | ||
} | ||
if (target) | ||
target->ResetStatistics(); | ||
else { | ||
for (const auto &target : debugger.GetTargetList().Targets()) | ||
target->ResetStatistics(); | ||
} | ||
} | ||
|
||
llvm::json::Value DebuggerStats::ReportStatistics( | ||
Debugger &debugger, Target *target, | ||
const lldb_private::StatisticsOptions &options) { | ||
|
@@ -261,14 +301,18 @@ llvm::json::Value DebuggerStats::ReportStatistics( | |
std::vector<ModuleStats> modules; | ||
std::lock_guard<std::recursive_mutex> guard( | ||
Module::GetAllocationModuleCollectionMutex()); | ||
const uint64_t num_modules = Module::GetNumberAllocatedModules(); | ||
const uint64_t num_modules = target != nullptr | ||
? target->GetImages().GetSize() | ||
: Module::GetNumberAllocatedModules(); | ||
uint32_t num_debug_info_enabled_modules = 0; | ||
uint32_t num_modules_has_debug_info = 0; | ||
uint32_t num_modules_with_variable_errors = 0; | ||
uint32_t num_modules_with_incomplete_types = 0; | ||
uint32_t num_stripped_modules = 0; | ||
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) { | ||
Module *module = Module::GetAllocatedModuleAtIndex(image_idx); | ||
Module *module = target != nullptr | ||
? target->GetImages().GetModuleAtIndex(image_idx).get() | ||
: Module::GetAllocatedModuleAtIndex(image_idx); | ||
ModuleStats module_stat; | ||
module_stat.symtab_parse_time = module->GetSymtabParseTime().get().count(); | ||
module_stat.symtab_index_time = module->GetSymtabIndexTime().get().count(); | ||
|
@@ -440,3 +484,8 @@ json::Value SummaryStatisticsCache::ToJSON() { | |
|
||
return json_summary_stats; | ||
} | ||
|
||
void SummaryStatisticsCache::Reset() { | ||
for (const auto &summary_stat : m_summary_stats_map) | ||
summary_stat.second->Reset(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Test that the lldb command `statistics` works. | ||
|
||
int main(void) { | ||
return 0; // break here | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a header doc comment for this to document what this will do:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments added. I do not think we need to clear any breakpoint stats because they are not reused across debug sessions by "reuse lldb-dap"