Commit 9f77ba9f authored by yangguo@chromium.org's avatar yangguo@chromium.org

Add an option to dump core when an uncaught exception is thrown.

BUG=

Review URL: https://chromiumcodereview.appspot.com/13071005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14185 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent ea2d9e38
......@@ -499,6 +499,8 @@ DEFINE_int(sim_stack_alignment, 8,
"Stack alingment in bytes in simulator (4 or 8, 8 is default)")
// isolate.cc
DEFINE_bool(abort_on_uncaught_exception, false,
"abort program (dump core) when an uncaught exception is thrown")
DEFINE_bool(trace_exception, false,
"print stack trace when throwing exceptions")
DEFINE_bool(preallocate_message_memory, false,
......
......@@ -1213,6 +1213,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());
......@@ -1296,6 +1297,20 @@ 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, "%s\n\nFROM\n",
*MessageHandler::GetLocalizedMessage(this, message_obj));
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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment