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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/language/issue_22780_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 44523)
+++ runtime/vm/object.cc (working copy)
@@ -13469,20 +13469,21 @@
const char* UnhandledException::ToErrorCString() const {
Isolate* isolate = Isolate::Current();
- if (exception() == isolate->object_store()->out_of_memory()) {
- return "Unhandled exception:\nOut of memory";
- }
- if (exception() == isolate->object_store()->stack_overflow()) {
- return "Unhandled exception:\nStack overflow";
- }
HANDLESCOPE(isolate);
Object& strtmp = Object::Handle();
- const Instance& exc = Instance::Handle(exception());
- strtmp = DartLibraryCalls::ToString(exc);
- const char* exc_str =
- "<Received error while converting exception to string>";
- if (!strtmp.IsError()) {
- exc_str = strtmp.ToCString();
+ const char* exc_str;
+ if (exception() == isolate->object_store()->out_of_memory()) {
+ exc_str = "Out of Memory";
+ } else if (exception() == isolate->object_store()->stack_overflow()) {
+ exc_str = "Stack Overflow";
+ } else {
+ const Instance& exc = Instance::Handle(exception());
+ strtmp = DartLibraryCalls::ToString(exc);
+ if (!strtmp.IsError()) {
+ exc_str = strtmp.ToCString();
+ } else {
+ exc_str = "<Received error while converting exception to string>";
+ }
}
const Instance& stack = Instance::Handle(stacktrace());
strtmp = DartLibraryCalls::ToString(stack);
@@ -13491,11 +13492,8 @@
if (!strtmp.IsError()) {
stack_str = strtmp.ToCString();
}
-
const char* format = "Unhandled exception:\n%s\n%s";
- int len = (strlen(exc_str) + strlen(stack_str) + strlen(format)
- - 4 // Two '%s'
- + 1); // '\0'
+ intptr_t len = OS::SNPrint(NULL, 0, format, exc_str, stack_str);
char* chars = isolate->current_zone()->Alloc<char>(len);
OS::SNPrint(chars, len, format, exc_str, stack_str);
return chars;
« 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