OLD | NEW |
---|---|
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/exceptions.h" | 5 #include "vm/exceptions.h" |
6 | 6 |
7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 &handler_sp, | 368 &handler_sp, |
369 &handler_fp, | 369 &handler_fp, |
370 &handler_needs_stacktrace); | 370 &handler_needs_stacktrace); |
371 if (handler_needs_stacktrace) { | 371 if (handler_needs_stacktrace) { |
372 BuildStackTrace(&frame_builder); | 372 BuildStackTrace(&frame_builder); |
373 } | 373 } |
374 } else { | 374 } else { |
375 // Get stacktrace field of class Error. | 375 // Get stacktrace field of class Error. |
376 const Field& stacktrace_field = | 376 const Field& stacktrace_field = |
377 Field::Handle(isolate, LookupStacktraceField(exception)); | 377 Field::Handle(isolate, LookupStacktraceField(exception)); |
378 bool full_stacktrace = !stacktrace_field.IsNull(); | |
379 handler_exists = FindExceptionHandler(&handler_pc, | 378 handler_exists = FindExceptionHandler(&handler_pc, |
380 &handler_sp, | 379 &handler_sp, |
381 &handler_fp, | 380 &handler_fp, |
382 &handler_needs_stacktrace); | 381 &handler_needs_stacktrace); |
383 Array& code_array = Array::Handle(isolate, Object::empty_array().raw()); | 382 Array& code_array = Array::Handle(isolate, Object::empty_array().raw()); |
384 Array& pc_offset_array = | 383 Array& pc_offset_array = |
385 Array::Handle(isolate, Object::empty_array().raw()); | 384 Array::Handle(isolate, Object::empty_array().raw()); |
386 if (handler_needs_stacktrace || full_stacktrace) { | 385 // If we have an error with a stacktrace field then collect the full stack |
387 RegularStacktraceBuilder frame_builder(full_stacktrace); | 386 // trace and store it into the field. |
388 BuildStackTrace(&frame_builder); | 387 if (!stacktrace_field.IsNull()) { |
389 | 388 if (exception.GetField(stacktrace_field) == Object::null()) { |
390 // Create arrays for function, code and pc_offset triplet of each frame. | |
391 code_array = Array::MakeArray(frame_builder.code_list()); | |
392 pc_offset_array = Array::MakeArray(frame_builder.pc_offset_list()); | |
393 if (!stacktrace_field.IsNull()) { | |
394 // This is an error object and we need to capture the full stack trace | 389 // This is an error object and we need to capture the full stack trace |
395 // here implicitly, so we set up the stack trace. The stack trace field | 390 // here implicitly, so we set up the stack trace. The stack trace field |
396 // is set only once, it is not overriden. | 391 // is set only once, it is not overriden. |
397 const Array& catch_code_array = Array::Handle(isolate, | 392 RegularStacktraceBuilder frame_builder(true); |
393 BuildStackTrace(&frame_builder); | |
394 | |
395 // Create arrays for code and pc_offset tuples of each frame. | |
396 const Array& full_code_array = Array::Handle(isolate, | |
397 Array::MakeArray(frame_builder.code_list())); | |
398 const Array& full_pc_offset_array = Array::Handle(isolate, | |
399 Array::MakeArray(frame_builder.pc_offset_list())); | |
400 const Array& full_catch_code_array = Array::Handle(isolate, | |
398 Array::MakeArray(frame_builder.catch_code_list())); | 401 Array::MakeArray(frame_builder.catch_code_list())); |
399 const Array& catch_pc_offset_array = Array::Handle(isolate, | 402 const Array& full_catch_pc_offset_array = Array::Handle(isolate, |
400 Array::MakeArray(frame_builder.catch_pc_offset_list())); | 403 Array::MakeArray(frame_builder.catch_pc_offset_list())); |
401 stacktrace = Stacktrace::New(code_array, pc_offset_array); | 404 const Stacktrace& full_stacktrace = Stacktrace::Handle(isolate, |
402 stacktrace.SetCatchStacktrace(catch_code_array, | 405 Stacktrace::New(full_code_array, full_pc_offset_array)); |
403 catch_pc_offset_array); | 406 full_stacktrace.SetCatchStacktrace(full_catch_code_array, |
404 if (exception.GetField(stacktrace_field) == Object::null()) { | 407 full_catch_pc_offset_array); |
405 exception.SetField(stacktrace_field, stacktrace); | 408 exception.SetField(stacktrace_field, full_stacktrace); |
406 } | 409 } |
407 } // if stacktrace needed. | 410 } |
411 if (handler_needs_stacktrace) { | |
412 RegularStacktraceBuilder frame_builder(false); | |
413 BuildStackTrace(&frame_builder); | |
414 | |
415 // Create arrays for fcode and pc_offset tuples of each frame. | |
siva
2013/10/24 00:16:10
for code and pc_offset
Ivan Posva
2013/10/24 00:16:41
Done.
| |
416 code_array = Array::MakeArray(frame_builder.code_list()); | |
417 pc_offset_array = Array::MakeArray(frame_builder.pc_offset_list()); | |
408 } | 418 } |
409 if (existing_stacktrace.IsNull()) { | 419 if (existing_stacktrace.IsNull()) { |
410 stacktrace = Stacktrace::New(code_array, pc_offset_array); | 420 stacktrace = Stacktrace::New(code_array, pc_offset_array); |
411 } else { | 421 } else { |
412 stacktrace ^= existing_stacktrace.raw(); | 422 stacktrace ^= existing_stacktrace.raw(); |
413 if (pc_offset_array.Length() != 0) { | 423 if (pc_offset_array.Length() != 0) { |
414 stacktrace.Append(code_array, pc_offset_array); | 424 stacktrace.Append(code_array, pc_offset_array); |
415 } | 425 } |
416 // Since we are re throwing and appending to the existing stack trace | 426 // Since we are re throwing and appending to the existing stack trace |
417 // we clear out the catch trace collected in the existing stack trace | 427 // we clear out the catch trace collected in the existing stack trace |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 break; | 713 break; |
704 } | 714 } |
705 | 715 |
706 return DartLibraryCalls::InstanceCreate(library, | 716 return DartLibraryCalls::InstanceCreate(library, |
707 *class_name, | 717 *class_name, |
708 *constructor_name, | 718 *constructor_name, |
709 arguments); | 719 arguments); |
710 } | 720 } |
711 | 721 |
712 } // namespace dart | 722 } // namespace dart |
OLD | NEW |