Chromium Code Reviews| 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); |
| } |