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

Unified 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: Created 7 years, 9 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 | « src/flag-definitions.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 632ecdc50a32b569ba3224c9428a165ef10deccb..34f68d8386afd7b7ca2d630a128711e196fed059 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -1198,6 +1198,7 @@ bool Isolate::IsErrorObject(Handle<Object> obj) {
return false;
}
+static int fatal_exception_depth = 0;
void Isolate::DoThrow(Object* exception, MessageLocation* location) {
ASSERT(!has_pending_exception());
@@ -1281,6 +1282,36 @@ void Isolate::DoThrow(Object* exception, MessageLocation* location) {
thread_local_top()->pending_message_start_pos_ = location->start_pos();
thread_local_top()->pending_message_end_pos_ = location->end_pos();
}
+
+ // If the abort-on-uncaught-exception flag is specified, abort on any
+ // exception not caught by JavaScript, even when an external handler is
+ // present. This flag is intended for use by JavaScript developers, so
+ // print a user-friendly stack trace (not an internal one).
+ if (fatal_exception_depth == 0 &&
+ FLAG_abort_on_uncaught_exception &&
+ (report_exception || can_be_caught_externally)) {
+ fatal_exception_depth++;
+ fprintf(stderr, "UNCAUGHT EXCEPTION: ");
+ exception->ShortPrint(stderr);
+
+ if (IsErrorObject(exception_handle)) {
+ Handle<String> key = factory()->InternalizeOneByteString(
+ STATIC_ASCII_VECTOR("message"));
+ MaybeObject *maybeMessage =
+ JSObject::cast(*exception_handle)->GetProperty(*key);
+ Object *messageObject;
+ if (maybeMessage->ToObject(&messageObject)) {
+ String *message = String::cast(messageObject);
+ fprintf(stderr, "\nEXCEPTION MESSAGE: ");
+ message->PrintOn(stderr);
+ }
+ }
Yang 2013/04/02 10:42:30 I was actually suggesting to replace the entire ab
+
+ fprintf(stderr, "\nFROM:\n");
+ PrintCurrentStackTrace(stderr);
+ OS::Abort();
+ }
+
} else if (location != NULL && !location->script().is_null()) {
// We are bootstrapping and caught an error where the location is set
// and we have a script for the location.
« 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