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

Side by Side Diff: src/mksnapshot.cc

Issue 14031036: Also print the exception when mksnapshot failed to compile extra code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: updates Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 0, 1); 284 0, 1);
285 if (result == BZ_OK) { 285 if (result == BZ_OK) {
286 *raw_data_size = decompressed_size; 286 *raw_data_size = decompressed_size;
287 } 287 }
288 return result; 288 return result;
289 } 289 }
290 }; 290 };
291 #endif 291 #endif
292 292
293 293
294 void DumpException(Handle<Message> message) {
295 String::Utf8Value message_string(message->Get());
296 String::Utf8Value message_line(message->GetSourceLine());
297 fprintf(stderr, "%s at line %d\n", *message_string, message->GetLineNumber());
298 fprintf(stderr, "%s\n", *message_line);
299 for (int i = 0; i <= message->GetEndColumn(); ++i) {
300 fprintf(stderr, "%c", i < message->GetStartColumn() ? ' ' : '^');
301 }
302 fprintf(stderr, "\n");
303 }
304
305
294 int main(int argc, char** argv) { 306 int main(int argc, char** argv) {
295 // By default, log code create information in the snapshot. 307 // By default, log code create information in the snapshot.
296 i::FLAG_log_code = true; 308 i::FLAG_log_code = true;
297 309
298 // Print the usage if an error occurs when parsing the command line 310 // Print the usage if an error occurs when parsing the command line
299 // flags or if the help flag is set. 311 // flags or if the help flag is set.
300 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true); 312 int result = i::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
301 if (result > 0 || argc != 2 || i::FLAG_help) { 313 if (result > 0 || argc != 2 || i::FLAG_help) {
302 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); 314 ::printf("Usage: %s [flag] ... outfile\n", argv[0]);
303 i::FlagList::PrintHelp(); 315 i::FlagList::PrintHelp();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 fprintf(stderr, "Failed to read '%s': errno %d\n", name, errno); 355 fprintf(stderr, "Failed to read '%s': errno %d\n", name, errno);
344 exit(1); 356 exit(1);
345 } 357 }
346 i += read; 358 i += read;
347 } 359 }
348 fclose(file); 360 fclose(file);
349 Local<String> source = String::New(chars); 361 Local<String> source = String::New(chars);
350 TryCatch try_catch; 362 TryCatch try_catch;
351 Local<Script> script = Script::Compile(source); 363 Local<Script> script = Script::Compile(source);
352 if (try_catch.HasCaught()) { 364 if (try_catch.HasCaught()) {
353 fprintf(stderr, "Failure compiling '%s' (see above)\n", name); 365 fprintf(stderr, "Failure compiling '%s'\n", name);
366 DumpException(try_catch.Message());
354 exit(1); 367 exit(1);
355 } 368 }
356 script->Run(); 369 script->Run();
357 if (try_catch.HasCaught()) { 370 if (try_catch.HasCaught()) {
358 fprintf(stderr, "Failure running '%s'\n", name); 371 fprintf(stderr, "Failure running '%s'\n", name);
359 Local<Message> message = try_catch.Message(); 372 DumpException(try_catch.Message());
360 Local<String> message_string = message->Get();
361 Local<String> message_line = message->GetSourceLine();
362 int len = 2 + message_string->Utf8Length() + message_line->Utf8Length();
363 char* buf = new char(len);
364 message_string->WriteUtf8(buf);
365 fprintf(stderr, "%s at line %d\n", buf, message->GetLineNumber());
366 message_line->WriteUtf8(buf);
367 fprintf(stderr, "%s\n", buf);
368 int from = message->GetStartColumn();
369 int to = message->GetEndColumn();
370 int i;
371 for (i = 0; i < from; i++) fprintf(stderr, " ");
372 for ( ; i <= to; i++) fprintf(stderr, "^");
373 fprintf(stderr, "\n");
374 exit(1); 373 exit(1);
375 } 374 }
376 context->Exit(); 375 context->Exit();
377 } 376 }
378 // Make sure all builtin scripts are cached. 377 // Make sure all builtin scripts are cached.
379 { HandleScope scope(isolate); 378 { HandleScope scope(isolate);
380 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) { 379 for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
381 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i); 380 i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i);
382 } 381 }
383 } 382 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 sink.WriteSpaceUsed( 417 sink.WriteSpaceUsed(
419 "", 418 "",
420 ser.CurrentAllocationAddress(i::NEW_SPACE), 419 ser.CurrentAllocationAddress(i::NEW_SPACE),
421 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE), 420 ser.CurrentAllocationAddress(i::OLD_POINTER_SPACE),
422 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE), 421 ser.CurrentAllocationAddress(i::OLD_DATA_SPACE),
423 ser.CurrentAllocationAddress(i::CODE_SPACE), 422 ser.CurrentAllocationAddress(i::CODE_SPACE),
424 ser.CurrentAllocationAddress(i::MAP_SPACE), 423 ser.CurrentAllocationAddress(i::MAP_SPACE),
425 ser.CurrentAllocationAddress(i::CELL_SPACE)); 424 ser.CurrentAllocationAddress(i::CELL_SPACE));
426 return 0; 425 return 0;
427 } 426 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698