Skip to content

Commit 723fa96

Browse files
targosofrobots
authored andcommitted
deps: cherry-pick de5aaad from V8's upstream
Original commit message: [Debugger] Fix StepNext over function with caught exception Without CL debugger on StepNext adds breakpoint to function where throw instruction is located. In case of StepNext we will skip pause in this function because StepNext shouldn't break in a deeper frame. BUG=chromium:604495 R=yangguo@chromium.org LOG=N Review URL: https://codereview.chromium.org/1894263002 Cr-Commit-Position: refs/heads/master@{#35627} Fixes: #7219 PR-URL: #8099 Reviewed-By: bnoordhuis - Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
1 parent fc2a89c commit 723fa96

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

deps/v8/include/v8-version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#define V8_MAJOR_VERSION 5
1212
#define V8_MINOR_VERSION 1
1313
#define V8_BUILD_NUMBER 281
14-
#define V8_PATCH_LEVEL 80
14+
#define V8_PATCH_LEVEL 81
1515

1616
// Use 1 for candidates and 0 otherwise.
1717
// (Boolean macro values are not supported by all preprocessors.)

deps/v8/src/debug/debug.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,14 @@ void Debug::PrepareStepOnThrow() {
962962
it.Advance();
963963
}
964964

965+
if (last_step_action() == StepNext) {
966+
while (!it.done()) {
967+
Address current_fp = it.frame()->UnpaddedFP();
968+
if (current_fp >= thread_local_.target_fp_) break;
969+
it.Advance();
970+
}
971+
}
972+
965973
// Find the closest Javascript frame we can flood with one-shots.
966974
while (!it.done() &&
967975
!it.frame()->function()->shared()->IsSubjectToDebugging()) {

deps/v8/test/cctest/test-debug.cc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8185,3 +8185,36 @@ TEST(DebugStepNextTailCallEliminiation) {
81858185
ExpectString("JSON.stringify(log)",
81868186
"[\"a4\",\"b2\",\"c4\",\"e0\",\"e0\",\"e0\",\"e0\",\"f0\"]");
81878187
}
8188+
8189+
size_t current_action = 0;
8190+
StepAction actions[] = {StepNext, StepNext};
8191+
static void DebugStepOverFunctionWithCaughtExceptionListener(
8192+
const v8::Debug::EventDetails& event_details) {
8193+
v8::DebugEvent event = event_details.GetEvent();
8194+
if (event != v8::Break) return;
8195+
++break_point_hit_count;
8196+
if (current_action >= 2) return;
8197+
PrepareStep(actions[current_action]);
8198+
}
8199+
8200+
TEST(DebugStepOverFunctionWithCaughtException) {
8201+
i::FLAG_allow_natives_syntax = true;
8202+
8203+
DebugLocalContext env;
8204+
v8::Isolate* isolate = env->GetIsolate();
8205+
v8::HandleScope scope(isolate);
8206+
v8::Debug::SetDebugEventListener(
8207+
isolate, DebugStepOverFunctionWithCaughtExceptionListener);
8208+
8209+
break_point_hit_count = 0;
8210+
CompileRun(
8211+
"function foo() {\n"
8212+
" try { throw new Error(); } catch (e) {}\n"
8213+
"}\n"
8214+
"debugger;\n"
8215+
"foo();\n"
8216+
"foo();\n");
8217+
8218+
v8::Debug::SetDebugEventListener(env->GetIsolate(), nullptr);
8219+
CHECK_EQ(break_point_hit_count, 4);
8220+
}

0 commit comments

Comments
 (0)