Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Unified Diff: src/debug/debug.cc

Issue 1527593002: [debugger] flood function for stepping on throw. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: one more item for the black list Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/debug/debug.h ('k') | src/execution.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/debug/debug.cc
diff --git a/src/debug/debug.cc b/src/debug/debug.cc
index 5f623f6b26aa11a1e5405a981ae60f2d17737947..6c88f826a26a944a19a6986e8a739504119ddfb9 100644
--- a/src/debug/debug.cc
+++ b/src/debug/debug.cc
@@ -767,22 +767,6 @@ void Debug::FloodWithOneShot(Handle<JSFunction> function,
}
-void Debug::FloodHandlerWithOneShot() {
- // Iterate through the JavaScript stack looking for handlers.
- DCHECK_NE(StackFrame::NO_ID, break_frame_id());
- for (JavaScriptFrameIterator it(isolate_, break_frame_id()); !it.done();
- it.Advance()) {
- JavaScriptFrame* frame = it.frame();
- int stack_slots = 0; // The computed stack slot count is not used.
- if (frame->LookupExceptionHandlerInTable(&stack_slots, NULL) > 0) {
- // Flood the function with the catch/finally block with break points.
- FloodWithOneShot(Handle<JSFunction>(frame->function()));
- return;
- }
- }
-}
-
-
void Debug::ChangeBreakOnException(ExceptionBreakType type, bool enable) {
if (type == BreakUncaughtException) {
break_on_uncaught_exception_ = enable;
@@ -820,6 +804,35 @@ void Debug::PrepareStepIn(Handle<JSFunction> function) {
}
+void Debug::PrepareStepOnThrow() {
+ if (!is_active()) return;
+ if (!IsStepping()) return;
+ if (last_step_action() == StepNone) return;
+ if (in_debug_scope()) return;
+
+ ClearOneShot();
+
+ // Iterate through the JavaScript stack looking for handlers.
+ JavaScriptFrameIterator it(isolate_);
+ while (!it.done()) {
+ JavaScriptFrame* frame = it.frame();
+ int stack_slots = 0; // The computed stack slot count is not used.
+ if (frame->LookupExceptionHandlerInTable(&stack_slots, NULL) > 0) break;
+ it.Advance();
+ }
+
+ // Find the closest Javascript frame we can flood with one-shots.
+ while (!it.done() &&
+ !it.frame()->function()->shared()->IsSubjectToDebugging()) {
+ it.Advance();
+ }
+
+ if (it.done()) return; // No suitable Javascript catch handler.
+
+ FloodWithOneShot(Handle<JSFunction>(it.frame()->function()));
+}
+
+
void Debug::PrepareStep(StepAction step_action,
int step_count,
StackFrame::Id frame_id) {
@@ -856,10 +869,6 @@ void Debug::PrepareStep(StepAction step_action,
thread_local_.step_count_ = step_count;
}
- // First of all ensure there is one-shot break points in the top handler
- // if any.
- FloodHandlerWithOneShot();
-
// If the function on the top frame is unresolved perform step out. This will
// be the case when calling unknown function and having the debugger stopped
// in an unhandled exception.
@@ -1659,6 +1668,7 @@ MaybeHandle<Object> Debug::MakeAsyncTaskEvent(Handle<JSObject> task_event) {
void Debug::OnThrow(Handle<Object> exception) {
if (in_debug_scope() || ignore_events()) return;
+ PrepareStepOnThrow();
// Temporarily clear any scheduled_exception to allow evaluating
// JavaScript from the debug event handler.
HandleScope scope(isolate_);
@@ -1720,9 +1730,6 @@ void Debug::OnException(Handle<Object> exception, Handle<Object> promise) {
DebugScope debug_scope(this);
if (debug_scope.failed()) return;
- // Clear all current stepping setup.
- ClearStepping();
-
// Create the event data object.
Handle<Object> event_data;
// Bail out and don't call debugger if exception.
« no previous file with comments | « src/debug/debug.h ('k') | src/execution.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698