Skip to content

Commit 418b646

Browse files
zichanggcommit-bot@chromium.org
authored andcommitted
[vm/debugger] not pausing exceptions on implicit throw
Ignoring exceptions that coming from implicit throw. For example, try finally block will generate an implicit throw inside finally block to rethrow the exception. Bug: #37645 Change-Id: I5c4f90ec3c9aa92bb670d4bb9a8edb332f7b32fc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118911 Reviewed-by: Alexander Markov <alexmarkov@google.com> Reviewed-by: Siva Annamalai <asiva@google.com> Commit-Queue: Zichang Guo <zichangguo@google.com>
1 parent 36e4d5e commit 418b646

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

runtime/observatory/tests/service/pause_on_unhandled_async_exceptions3_test.dart

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,22 @@ import 'package:unittest/unittest.dart';
1010
import 'test_helper.dart';
1111
import 'service_test_common.dart';
1212

13-
const LINE_A = 16;
13+
const LINE_A = 18;
14+
const LINE_B = 23;
15+
const LINE_C = 26;
1416

1517
throwException() async {
1618
throw 'exception'; // LINE_A
1719
}
1820

1921
testeeMain() async {
2022
try {
21-
await throwException();
22-
} finally {}
23+
await throwException(); // LINE_B
24+
} finally {
25+
try {
26+
await throwException(); // LINE_C
27+
} finally {}
28+
}
2329
}
2430

2531
var tests = <IsolateTest>[
@@ -29,6 +35,26 @@ var tests = <IsolateTest>[
2935
print("Stopped!");
3036
var stack = await isolate.getStack();
3137
expect(stack['frames'][0].function.toString(), contains('throwException'));
38+
},
39+
resumeIsolate,
40+
hasStoppedWithUnhandledException,
41+
(Isolate isolate) async {
42+
var stack = await isolate.getStack();
43+
print(stack['frames'][0]);
44+
// await in testeeMain
45+
expect(await stack['frames'][0].location.toUserString(),
46+
contains('.dart:${LINE_B}'));
47+
},
48+
resumeIsolate,
49+
hasStoppedWithUnhandledException,
50+
stoppedAtLine(LINE_A),
51+
resumeIsolate,
52+
hasStoppedWithUnhandledException,
53+
(Isolate isolate) async {
54+
var stack = await isolate.getStack();
55+
print(stack['frames'][0]);
56+
expect(await stack['frames'][0].location.toUserString(),
57+
contains('.dart:${LINE_C}'));
3258
}
3359
];
3460

runtime/vm/debugger.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,6 +2780,11 @@ bool Debugger::ShouldPauseOnException(DebuggerStackTrace* stack_trace,
27802780
return true;
27812781
}
27822782
ASSERT(exc_pause_info_ == kPauseOnUnhandledExceptions);
2783+
// Exceptions coming from invalid token positions should be skipped
2784+
ActivationFrame* top_frame = stack_trace->FrameAt(0);
2785+
if (!top_frame->TokenPos().IsReal() && top_frame->TryIndex() != -1) {
2786+
return false;
2787+
}
27832788
ActivationFrame* handler_frame = stack_trace->GetHandlerFrame(exception);
27842789
if (handler_frame == NULL) {
27852790
// Did not find an exception handler that catches this exception.

0 commit comments

Comments
 (0)