Reland "[Berberis][CrashReporting] Dump guest thread inf..."
Guest thread information will print out follow host thread.
Revert submission 3081452-revert-3062926-CJGHTRPCBP
Reason for revert: Will make the change base on the original CLs for a reland.
Bug: b/321799516
Test: riscv64, checked tombstone file has wanted block.
https://paste.googleplex.com/6282302317658112
Added arm64 support and tested arm64 unwinding in internal repo.
https://paste.googleplex.com/6545612887818240
Change-Id: Ie54ad6f359d60283442adfcd9ee95f5a116e4b72
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 6706650..852c159 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -81,6 +81,10 @@
using android::base::StringPrintf;
using android::base::unique_fd;
+// This stores guest architecture. When the architecture is supported, tombstone file will output
+// guest state information.
+static Architecture g_guest_arch;
+
static bool pid_contains_tid(int pid_proc_fd, pid_t tid) {
struct stat st;
std::string task_path = StringPrintf("task/%d", tid);
@@ -495,6 +499,8 @@
arm64_user_regs.sp = guest_regs.regs_arm64.sp;
arm64_user_regs.pc = guest_regs.regs_arm64.ip;
regs->reset(unwindstack::RegsArm64::Read(&arm64_user_regs));
+
+ g_guest_arch = Architecture::ARM64;
break;
}
case NATIVE_BRIDGE_ARCH_RISCV64: {
@@ -505,6 +511,8 @@
riscv64_user_regs.regs[i] = guest_regs.regs_riscv64.x[i];
}
regs->reset(unwindstack::RegsRiscv64::Read(&riscv64_user_regs, tid));
+
+ g_guest_arch = Architecture::RISCV64;
break;
}
#endif
@@ -771,8 +779,32 @@
{
ATRACE_NAME("engrave_tombstone");
- engrave_tombstone(std::move(g_output_fd), std::move(g_proto_fd), &unwinder, thread_info,
- g_target_thread, process_info, &open_files, &amfd_data);
+ unwindstack::ArchEnum regs_arch = unwindstack::ARCH_UNKNOWN;
+ switch (g_guest_arch) {
+ case Architecture::ARM32: {
+ regs_arch = unwindstack::ARCH_ARM;
+ break;
+ }
+ case Architecture::ARM64: {
+ regs_arch = unwindstack::ARCH_ARM64;
+ break;
+ }
+ case Architecture::RISCV64: {
+ regs_arch = unwindstack::ARCH_RISCV64;
+ break;
+ }
+ default: {
+ }
+ }
+ if (regs_arch == unwindstack::ARCH_UNKNOWN) {
+ engrave_tombstone(std::move(g_output_fd), std::move(g_proto_fd), &unwinder, thread_info,
+ g_target_thread, process_info, &open_files, &amfd_data);
+ } else {
+ unwindstack::AndroidRemoteUnwinder guest_unwinder(vm_pid, regs_arch);
+ engrave_tombstone(std::move(g_output_fd), std::move(g_proto_fd), &unwinder, thread_info,
+ g_target_thread, process_info, &open_files, &amfd_data, &g_guest_arch,
+ &guest_unwinder);
+ }
}
}