Skip to content

Commit 833fb7d

Browse files
hashseedCommit bot
authored andcommitted
[debugger] track debugger feature usage via histogram.
[email protected] Review URL: https://codereview.chromium.org/1478613004 Cr-Commit-Position: refs/heads/master@{#32328}
1 parent 8b192a2 commit 833fb7d

File tree

6 files changed

+59
-1
lines changed

6 files changed

+59
-1
lines changed

src/counters.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ double AggregatedMemoryHistogram<Histogram>::Aggregate(double current_ms,
484484
HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \
485485
101) \
486486
HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6) \
487-
HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20)
487+
HR(errors_thrown_per_context, V8.ErrorsThrownPerContext, 0, 200, 20) \
488+
HR(debug_feature_usage, V8.DebugFeatureUsage, 1, 7, 7)
488489

489490
#define HISTOGRAM_TIMER_LIST(HT) \
490491
/* Garbage collection timers. */ \

src/debug/debug.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Debug::Debug(Isolate* isolate)
4343
break_on_exception_(false),
4444
break_on_uncaught_exception_(false),
4545
debug_info_list_(NULL),
46+
feature_tracker_(isolate),
4647
isolate_(isolate) {
4748
ThreadInit();
4849
}
@@ -316,6 +317,15 @@ Handle<Object> BreakLocation::BreakPointObjects() const {
316317
}
317318

318319

320+
void DebugFeatureTracker::Track(DebugFeatureTracker::Feature feature) {
321+
uint32_t mask = 1 << feature;
322+
// Only count one sample per feature and isolate.
323+
if (bitfield_ & mask) return;
324+
isolate_->counters()->debug_feature_usage()->AddSample(feature);
325+
bitfield_ |= mask;
326+
}
327+
328+
319329
// Threading support.
320330
void Debug::ThreadInit() {
321331
thread_local_.break_count_ = 0;
@@ -396,6 +406,9 @@ bool Debug::Load() {
396406

397407
debug_context_ = Handle<Context>::cast(
398408
isolate_->global_handles()->Create(*context));
409+
410+
feature_tracker()->Track(DebugFeatureTracker::kActive);
411+
399412
return true;
400413
}
401414

@@ -625,6 +638,8 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function,
625638
*source_position = location.statement_position();
626639
location.SetBreakPoint(break_point_object);
627640

641+
feature_tracker()->Track(DebugFeatureTracker::kBreakPoint);
642+
628643
// At least one active break point now.
629644
return debug_info->GetBreakPointCount() > 0;
630645
}
@@ -666,6 +681,8 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
666681
debug_info, ALL_BREAK_LOCATIONS, position, alignment);
667682
location.SetBreakPoint(break_point_object);
668683

684+
feature_tracker()->Track(DebugFeatureTracker::kBreakPoint);
685+
669686
position = (alignment == STATEMENT_ALIGNED) ? location.statement_position()
670687
: location.position();
671688

@@ -874,6 +891,8 @@ void Debug::PrepareStep(StepAction step_action,
874891
JavaScriptFrameIterator frames_it(isolate_, id);
875892
JavaScriptFrame* frame = frames_it.frame();
876893

894+
feature_tracker()->Track(DebugFeatureTracker::kStepping);
895+
877896
// First of all ensure there is one-shot break points in the top handler
878897
// if any.
879898
FloodHandlerWithOneShot();

src/debug/debug.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,28 @@ class LockingCommandMessageQueue BASE_EMBEDDED {
343343
};
344344

345345

346+
class DebugFeatureTracker {
347+
public:
348+
enum Feature {
349+
kActive = 1,
350+
kBreakPoint = 2,
351+
kStepping = 3,
352+
kHeapSnapshot = 4,
353+
kAllocationTracking = 5,
354+
kProfiler = 6,
355+
kLiveEdit = 7,
356+
};
357+
358+
explicit DebugFeatureTracker(Isolate* isolate)
359+
: isolate_(isolate), bitfield_(0) {}
360+
void Track(Feature feature);
361+
362+
private:
363+
Isolate* isolate_;
364+
uint32_t bitfield_;
365+
};
366+
367+
346368
// This class contains the debugger support. The main purpose is to handle
347369
// setting break points in the code.
348370
//
@@ -508,6 +530,8 @@ class Debug {
508530

509531
StepAction last_step_action() { return thread_local_.last_step_action_; }
510532

533+
DebugFeatureTracker* feature_tracker() { return &feature_tracker_; }
534+
511535
private:
512536
explicit Debug(Isolate* isolate);
513537

@@ -606,6 +630,9 @@ class Debug {
606630
// before returning to the DebugBreakCallHelper.
607631
Address after_break_target_;
608632

633+
// Used to collect histogram data on debugger feature usage.
634+
DebugFeatureTracker feature_tracker_;
635+
609636
// Per-thread data.
610637
class ThreadLocal {
611638
public:

src/profiler/cpu-profiler.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include "src/profiler/cpu-profiler.h"
66

7+
#include "src/debug/debug.h"
78
#include "src/deoptimizer.h"
89
#include "src/frames-inl.h"
910
#include "src/locked-queue-inl.h"
@@ -438,6 +439,7 @@ void CpuProfiler::StartProfiling(const char* title, bool record_samples) {
438439

439440
void CpuProfiler::StartProfiling(String* title, bool record_samples) {
440441
StartProfiling(profiles_->GetName(title), record_samples);
442+
isolate_->debug()->feature_tracker()->Track(DebugFeatureTracker::kProfiler);
441443
}
442444

443445

src/profiler/heap-profiler.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "src/profiler/heap-profiler.h"
66

77
#include "src/api.h"
8+
#include "src/debug/debug.h"
89
#include "src/profiler/allocation-tracker.h"
910
#include "src/profiler/heap-snapshot-generator-inl.h"
1011

@@ -75,6 +76,10 @@ HeapSnapshot* HeapProfiler::TakeSnapshot(
7576
}
7677
ids_->RemoveDeadEntries();
7778
is_tracking_object_moves_ = true;
79+
80+
heap()->isolate()->debug()->feature_tracker()->Track(
81+
DebugFeatureTracker::kHeapSnapshot);
82+
7883
return result;
7984
}
8085

@@ -86,6 +91,8 @@ void HeapProfiler::StartHeapObjectsTracking(bool track_allocations) {
8691
if (track_allocations) {
8792
allocation_tracker_.Reset(new AllocationTracker(ids_.get(), names_.get()));
8893
heap()->DisableInlineAllocation();
94+
heap()->isolate()->debug()->feature_tracker()->Track(
95+
DebugFeatureTracker::kAllocationTracking);
8996
}
9097
}
9198

src/runtime/runtime-liveedit.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ RUNTIME_FUNCTION(Runtime_LiveEditCompareStrings) {
229229
CONVERT_ARG_HANDLE_CHECKED(String, s1, 0);
230230
CONVERT_ARG_HANDLE_CHECKED(String, s2, 1);
231231

232+
isolate->debug()->feature_tracker()->Track(DebugFeatureTracker::kLiveEdit);
233+
232234
return *LiveEdit::CompareStrings(s1, s2);
233235
}
234236

0 commit comments

Comments
 (0)