Implement Runtime::Abort and switch LOG(FATAL) over to it.

Runtime::Abort takes arguments so it can provide less misleading log output,
but this shouldn't matter to callers because they should be using LOG(FATAL)
anyway.

This patch also fixes an errno/errno_ mixup in the logging code.

Change-Id: If24b66b7bbf0bf7c0ecb93dd806d82b1d21ee239
diff --git a/src/logging_linux.cc b/src/logging_linux.cc
index 9feceea..4be989d 100644
--- a/src/logging_linux.cc
+++ b/src/logging_linux.cc
@@ -3,12 +3,12 @@
 
 #include "logging.h"
 
+#include "runtime.h"
 #include "scoped_ptr.h"
 #include "stringprintf.h"
 
 #include <cstdio>
 #include <cstring>
-#include <execinfo.h>
 #include <iostream>
 #include <sys/types.h>
 #include <unistd.h>
@@ -23,44 +23,22 @@
 #endif
 #undef __KERNEL__
 
-static void dumpStackTrace(std::ostream& os) {
-  // Get the raw stack frames.
-  size_t MAX_STACK_FRAMES = 64;
-  void* stack_frames[MAX_STACK_FRAMES];
-  size_t frame_count = backtrace(stack_frames, MAX_STACK_FRAMES);
-
-  // Turn them into something human-readable with symbols.
-  // TODO: in practice, we may find that we should use backtrace_symbols_fd
-  // to avoid allocation, rather than use our own custom formatting.
-  art::scoped_ptr_malloc<char*> strings(backtrace_symbols(stack_frames, frame_count));
-  if (strings.get() == NULL) {
-    os << "backtrace_symbols failed: " << strerror(errno) << std::endl;
-    return;
-  }
-
-  for (size_t i = 0; i < frame_count; ++i) {
-    os << StringPrintf("\t#%02d %s", i, strings.get()[i]) << std::endl;
-  }
-}
-
 LogMessage::LogMessage(const char* file, int line, LogSeverity severity, int error)
-: severity_(severity), errno_(error)
+: line_(line), severity_(severity), errno_(error)
 {
   const char* last_slash = strrchr(file, '/');
-  const char* leaf = (last_slash == NULL) ? file : last_slash + 1;
+  file_ = (last_slash == NULL) ? file : last_slash + 1;
   stream() << StringPrintf("%c %5d %5d %s:%d] ",
-    "IWEF"[severity], getpid(), gettid(), leaf, line);
+      "IWEF"[severity], getpid(), gettid(), file_, line);
 }
 
 LogMessage::~LogMessage() {
   if (errno_ != -1) {
-    stream() << ": " << strerror(errno);
+    stream() << ": " << strerror(errno_);
   }
   stream() << std::endl;
   if (severity_ == FATAL) {
-    stream() << "Aborting:" << std::endl;
-    dumpStackTrace(stream());
-    abort();
+    art::Runtime::Abort(file_, line_);
   }
 }