Clean up host aborts (and simplify the code).
Change-Id: I6efaf065304459df0e030f242f8d1d2fc6fdec4a
diff --git a/src/logging.cc b/src/logging.cc
index 4aacd3b..b0f3055 100644
--- a/src/logging.cc
+++ b/src/logging.cc
@@ -55,7 +55,7 @@
// Abort if necessary.
if (data_->severity == FATAL) {
- Runtime::Abort(data_->file, data_->line_number);
+ Runtime::Abort();
}
delete data_;
diff --git a/src/runtime.cc b/src/runtime.cc
index 37887e2..3f80260 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -146,7 +146,7 @@
return abort_lock;
}
-void Runtime::Abort(const char* file, int line) {
+void Runtime::Abort() {
// Ensure that we don't have multiple threads trying to abort at once,
// which would result in significantly worse diagnostics.
MutexLock mu(GetAbortLock());
@@ -159,10 +159,7 @@
AbortState state;
LOG(INTERNAL_FATAL) << Dumpable<AbortState>(state);
- // Perform any platform-specific pre-abort actions.
- PlatformAbort(file, line);
-
- // use abort hook if we have one
+ // Call the abort hook if we have one.
if (Runtime::Current() != NULL && Runtime::Current()->abort_ != NULL) {
Runtime::Current()->abort_();
// notreached
diff --git a/src/runtime.h b/src/runtime.h
index dc61b15..b682b67 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -120,7 +120,7 @@
// This isn't marked ((noreturn)) because then gcc will merge multiple calls
// in a single function together. This reduces code size slightly, but means
// that the native stack trace we get may point at the wrong call site.
- static void Abort(const char* file, int line);
+ static void Abort();
// Attaches the calling native thread to the runtime.
void AttachCurrentThread(const char* thread_name, bool as_daemon, Object* thread_group);
@@ -246,7 +246,6 @@
void SetCompileTimeClassPath(const ClassLoader* class_loader, std::vector<const DexFile*>& class_path);
private:
- static void PlatformAbort(const char*, int);
static void InitPlatformSignalHandlers();
Runtime();
diff --git a/src/runtime_android.cc b/src/runtime_android.cc
index b64f8a1..2013294 100644
--- a/src/runtime_android.cc
+++ b/src/runtime_android.cc
@@ -18,10 +18,6 @@
namespace art {
-void Runtime::PlatformAbort(const char*, int) {
- // On a device, debuggerd will give us a stack trace. Nothing to do here.
-}
-
void Runtime::InitPlatformSignalHandlers() {
// On a device, debuggerd will give us a stack trace. Nothing to do here.
}
diff --git a/src/runtime_linux.cc b/src/runtime_linux.cc
index c4d4b3c..b7e7d01 100644
--- a/src/runtime_linux.cc
+++ b/src/runtime_linux.cc
@@ -56,11 +56,11 @@
}
// backtrace_symbols(3) gives us lines like this:
- // "/usr/local/google/home/enh/a1/out/host/linux-x86/bin/../lib/libartd.so(_ZN3art7Runtime13PlatformAbortEPKci+0x15b) [0xf76c5af3]"
+ // "/usr/local/google/home/enh/a1/out/host/linux-x86/bin/../lib/libartd.so(_ZN3art7Runtime5AbortEPKci+0x15b) [0xf76c5af3]"
// "[0xf7b62057]"
// We extract the pieces and demangle, so we can produce output like this:
- // libartd.so:-1] #00 art::Runtime::PlatformAbort(char const*, int) +0x15b [0xf770dd51]
+ // libartd.so:-1] #00 art::Runtime::Abort(char const*, int) +0x15b [0xf770dd51]
for (size_t i = 0; i < frame_count; ++i) {
std::string text(symbols[i]);
@@ -180,6 +180,9 @@
signal_name = "SIGPIPE";
}
+ // Remove ourselves as signal handler for this signal, in case of recursion.
+ signal(signal_number, SIG_DFL);
+
LOG(INTERNAL_FATAL) << "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***\n"
<< StringPrintf("Fatal signal %d (%s), code %d (%s)",
signal_number, signal_name,
@@ -200,11 +203,6 @@
}
}
-void Runtime::PlatformAbort(const char* /*file*/, int /*line_number*/) {
- // On the host, we don't have debuggerd to dump a stack for us when we LOG(FATAL).
- Backtrace();
-}
-
void Runtime::InitPlatformSignalHandlers() {
// On the host, we don't have debuggerd to dump a stack for us when something unexpected happens.
struct sigaction action;