Add handler for printing java stack traces for compiled code SIGSEGV.
Added a new FaultHandler which attempts to print a java stack trace
when a SIGSEGV occurse in generated code. This should help debugging
compiler and GC related heap corruption.
Bug: 13725693
Bug: 12934910
Change-Id: Id54d83ea180c222eb86d449c61926e83f0b026ad
diff --git a/runtime/thread.cc b/runtime/thread.cc
index fd5b599..2125ad5 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -830,7 +830,7 @@
int line_number = -1;
if (dex_cache != nullptr) { // be tolerant of bad input
const DexFile& dex_file = *dex_cache->GetDexFile();
- line_number = dex_file.GetLineNumFromPC(m, GetDexPc());
+ line_number = dex_file.GetLineNumFromPC(m, GetDexPc(false));
}
if (line_number == last_line_number && last_method == m) {
++repetition_count;
@@ -903,6 +903,13 @@
return current_method != nullptr && current_method->IsNative();
}
+void Thread::DumpJavaStack(std::ostream& os) const {
+ UniquePtr<Context> context(Context::Create());
+ StackDumpVisitor dumper(os, const_cast<Thread*>(this), context.get(),
+ !tls32_.throwing_OutOfMemoryError);
+ dumper.WalkStack();
+}
+
void Thread::DumpStack(std::ostream& os) const {
// TODO: we call this code when dying but may not have suspended the thread ourself. The
// IsSuspended check is therefore racy with the use for dumping (normally we inhibit
@@ -916,10 +923,7 @@
SirtRef<mirror::ArtMethod> method_ref(Thread::Current(), GetCurrentMethod(nullptr));
DumpNativeStack(os, GetTid(), " native: ", false, method_ref.get());
}
- UniquePtr<Context> context(Context::Create());
- StackDumpVisitor dumper(os, const_cast<Thread*>(this), context.get(),
- !tls32_.throwing_OutOfMemoryError);
- dumper.WalkStack();
+ DumpJavaStack(os);
} else {
os << "Not able to dump stack of thread that isn't suspended";
}