Tidy gAborting.
Reduce scope to Runtime::Abort and short-cut recursive case earlier. gAborting
remains global to avoid two fatal errors in thread and the verifier.
Change-Id: Ibc893f891ffee9a763c65cde9507d99083d47b3f
diff --git a/runtime/base/logging.cc b/runtime/base/logging.cc
index b781d60..bdc4cf6 100644
--- a/runtime/base/logging.cc
+++ b/runtime/base/logging.cc
@@ -35,8 +35,6 @@
LogVerbosity gLogVerbosity;
-unsigned int gAborting = 0;
-
static LogSeverity gMinimumLogSeverity = INFO;
static std::unique_ptr<std::string> gCmdLine;
static std::unique_ptr<std::string> gProgramInvocationName;
diff --git a/runtime/base/logging.h b/runtime/base/logging.h
index ae83e33..a9cc99b 100644
--- a/runtime/base/logging.h
+++ b/runtime/base/logging.h
@@ -55,11 +55,6 @@
// Global log verbosity setting, initialized by InitLogging.
extern LogVerbosity gLogVerbosity;
-// 0 if not abort, non-zero if an abort is in progress. Used on fatal exit to prevents recursive
-// aborts. Global declaration allows us to disable some error checking to ensure fatal shutdown
-// makes forward progress.
-extern unsigned int gAborting;
-
// Configure logging based on ANDROID_LOG_TAGS environment variable.
// We need to parse a string that looks like
//
diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h
index cb69817..0206341 100644
--- a/runtime/base/mutex-inl.h
+++ b/runtime/base/mutex-inl.h
@@ -97,9 +97,7 @@
}
}
}
- if (gAborting == 0) { // Avoid recursive aborts.
- CHECK(!bad_mutexes_held);
- }
+ CHECK(!bad_mutexes_held);
}
// Don't record monitors as they are outside the scope of analysis. They may be inspected off of
// the monitor list.
@@ -114,7 +112,7 @@
return;
}
if (level_ != kMonitorLock) {
- if (kDebugLocking && gAborting == 0) { // Avoid recursive aborts.
+ if (kDebugLocking) {
CHECK(self->GetHeldMutex(level_) == this) << "Unlocking on unacquired mutex: " << name_;
}
self->SetHeldMutex(level_, NULL);
@@ -178,7 +176,7 @@
bool result = (GetExclusiveOwnerTid() == SafeGetTid(self));
if (kDebugLocking) {
// Sanity debug check that if we think it is locked we have it in our held mutexes.
- if (result && self != NULL && level_ != kMonitorLock && !gAborting) {
+ if (result && self != NULL && level_ != kMonitorLock) {
CHECK_EQ(self->GetHeldMutex(level_), this);
}
}
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index aa2aefc..4957988 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -209,9 +209,7 @@
}
}
}
- if (gAborting == 0) { // Avoid recursive aborts.
- CHECK(!bad_mutexes_held);
- }
+ CHECK(!bad_mutexes_held);
}
}
diff --git a/runtime/base/mutex.h b/runtime/base/mutex.h
index 9c93cc6..41b5f12 100644
--- a/runtime/base/mutex.h
+++ b/runtime/base/mutex.h
@@ -220,7 +220,7 @@
// Assert that the Mutex is exclusively held by the current thread.
void AssertExclusiveHeld(const Thread* self) {
- if (kDebugLocking && (gAborting == 0)) {
+ if (kDebugLocking) {
CHECK(IsExclusiveHeld(self)) << *this;
}
}
@@ -228,7 +228,7 @@
// Assert that the Mutex is not held by the current thread.
void AssertNotHeldExclusive(const Thread* self) {
- if (kDebugLocking && (gAborting == 0)) {
+ if (kDebugLocking) {
CHECK(!IsExclusiveHeld(self)) << *this;
}
}
@@ -318,7 +318,7 @@
// Assert the current thread has exclusive access to the ReaderWriterMutex.
void AssertExclusiveHeld(const Thread* self) {
- if (kDebugLocking && (gAborting == 0)) {
+ if (kDebugLocking) {
CHECK(IsExclusiveHeld(self)) << *this;
}
}
@@ -326,7 +326,7 @@
// Assert the current thread doesn't have exclusive access to the ReaderWriterMutex.
void AssertNotExclusiveHeld(const Thread* self) {
- if (kDebugLocking && (gAborting == 0)) {
+ if (kDebugLocking) {
CHECK(!IsExclusiveHeld(self)) << *this;
}
}
@@ -337,7 +337,7 @@
// Assert the current thread has shared access to the ReaderWriterMutex.
void AssertSharedHeld(const Thread* self) {
- if (kDebugLocking && (gAborting == 0)) {
+ if (kDebugLocking) {
// TODO: we can only assert this well when self != NULL.
CHECK(IsSharedHeld(self) || self == NULL) << *this;
}
@@ -347,7 +347,7 @@
// Assert the current thread doesn't hold this ReaderWriterMutex either in shared or exclusive
// mode.
void AssertNotHeld(const Thread* self) {
- if (kDebugLocking && (gAborting == 0)) {
+ if (kDebugLocking) {
CHECK(!IsSharedHeld(self)) << *this;
}
}