From 833fb7d87064111e031dccb2d707b004b2c7a354 Mon Sep 17 00:00:00 2001 From: yangguo Date: Thu, 26 Nov 2015 02:41:20 -0800 Subject: [PATCH] [debugger] track debugger feature usage via histogram. R=jochen@chromium.org Review URL: https://codereview.chromium.org/1478613004 Cr-Commit-Position: refs/heads/master@{#32328} --- src/counters.h | 3 ++- src/debug/debug.cc | 19 +++++++++++++++++++ src/debug/debug.h | 27 +++++++++++++++++++++++++++ src/profiler/cpu-profiler.cc | 2 ++ src/profiler/heap-profiler.cc | 7 +++++++ src/runtime/runtime-liveedit.cc | 2 ++ 6 files changed, 59 insertions(+), 1 deletion(-) diff --git a/src/counters.h b/src/counters.h index 7f66ff0a77..87eca24498 100644 --- a/src/counters.h +++ b/src/counters.h @@ -484,7 +484,8 @@ double AggregatedMemoryHistogram::Aggregate(double current_ms, HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \ 101) \ HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6) \ - HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20) + HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20) \ + HR(debug_feature_usage, V8.DebugFeatureUsage, 1, 7, 7) #define HISTOGRAM_TIMER_LIST(HT) \ /* Garbage collection timers. */ \ diff --git a/src/debug/debug.cc b/src/debug/debug.cc index 3830d8eed8..798a2f4e43 100644 --- a/src/debug/debug.cc +++ b/src/debug/debug.cc @@ -43,6 +43,7 @@ Debug::Debug(Isolate* isolate) break_on_exception_(false), break_on_uncaught_exception_(false), debug_info_list_(NULL), + feature_tracker_(isolate), isolate_(isolate) { ThreadInit(); } @@ -316,6 +317,15 @@ Handle BreakLocation::BreakPointObjects() const { } +void DebugFeatureTracker::Track(DebugFeatureTracker::Feature feature) { + uint32_t mask = 1 << feature; + // Only count one sample per feature and isolate. + if (bitfield_ & mask) return; + isolate_->counters()->debug_feature_usage()->AddSample(feature); + bitfield_ |= mask; +} + + // Threading support. void Debug::ThreadInit() { thread_local_.break_count_ = 0; @@ -396,6 +406,9 @@ bool Debug::Load() { debug_context_ = Handle::cast( isolate_->global_handles()->Create(*context)); + + feature_tracker()->Track(DebugFeatureTracker::kActive); + return true; } @@ -625,6 +638,8 @@ bool Debug::SetBreakPoint(Handle function, *source_position = location.statement_position(); location.SetBreakPoint(break_point_object); + feature_tracker()->Track(DebugFeatureTracker::kBreakPoint); + // At least one active break point now. return debug_info->GetBreakPointCount() > 0; } @@ -666,6 +681,8 @@ bool Debug::SetBreakPointForScript(Handle