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

Side by Side Diff: runtime/vm/exceptions.cc

Issue 11413101: Added support for isolate unhandled exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Incorporated code review feedback Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_entry.h" 8 #include "vm/dart_entry.h"
8 #include "vm/debugger.h" 9 #include "vm/debugger.h"
9 #include "vm/flags.h" 10 #include "vm/flags.h"
10 #include "vm/object.h" 11 #include "vm/object.h"
11 #include "vm/stack_frame.h" 12 #include "vm/stack_frame.h"
12 #include "vm/stub_code.h" 13 #include "vm/stub_code.h"
13 #include "vm/symbols.h" 14 #include "vm/symbols.h"
14 15
15 namespace dart { 16 namespace dart {
16 17
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 const GrowableObjectArray& pc_offset_list = 157 const GrowableObjectArray& pc_offset_list =
157 GrowableObjectArray::Handle(GrowableObjectArray::New()); 158 GrowableObjectArray::Handle(GrowableObjectArray::New());
158 bool handler_exists = FindExceptionHandler(&handler_pc, 159 bool handler_exists = FindExceptionHandler(&handler_pc,
159 &handler_sp, 160 &handler_sp,
160 &handler_fp, 161 &handler_fp,
161 func_list, 162 func_list,
162 code_list, 163 code_list,
163 pc_offset_list); 164 pc_offset_list);
164 if (handler_pc == 0) { 165 if (handler_pc == 0) {
165 // There are no dart invocation frames on the stack so we do not 166 // There are no dart invocation frames on the stack so we do not
166 // have a caller to return to. This is a case where we would have 167 // have a caller to return to.
167 // to call the Isolate error handler and let it deal with the shutdown.
168 // We report an error and shutdown the process as a temporary solution
169 // until the isolate error handler stuff is implemented.
170 ASSERT(!handler_exists); 168 ASSERT(!handler_exists);
171 OS::PrintErr("Exception '%s' thrown:\n", exception.ToCString()); 169 if (Isolate::UnhandledExceptionCallback() != NULL) {
172 OS::PrintErr("Exiting the process\n"); 170 // Notify embedder that an unhandled exception occurred.
173 OS::Exit(255); 171 Dart_EnterScope();
172 Dart_Handle error_handle = Api::NewHandle(Isolate::Current(),
173 incoming_exception.raw());
174 (Isolate::UnhandledExceptionCallback())(error_handle);
175 Dart_ExitScope();
176 } else {
177 OS::PrintErr("Exception '%s' thrown:\n", exception.ToCString());
178 OS::PrintErr("Shutting down the isolate\n");
179 }
180 Dart_ShutdownIsolate();
174 } 181 }
175 // TODO(5411263): At some point we can optimize by figuring out if a 182 // TODO(5411263): At some point we can optimize by figuring out if a
176 // stack trace is needed based on whether the catch code specifies a 183 // stack trace is needed based on whether the catch code specifies a
177 // stack trace object or there is a rethrow in the catch clause. 184 // stack trace object or there is a rethrow in the catch clause.
178 Stacktrace& stacktrace = Stacktrace::Handle(); 185 Stacktrace& stacktrace = Stacktrace::Handle();
179 if (pc_offset_list.Length() != 0) { 186 if (pc_offset_list.Length() != 0) {
180 if (existing_stacktrace.IsNull()) { 187 if (existing_stacktrace.IsNull()) {
181 stacktrace = Stacktrace::New(func_list, code_list, pc_offset_list); 188 stacktrace = Stacktrace::New(func_list, code_list, pc_offset_list);
182 } else { 189 } else {
183 stacktrace ^= existing_stacktrace.raw(); 190 stacktrace ^= existing_stacktrace.raw();
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 case kIsolateSpawn: 445 case kIsolateSpawn:
439 library = Library::IsolateLibrary(); 446 library = Library::IsolateLibrary();
440 class_name = Symbols::New("IsolateSpawnException"); 447 class_name = Symbols::New("IsolateSpawnException");
441 break; 448 break;
442 } 449 }
443 450
444 return DartLibraryCalls::ExceptionCreate(library, class_name, arguments); 451 return DartLibraryCalls::ExceptionCreate(library, class_name, arguments);
445 } 452 }
446 453
447 } // namespace dart 454 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl_test.cc ('k') | runtime/vm/isolate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698