Provide a convenience for logging types that don't have an operator<<.
Change-Id: I650b852ded67576dc5ec7c8e57732cfb49f1ecd6
diff --git a/src/runtime.cc b/src/runtime.cc
index 9c923fb..54d7ec6 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -76,27 +76,26 @@
instance_ = NULL;
}
+struct AbortState {
+ void Dump(std::ostream& os) {
+ os << "Runtime aborting...\n";
+ Thread* self = Thread::Current();
+ if (self == NULL) {
+ os << "(Aborting thread was not attached to runtime!)\n";
+ } else {
+ self->Dump(os, true);
+ }
+ }
+};
+
void Runtime::Abort(const char* file, int line) {
// Get any pending output out of the way.
fflush(NULL);
// Many people have difficulty distinguish aborts from crashes,
// so be explicit.
- {
- LogMessage log(file, line, ERROR, -1);
- log.stream() << "Runtime aborting..." << std::endl;
- // Add Java stack trace if possible
- Thread* thread = Thread::Current();
- if (thread != NULL) {
- log.stream() << "Java stack trace of aborting thread:" << std::endl;
- thread->DumpStack(log.stream());
- if (thread->IsExceptionPending()) {
- Throwable* e = thread->GetException();
- log.stream() << "Pending exception on thread: " << PrettyTypeOf(e) << std::endl;
- log.stream() << e->Dump();
- }
- }
- }
+ AbortState state;
+ LOG(ERROR) << Dumpable<AbortState>(state);
// Perform any platform-specific pre-abort actions.
PlatformAbort(file, line);