Commit 833fb7d8 authored by yangguo's avatar yangguo Committed by Commit bot

[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}
parent 8b192a2a
...@@ -484,7 +484,8 @@ double AggregatedMemoryHistogram<Histogram>::Aggregate(double current_ms, ...@@ -484,7 +484,8 @@ double AggregatedMemoryHistogram<Histogram>::Aggregate(double current_ms,
HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \ HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \
101) \ 101) \
HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6) \ 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) \ #define HISTOGRAM_TIMER_LIST(HT) \
/* Garbage collection timers. */ \ /* Garbage collection timers. */ \
......
...@@ -43,6 +43,7 @@ Debug::Debug(Isolate* isolate) ...@@ -43,6 +43,7 @@ Debug::Debug(Isolate* isolate)
break_on_exception_(false), break_on_exception_(false),
break_on_uncaught_exception_(false), break_on_uncaught_exception_(false),
debug_info_list_(NULL), debug_info_list_(NULL),
feature_tracker_(isolate),
isolate_(isolate) { isolate_(isolate) {
ThreadInit(); ThreadInit();
} }
...@@ -316,6 +317,15 @@ Handle<Object> BreakLocation::BreakPointObjects() const { ...@@ -316,6 +317,15 @@ Handle<Object> 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. // Threading support.
void Debug::ThreadInit() { void Debug::ThreadInit() {
thread_local_.break_count_ = 0; thread_local_.break_count_ = 0;
...@@ -396,6 +406,9 @@ bool Debug::Load() { ...@@ -396,6 +406,9 @@ bool Debug::Load() {
debug_context_ = Handle<Context>::cast( debug_context_ = Handle<Context>::cast(
isolate_->global_handles()->Create(*context)); isolate_->global_handles()->Create(*context));
feature_tracker()->Track(DebugFeatureTracker::kActive);
return true; return true;
} }
...@@ -625,6 +638,8 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function, ...@@ -625,6 +638,8 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function,
*source_position = location.statement_position(); *source_position = location.statement_position();
location.SetBreakPoint(break_point_object); location.SetBreakPoint(break_point_object);
feature_tracker()->Track(DebugFeatureTracker::kBreakPoint);
// At least one active break point now. // At least one active break point now.
return debug_info->GetBreakPointCount() > 0; return debug_info->GetBreakPointCount() > 0;
} }
...@@ -666,6 +681,8 @@ bool Debug::SetBreakPointForScript(Handle<Script> script, ...@@ -666,6 +681,8 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
debug_info, ALL_BREAK_LOCATIONS, position, alignment); debug_info, ALL_BREAK_LOCATIONS, position, alignment);
location.SetBreakPoint(break_point_object); location.SetBreakPoint(break_point_object);
feature_tracker()->Track(DebugFeatureTracker::kBreakPoint);
position = (alignment == STATEMENT_ALIGNED) ? location.statement_position() position = (alignment == STATEMENT_ALIGNED) ? location.statement_position()
: location.position(); : location.position();
...@@ -874,6 +891,8 @@ void Debug::PrepareStep(StepAction step_action, ...@@ -874,6 +891,8 @@ void Debug::PrepareStep(StepAction step_action,
JavaScriptFrameIterator frames_it(isolate_, id); JavaScriptFrameIterator frames_it(isolate_, id);
JavaScriptFrame* frame = frames_it.frame(); JavaScriptFrame* frame = frames_it.frame();
feature_tracker()->Track(DebugFeatureTracker::kStepping);
// First of all ensure there is one-shot break points in the top handler // First of all ensure there is one-shot break points in the top handler
// if any. // if any.
FloodHandlerWithOneShot(); FloodHandlerWithOneShot();
......
...@@ -343,6 +343,28 @@ class LockingCommandMessageQueue BASE_EMBEDDED { ...@@ -343,6 +343,28 @@ class LockingCommandMessageQueue BASE_EMBEDDED {
}; };
class DebugFeatureTracker {
public:
enum Feature {
kActive = 1,
kBreakPoint = 2,
kStepping = 3,
kHeapSnapshot = 4,
kAllocationTracking = 5,
kProfiler = 6,
kLiveEdit = 7,
};
explicit DebugFeatureTracker(Isolate* isolate)
: isolate_(isolate), bitfield_(0) {}
void Track(Feature feature);
private:
Isolate* isolate_;
uint32_t bitfield_;
};
// This class contains the debugger support. The main purpose is to handle // This class contains the debugger support. The main purpose is to handle
// setting break points in the code. // setting break points in the code.
// //
...@@ -508,6 +530,8 @@ class Debug { ...@@ -508,6 +530,8 @@ class Debug {
StepAction last_step_action() { return thread_local_.last_step_action_; } StepAction last_step_action() { return thread_local_.last_step_action_; }
DebugFeatureTracker* feature_tracker() { return &feature_tracker_; }
private: private:
explicit Debug(Isolate* isolate); explicit Debug(Isolate* isolate);
...@@ -606,6 +630,9 @@ class Debug { ...@@ -606,6 +630,9 @@ class Debug {
// before returning to the DebugBreakCallHelper. // before returning to the DebugBreakCallHelper.
Address after_break_target_; Address after_break_target_;
// Used to collect histogram data on debugger feature usage.
DebugFeatureTracker feature_tracker_;
// Per-thread data. // Per-thread data.
class ThreadLocal { class ThreadLocal {
public: public:
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "src/profiler/cpu-profiler.h" #include "src/profiler/cpu-profiler.h"
#include "src/debug/debug.h"
#include "src/deoptimizer.h" #include "src/deoptimizer.h"
#include "src/frames-inl.h" #include "src/frames-inl.h"
#include "src/locked-queue-inl.h" #include "src/locked-queue-inl.h"
...@@ -438,6 +439,7 @@ void CpuProfiler::StartProfiling(const char* title, bool record_samples) { ...@@ -438,6 +439,7 @@ void CpuProfiler::StartProfiling(const char* title, bool record_samples) {
void CpuProfiler::StartProfiling(String* title, bool record_samples) { void CpuProfiler::StartProfiling(String* title, bool record_samples) {
StartProfiling(profiles_->GetName(title), record_samples); StartProfiling(profiles_->GetName(title), record_samples);
isolate_->debug()->feature_tracker()->Track(DebugFeatureTracker::kProfiler);
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "src/profiler/heap-profiler.h" #include "src/profiler/heap-profiler.h"
#include "src/api.h" #include "src/api.h"
#include "src/debug/debug.h"
#include "src/profiler/allocation-tracker.h" #include "src/profiler/allocation-tracker.h"
#include "src/profiler/heap-snapshot-generator-inl.h" #include "src/profiler/heap-snapshot-generator-inl.h"
...@@ -75,6 +76,10 @@ HeapSnapshot* HeapProfiler::TakeSnapshot( ...@@ -75,6 +76,10 @@ HeapSnapshot* HeapProfiler::TakeSnapshot(
} }
ids_->RemoveDeadEntries(); ids_->RemoveDeadEntries();
is_tracking_object_moves_ = true; is_tracking_object_moves_ = true;
heap()->isolate()->debug()->feature_tracker()->Track(
DebugFeatureTracker::kHeapSnapshot);
return result; return result;
} }
...@@ -86,6 +91,8 @@ void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) { ...@@ -86,6 +91,8 @@ void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) {
if (track_allocations) { if (track_allocations) {
allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get())); allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get()));
heap()->DisableInlineAllocation(); heap()->DisableInlineAllocation();
heap()->isolate()->debug()->feature_tracker()->Track(
DebugFeatureTracker::kAllocationTracking);
} }
} }
......
...@@ -229,6 +229,8 @@ RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) { ...@@ -229,6 +229,8 @@ RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) {
CONVERT_ARG_HANDLE_CHECKED(String, s1, 0); CONVERT_ARG_HANDLE_CHECKED(String, s1, 0);
CONVERT_ARG_HANDLE_CHECKED(String, s2, 1); CONVERT_ARG_HANDLE_CHECKED(String, s2, 1);
isolate->debug()->feature_tracker()->Track(DebugFeatureTracker::kLiveEdit);
return *LiveEdit::CompareStrings(s1, s2); return *LiveEdit::CompareStrings(s1, s2);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment