ART: Reprint long messages on abort am: 90a32b16fe am: 4d22cfff72
am: f494d8f681
Change-Id: I6aacb2e73ea0869481e23ce08b1dfbbfdfbb1540
diff --git a/runtime/base/logging.cc b/runtime/base/logging.cc
index d09e66f..08c036e 100644
--- a/runtime/base/logging.cc
+++ b/runtime/base/logging.cc
@@ -64,7 +64,7 @@
#else
UNUSED(abort_message);
#endif
- Runtime::Abort();
+ Runtime::Abort(abort_message);
}
void InitLogging(char* argv[]) {
diff --git a/runtime/indirect_reference_table.cc b/runtime/indirect_reference_table.cc
index 1eee7c4..b742ccc 100644
--- a/runtime/indirect_reference_table.cc
+++ b/runtime/indirect_reference_table.cc
@@ -129,15 +129,9 @@
DCHECK_GE(segment_state_.parts.numHoles, prevState.parts.numHoles);
if (topIndex == max_entries_) {
- std::ostringstream oss;
- oss << "JNI ERROR (app bug): " << kind_ << " table overflow "
- << "(max=" << max_entries_ << ")\n"
- << MutatorLockedDumpable<IndirectReferenceTable>(*this);
- if (VLOG_IS_ON(jni)) {
- LOG(FATAL) << oss.str();
- } else {
- LOG_FATAL_THIS_THREAD_ONLY(oss.str());
- }
+ LOG(FATAL) << "JNI ERROR (app bug): " << kind_ << " table overflow "
+ << "(max=" << max_entries_ << ")\n"
+ << MutatorLockedDumpable<IndirectReferenceTable>(*this);
}
// We know there's enough room in the table. Now we just need to find
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index 0d876c7..e29b5ee 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -422,7 +422,7 @@
}
};
-void Runtime::Abort() {
+void Runtime::Abort(const char* msg) {
gAborting++; // set before taking any locks
// Ensure that we don't have multiple threads trying to abort at once,
@@ -437,6 +437,12 @@
AbortState state;
LOG(FATAL_WITHOUT_ABORT) << Dumpable<AbortState>(state);
+ // Sometimes we dump long messages, and the Android abort message only retains the first line.
+ // In those cases, just log the message again, to avoid logcat limits.
+ if (msg != nullptr && strchr(msg, '\n') != nullptr) {
+ LOG(FATAL_WITHOUT_ABORT) << msg;
+ }
+
// Call the abort hook if we have one.
if (Runtime::Current() != nullptr && Runtime::Current()->abort_ != nullptr) {
LOG(FATAL_WITHOUT_ABORT) << "Calling abort hook...";
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 30f1b4a..84c6b6f 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -225,7 +225,7 @@
// Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
// callers should prefer.
- NO_RETURN static void Abort() REQUIRES(!Locks::abort_lock_);
+ NO_RETURN static void Abort(const char* msg) REQUIRES(!Locks::abort_lock_);
// Returns the "main" ThreadGroup, used when attaching user threads.
jobject GetMainThreadGroup() const;