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

Unified Diff: runtime/vm/exceptions.cc

Issue 342473006: Don't add the catch frame at a rethrow to the stacktrace. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: move skipping logic to stacktrace::append Created 6 years, 6 months 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 | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/exceptions.cc
diff --git a/runtime/vm/exceptions.cc b/runtime/vm/exceptions.cc
index cbf89df3a4c4b2dd329df6d6e52c660dfc2a02b1..9795ee40add1d780290ad460d9d3cf79c7f1353b 100644
--- a/runtime/vm/exceptions.cc
+++ b/runtime/vm/exceptions.cc
@@ -375,7 +375,9 @@ RawStacktrace* Exceptions::CurrentStacktrace() {
static void ThrowExceptionHelper(Isolate* isolate,
const Instance& incoming_exception,
- const Instance& existing_stacktrace) {
+ const Instance& existing_stacktrace,
+ const bool is_rethrow) {
+ ASSERT(existing_stacktrace.IsNull() == !is_rethrow);
bool use_preallocated_stacktrace = false;
Instance& exception = Instance::Handle(isolate, incoming_exception.raw());
if (exception.IsNull()) {
@@ -439,7 +441,11 @@ static void ThrowExceptionHelper(Isolate* isolate,
} else {
siva 2014/06/25 22:46:12 How about moving the assert on top to here as ASSE
stacktrace ^= existing_stacktrace.raw();
if (pc_offset_array.Length() != 0) {
- stacktrace.Append(code_array, pc_offset_array);
+ // Skip the first frame during a rethrow. This is the catch clause with
+ // the rethrow statement, which is not part of the original trace a
+ // rethrow is supposed to preserve.
+ const intptr_t offset = is_rethrow ? 1 : 0;
siva 2014/06/25 22:46:12 Can this just be: const intptr_t offset = 1; since
rmacnak 2014/06/25 23:00:43 Ah, yes.
+ stacktrace.Append(code_array, pc_offset_array, offset);
}
// Since we are re throwing and appending to the existing stack trace
// we clear out the catch trace collected in the existing stack trace
@@ -574,7 +580,7 @@ void Exceptions::CreateAndThrowTypeError(intptr_t location,
void Exceptions::Throw(Isolate* isolate, const Instance& exception) {
isolate->debugger()->SignalExceptionThrown(exception);
// Null object is a valid exception object.
- ThrowExceptionHelper(isolate, exception, Instance::Handle(isolate));
+ ThrowExceptionHelper(isolate, exception, Instance::Handle(isolate), false);
}
@@ -582,7 +588,7 @@ void Exceptions::ReThrow(Isolate* isolate,
const Instance& exception,
const Instance& stacktrace) {
// Null object is a valid exception object.
- ThrowExceptionHelper(isolate, exception, stacktrace);
+ ThrowExceptionHelper(isolate, exception, stacktrace, true);
}
« no previous file with comments | « no previous file | runtime/vm/object.h » ('j') | runtime/vm/object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698