Skip to content

Commit 4b54c07

Browse files
alexkozyCommit bot
authored andcommitted
Ignore pause on debugger statement when breakpoints are disabled
This behavior was changed in https://codereview.chromium.org/1402913002. It's pretty usefull to have ability to disable debugger statement for our users. BUG=chromium:583515 LOG=N [email protected] Review URL: https://codereview.chromium.org/1690173002 Cr-Commit-Position: refs/heads/master@{#33960}
1 parent f3cdf8a commit 4b54c07

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/debug/debug.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ class Debug {
525525
return !!base::NoBarrier_Load(&thread_local_.current_debug_scope_);
526526
}
527527
void set_break_points_active(bool v) { break_points_active_ = v; }
528+
bool break_points_active() const { return break_points_active_; }
528529

529530
StackFrame::Id break_frame_id() { return thread_local_.break_frame_id_; }
530531
int break_id() { return thread_local_.break_id_; }

src/runtime/runtime-debug.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ RUNTIME_FUNCTION(Runtime_DebugBreak) {
3030
RUNTIME_FUNCTION(Runtime_HandleDebuggerStatement) {
3131
SealHandleScope shs(isolate);
3232
DCHECK(args.length() == 0);
33-
isolate->debug()->HandleDebugBreak();
33+
if (isolate->debug()->break_points_active()) {
34+
isolate->debug()->HandleDebugBreak();
35+
}
3436
return isolate->heap()->undefined_value();
3537
}
3638

test/cctest/test-debug.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4327,6 +4327,22 @@ TEST(DisableBreak) {
43274327
CheckDebuggerUnloaded(env->GetIsolate());
43284328
}
43294329

4330+
TEST(DisableDebuggerStatement) {
4331+
DebugLocalContext env;
4332+
v8::HandleScope scope(env->GetIsolate());
4333+
4334+
// Register a debug event listener which sets the break flag and counts.
4335+
v8::Debug::SetDebugEventListener(env->GetIsolate(), DebugEventCounter);
4336+
CompileRun("debugger;");
4337+
CHECK_EQ(1, break_point_hit_count);
4338+
4339+
// Check that we ignore debugger statement when breakpoints aren't active.
4340+
i::Isolate* isolate = reinterpret_cast<i::Isolate*>(env->GetIsolate());
4341+
isolate->debug()->set_break_points_active(false);
4342+
CompileRun("debugger;");
4343+
CHECK_EQ(1, break_point_hit_count);
4344+
}
4345+
43304346
static const char* kSimpleExtensionSource =
43314347
"(function Foo() {"
43324348
" return 4;"

0 commit comments

Comments
 (0)