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

Side by Side Diff: src/isolate.cc

Issue 13071005: Add an option to dump core when an uncaught exception is thrown. (Closed) Base URL: git@github.com:davepacheco/v8.git@master
Patch Set: updated changes after code review feedback Created 7 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1191 for (Object* prototype = *obj; !prototype->IsNull(); 1191 for (Object* prototype = *obj; !prototype->IsNull();
1192 prototype = prototype->GetPrototype(this)) { 1192 prototype = prototype->GetPrototype(this)) {
1193 if (!prototype->IsJSObject()) return false; 1193 if (!prototype->IsJSObject()) return false;
1194 if (JSObject::cast(prototype)->map()->constructor() == error_constructor) { 1194 if (JSObject::cast(prototype)->map()->constructor() == error_constructor) {
1195 return true; 1195 return true;
1196 } 1196 }
1197 } 1197 }
1198 return false; 1198 return false;
1199 } 1199 }
1200 1200
1201 static int fatal_exception_depth = 0;
1201 1202
1202 void Isolate::DoThrow(Object* exception, MessageLocation* location) { 1203 void Isolate::DoThrow(Object* exception, MessageLocation* location) {
1203 ASSERT(!has_pending_exception()); 1204 ASSERT(!has_pending_exception());
1204 1205
1205 HandleScope scope(this); 1206 HandleScope scope(this);
1206 Handle<Object> exception_handle(exception, this); 1207 Handle<Object> exception_handle(exception, this);
1207 1208
1208 // Determine reporting and whether the exception is caught externally. 1209 // Determine reporting and whether the exception is caught externally.
1209 bool catchable_by_javascript = is_catchable_by_javascript(exception); 1210 bool catchable_by_javascript = is_catchable_by_javascript(exception);
1210 bool can_be_caught_externally = false; 1211 bool can_be_caught_externally = false;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1274 location, 1275 location,
1275 HandleVector<Object>(&exception_arg, 1), 1276 HandleVector<Object>(&exception_arg, 1),
1276 stack_trace, 1277 stack_trace,
1277 stack_trace_object); 1278 stack_trace_object);
1278 thread_local_top()->pending_message_obj_ = *message_obj; 1279 thread_local_top()->pending_message_obj_ = *message_obj;
1279 if (location != NULL) { 1280 if (location != NULL) {
1280 thread_local_top()->pending_message_script_ = *location->script(); 1281 thread_local_top()->pending_message_script_ = *location->script();
1281 thread_local_top()->pending_message_start_pos_ = location->start_pos(); 1282 thread_local_top()->pending_message_start_pos_ = location->start_pos();
1282 thread_local_top()->pending_message_end_pos_ = location->end_pos(); 1283 thread_local_top()->pending_message_end_pos_ = location->end_pos();
1283 } 1284 }
1285
1286 // If the abort-on-uncaught-exception flag is specified, abort on any
1287 // exception not caught by JavaScript, even when an external handler is
1288 // present. This flag is intended for use by JavaScript developers, so
1289 // print a user-friendly stack trace (not an internal one).
1290 if (fatal_exception_depth == 0 &&
1291 FLAG_abort_on_uncaught_exception &&
1292 (report_exception || can_be_caught_externally)) {
1293 fatal_exception_depth++;
1294 fprintf(stderr, "%s\n\nFROM\n",
1295 *MessageHandler::GetLocalizedMessage(this, message_obj));
1296 PrintCurrentStackTrace(stderr);
1297 OS::Abort();
1298 }
1284 } else if (location != NULL && !location->script().is_null()) { 1299 } else if (location != NULL && !location->script().is_null()) {
1285 // We are bootstrapping and caught an error where the location is set 1300 // We are bootstrapping and caught an error where the location is set
1286 // and we have a script for the location. 1301 // and we have a script for the location.
1287 // In this case we could have an extension (or an internal error 1302 // In this case we could have an extension (or an internal error
1288 // somewhere) and we print out the line number at which the error occured 1303 // somewhere) and we print out the line number at which the error occured
1289 // to the console for easier debugging. 1304 // to the console for easier debugging.
1290 int line_number = GetScriptLineNumberSafe(location->script(), 1305 int line_number = GetScriptLineNumberSafe(location->script(),
1291 location->start_pos()); 1306 location->start_pos());
1292 if (exception->IsString()) { 1307 if (exception->IsString()) {
1293 OS::PrintError( 1308 OS::PrintError(
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
2365 2380
2366 #ifdef DEBUG 2381 #ifdef DEBUG
2367 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \ 2382 #define ISOLATE_FIELD_OFFSET(type, name, ignored) \
2368 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_); 2383 const intptr_t Isolate::name##_debug_offset_ = OFFSET_OF(Isolate, name##_);
2369 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET) 2384 ISOLATE_INIT_LIST(ISOLATE_FIELD_OFFSET)
2370 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET) 2385 ISOLATE_INIT_ARRAY_LIST(ISOLATE_FIELD_OFFSET)
2371 #undef ISOLATE_FIELD_OFFSET 2386 #undef ISOLATE_FIELD_OFFSET
2372 #endif 2387 #endif
2373 2388
2374 } } // namespace v8::internal 2389 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/flag-definitions.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698