Run the verifier single-threaded.
Also improve crash dumps so the frame numbers are the same as when you're
in gdb, and add a more memorably-named environment variable for waiting
for gdb.
(cherry picked from commit 5db7ea037e9acad434efe8ab4ce798c513fdb49a)
Change-Id: I428569d84dc5728bcd090919456395be44bdc97b
diff --git a/src/compiler.cc b/src/compiler.cc
index 89f35b3..4d98d61 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -447,7 +447,11 @@
TimingLogger timings("compiler");
+ // TODO: make the verifier thread-safe and remove this workaround.
+ size_t thread_count = thread_count_;
+ thread_count_ = 1;
PreCompile(class_loader, dex_files, timings);
+ thread_count_ = thread_count;
Compile(class_loader, dex_files);
timings.AddSplit("Compile");
diff --git a/src/runtime_linux.cc b/src/runtime_linux.cc
index 5856f06..88a4a25 100644
--- a/src/runtime_linux.cc
+++ b/src/runtime_linux.cc
@@ -254,8 +254,7 @@
<< "Registers:\n" << Dumpable<UContext>(thread_context) << "\n"
<< "Backtrace:\n" << Dumpable<Backtrace>(thread_backtrace);
- // TODO: instead, get debuggerd running on the host, try to connect, and hang around on success.
- if (getenv("debug_db_uid") != NULL) {
+ if (getenv("debug_db_uid") != NULL || getenv("art_wait_for_gdb_on_crash") != NULL) {
LOG(INTERNAL_FATAL) << "********************************************************\n"
<< "* Process " << getpid() << " thread " << tid << " \"" << thread_name << "\""
<< " has been suspended while crashing.\n"
diff --git a/src/utils.cc b/src/utils.cc
index c3c3f79..d8b0837 100644
--- a/src/utils.cc
+++ b/src/utils.cc
@@ -970,7 +970,8 @@
const size_t MAX_DEPTH = 32;
UniquePtr<backtrace_frame_t[]> frames(new backtrace_frame_t[MAX_DEPTH]);
- ssize_t frame_count = unwind_backtrace_thread(tid, frames.get(), 0, MAX_DEPTH);
+ size_t ignore_count = 2; // Don't include unwind_backtrace_thread or DumpNativeStack.
+ ssize_t frame_count = unwind_backtrace_thread(tid, frames.get(), ignore_count, MAX_DEPTH);
if (frame_count == -1) {
os << prefix << "(unwind_backtrace_thread failed for thread " << tid << ")\n";
return;