From 8c0101b971ed1f4eac54d4f7c3952fdd686e9d5d Mon Sep 17 00:00:00 2001 From: Liu Cunyuan Date: Wed, 12 Oct 2022 22:35:51 +0800 Subject: [PATCH] Add tomstone proto support for riscv64 Signed-off-by: Liu Cunyuan Signed-off-by: Mao Han Change-Id: Ie22c2895fc30fab68eddc18713c80e403f44b203 --- debuggerd/libdebuggerd/tombstone_proto.cpp | 2 ++ debuggerd/libdebuggerd/tombstone_proto_to_text.cpp | 8 ++++++++ debuggerd/proto/tombstone.proto | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/debuggerd/libdebuggerd/tombstone_proto.cpp b/debuggerd/libdebuggerd/tombstone_proto.cpp index 159ebc85f..9a565deb6 100644 --- a/debuggerd/libdebuggerd/tombstone_proto.cpp +++ b/debuggerd/libdebuggerd/tombstone_proto.cpp @@ -82,6 +82,8 @@ static Architecture get_arch() { return Architecture::X86; #elif defined(__x86_64__) return Architecture::X86_64; +#elif defined(__riscv) && (__riscv_xlen == 64) + return Architecture::RISCV64; #else #error Unknown architecture! #endif diff --git a/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp b/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp index 026564112..28154a7af 100644 --- a/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp +++ b/debuggerd/libdebuggerd/tombstone_proto_to_text.cpp @@ -47,6 +47,8 @@ static const char* abi_string(const Tombstone& tombstone) { return "arm"; case Architecture::ARM64: return "arm64"; + case Architecture::RISCV64: + return "riscv64"; case Architecture::X86: return "x86"; case Architecture::X86_64: @@ -62,6 +64,8 @@ static int pointer_width(const Tombstone& tombstone) { return 4; case Architecture::ARM64: return 8; + case Architecture::RISCV64: + return 8; case Architecture::X86: return 4; case Architecture::X86_64: @@ -119,6 +123,10 @@ static void print_thread_registers(CallbackType callback, const Tombstone& tombs special_registers = {"ip", "lr", "sp", "pc", "pst"}; break; + case Architecture::RISCV64: + special_registers = {"ra", "sp", "pc"}; + break; + case Architecture::X86: special_registers = {"ebp", "esp", "eip"}; break; diff --git a/debuggerd/proto/tombstone.proto b/debuggerd/proto/tombstone.proto index f0d3d3f4b..49865a2bb 100644 --- a/debuggerd/proto/tombstone.proto +++ b/debuggerd/proto/tombstone.proto @@ -48,8 +48,9 @@ enum Architecture { ARM64 = 1; X86 = 2; X86_64 = 3; + RISCV64 = 4; - reserved 4 to 999; + reserved 5 to 999; } message Signal {