Also print the exception when mksnapshot failed to compile extra code.

Before, it would only print the exception when it failed to run the code

R=svenpanne@chromium.org

Review URL: https://codereview.chromium.org/14031036

Patch from Jochen Eisinger <jochen@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@14478 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 7b1e7463
......@@ -291,6 +291,18 @@ class BZip2Decompressor : public StartupDataDecompressor {
#endif
void DumpException(Handle<Message> message) {
String::Utf8Value message_string(message->Get());
String::Utf8Value message_line(message->GetSourceLine());
fprintf(stderr, "%s at line %d\n", *message_string, message->GetLineNumber());
fprintf(stderr, "%s\n", *message_line);
for (int i = 0; i <= message->GetEndColumn(); ++i) {
fprintf(stderr, "%c", i < message->GetStartColumn() ? ' ' : '^');
}
fprintf(stderr, "\n");
}
int main(int argc, char** argv) {
// By default, log code create information in the snapshot.
i::FLAG_log_code = true;
......@@ -350,27 +362,14 @@ int main(int argc, char** argv) {
TryCatch try_catch;
Local<Script> script = Script::Compile(source);
if (try_catch.HasCaught()) {
fprintf(stderr, "Failure compiling '%s' (see above)\n", name);
fprintf(stderr, "Failure compiling '%s'\n", name);
DumpException(try_catch.Message());
exit(1);
}
script->Run();
if (try_catch.HasCaught()) {
fprintf(stderr, "Failure running '%s'\n", name);
Local<Message> message = try_catch.Message();
Local<String> message_string = message->Get();
Local<String> message_line = message->GetSourceLine();
int len = 2 + message_string->Utf8Length() + message_line->Utf8Length();
char* buf = new char(len);
message_string->WriteUtf8(buf);
fprintf(stderr, "%s at line %d\n", buf, message->GetLineNumber());
message_line->WriteUtf8(buf);
fprintf(stderr, "%s\n", buf);
int from = message->GetStartColumn();
int to = message->GetEndColumn();
int i;
for (i = 0; i < from; i++) fprintf(stderr, " ");
for ( ; i <= to; i++) fprintf(stderr, "^");
fprintf(stderr, "\n");
DumpException(try_catch.Message());
exit(1);
}
context->Exit();
......
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