From 75ed08fb0bcd3306897d7dfbad189ea4d2fb8919 Mon Sep 17 00:00:00 2001 From: Sijie Chen Date: Thu, 23 May 2024 00:10:07 +0000 Subject: [PATCH] [Berberis][CrashReporting] Add riscv case for thread local retrieve As title. Bug: 339287219 Test: NA Change-Id: Ia75659330d1203f4f1fbaf019d41cb72c3986cd4 --- debuggerd/crash_dump.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp index 77d4a07af..1c1fb8a59 100644 --- a/debuggerd/crash_dump.cpp +++ b/debuggerd/crash_dump.cpp @@ -449,7 +449,16 @@ static bool GetGuestRegistersFromCrashedProcess([[maybe_unused]] pid_t tid, if (ptrace(PTRACE_GETREGSET, tid, NT_ARM_TLS, &pt_iov) != 0) { PLOG(ERROR) << "failed to read thread register for thread " << tid; + return false; } +#elif defined(__riscv) + struct user_regs_struct regs; + struct iovec pt_iov = {.iov_base = ®s, .iov_len = sizeof(regs)}; + if (ptrace(PTRACE_GETREGSET, tid, NT_PRSTATUS, &pt_iov) != 0) { + PLOG(ERROR) << "failed to read thread register for thread " << tid; + return false; + } + base = reinterpret_cast(regs.tp); #else // TODO(b/339287219): Add case for Riscv host. return false;