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

Side by Side Diff: runtime/vm/object.cc

Issue 1015513006: Fix for issue 22780 - print the stack trace on OOM and Stack overflow exceptions too. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/issue_22780_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 13451 matching lines...) Expand 10 before | Expand all | Expand 10 after
13462 } 13462 }
13463 13463
13464 13464
13465 void UnhandledException::set_stacktrace(const Instance& stacktrace) const { 13465 void UnhandledException::set_stacktrace(const Instance& stacktrace) const {
13466 StorePointer(&raw_ptr()->stacktrace_, stacktrace.raw()); 13466 StorePointer(&raw_ptr()->stacktrace_, stacktrace.raw());
13467 } 13467 }
13468 13468
13469 13469
13470 const char* UnhandledException::ToErrorCString() const { 13470 const char* UnhandledException::ToErrorCString() const {
13471 Isolate* isolate = Isolate::Current(); 13471 Isolate* isolate = Isolate::Current();
13472 if (exception() == isolate->object_store()->out_of_memory()) {
13473 return "Unhandled exception:\nOut of memory";
13474 }
13475 if (exception() == isolate->object_store()->stack_overflow()) {
13476 return "Unhandled exception:\nStack overflow";
13477 }
13478 HANDLESCOPE(isolate); 13472 HANDLESCOPE(isolate);
13479 Object& strtmp = Object::Handle(); 13473 Object& strtmp = Object::Handle();
13480 const Instance& exc = Instance::Handle(exception()); 13474 const char* exc_str;
13481 strtmp = DartLibraryCalls::ToString(exc); 13475 if (exception() == isolate->object_store()->out_of_memory()) {
13482 const char* exc_str = 13476 exc_str = "Out of Memory";
13483 "<Received error while converting exception to string>"; 13477 } else if (exception() == isolate->object_store()->stack_overflow()) {
13484 if (!strtmp.IsError()) { 13478 exc_str = "Stack Overflow";
13485 exc_str = strtmp.ToCString(); 13479 } else {
13480 const Instance& exc = Instance::Handle(exception());
13481 strtmp = DartLibraryCalls::ToString(exc);
13482 if (!strtmp.IsError()) {
13483 exc_str = strtmp.ToCString();
13484 } else {
13485 exc_str = "<Received error while converting exception to string>";
13486 }
13486 } 13487 }
13487 const Instance& stack = Instance::Handle(stacktrace()); 13488 const Instance& stack = Instance::Handle(stacktrace());
13488 strtmp = DartLibraryCalls::ToString(stack); 13489 strtmp = DartLibraryCalls::ToString(stack);
13489 const char* stack_str = 13490 const char* stack_str =
13490 "<Received error while converting stack trace to string>"; 13491 "<Received error while converting stack trace to string>";
13491 if (!strtmp.IsError()) { 13492 if (!strtmp.IsError()) {
13492 stack_str = strtmp.ToCString(); 13493 stack_str = strtmp.ToCString();
13493 } 13494 }
13494
13495 const char* format = "Unhandled exception:\n%s\n%s"; 13495 const char* format = "Unhandled exception:\n%s\n%s";
13496 int len = (strlen(exc_str) + strlen(stack_str) + strlen(format) 13496 intptr_t len = OS::SNPrint(NULL, 0, format, exc_str, stack_str);
13497 - 4 // Two '%s'
13498 + 1); // '\0'
13499 char* chars = isolate->current_zone()->Alloc<char>(len); 13497 char* chars = isolate->current_zone()->Alloc<char>(len);
13500 OS::SNPrint(chars, len, format, exc_str, stack_str); 13498 OS::SNPrint(chars, len, format, exc_str, stack_str);
13501 return chars; 13499 return chars;
13502 } 13500 }
13503 13501
13504 13502
13505 const char* UnhandledException::ToCString() const { 13503 const char* UnhandledException::ToCString() const {
13506 return "UnhandledException"; 13504 return "UnhandledException";
13507 } 13505 }
13508 13506
(...skipping 7247 matching lines...) Expand 10 before | Expand all | Expand 10 after
20756 return tag_label.ToCString(); 20754 return tag_label.ToCString();
20757 } 20755 }
20758 20756
20759 20757
20760 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20758 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20761 Instance::PrintJSONImpl(stream, ref); 20759 Instance::PrintJSONImpl(stream, ref);
20762 } 20760 }
20763 20761
20764 20762
20765 } // namespace dart 20763 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | tests/language/issue_22780_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698