blob: 9d7e502717270b67b328259e426368eaf8536e2e [file] [log] [blame]
Andrew Geissler517393d2023-01-13 08:55:19 -06001From 26bd72f3b8de22e5036d86e6c79f815853b83473 Mon Sep 17 00:00:00 2001
Andrew Geisslere34f8962021-04-15 15:53:51 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Mon, 26 Oct 2020 21:32:22 -0700
4Subject: [PATCH] Define correct gregs for RISCV32
Andrew Geisslerbbbd5f42020-10-30 15:42:48 -05005
6Upstream-Status: Pending
7Signed-off-by: Khem Raj <raj.khem@gmail.com>
Andrew Geisslere34f8962021-04-15 15:53:51 -05008
9Updated patch for 6.2.1
10Signed-off-by: Yi Fan Yu <yifan.yu@windriver.com>
11---
12 src/debug.c | 26 ++++++++++++++++++++++++--
13 1 file changed, 24 insertions(+), 2 deletions(-)
14
15diff --git a/src/debug.c b/src/debug.c
Andrew Geissler517393d2023-01-13 08:55:19 -060016index 5318c14..8c21b47 100644
Andrew Geisslerbbbd5f42020-10-30 15:42:48 -050017--- a/src/debug.c
18+++ b/src/debug.c
Andrew Geissler517393d2023-01-13 08:55:19 -060019@@ -1055,7 +1055,9 @@ static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) {
Andrew Geisslerbbbd5f42020-10-30 15:42:48 -050020 #endif
21 #elif defined(__linux__)
22 /* Linux */
Andrew Geisslere34f8962021-04-15 15:53:51 -050023- #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
Andrew Geisslerbbbd5f42020-10-30 15:42:48 -050024+ #if defined(__riscv) && __riscv_xlen == 32
25+ return (void*) uc->uc_mcontext.__gregs[REG_PC];
Andrew Geisslere34f8962021-04-15 15:53:51 -050026+ #elif defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
Andrew Geissler517393d2023-01-13 08:55:19 -060027 GET_SET_RETURN(uc->uc_mcontext.gregs[14], eip);
Andrew Geisslerbbbd5f42020-10-30 15:42:48 -050028 #elif defined(__X86_64__) || defined(__x86_64__)
Andrew Geissler517393d2023-01-13 08:55:19 -060029 GET_SET_RETURN(uc->uc_mcontext.gregs[16], eip);
30@@ -1222,8 +1224,28 @@ void logRegisters(ucontext_t *uc) {
Andrew Geisslerbbbd5f42020-10-30 15:42:48 -050031 #endif
32 /* Linux */
33 #elif defined(__linux__)
34+ /* Linux RISCV32 */
35+ #if defined(__riscv) && __riscv_xlen == 32
36+ serverLog(LL_WARNING,
37+ "\n"
38+ "RA:%08lx S0:%08lx S1:%08lx S2:%08lx\n"
39+ "SP:%08lx PC:%08lx A0:%08lx A1:%08lx\n"
40+ "A2 :%08lx A3:%08lx A4:%08lx",
41+ (unsigned long) uc->uc_mcontext.__gregs[REG_RA],
42+ (unsigned long) uc->uc_mcontext.__gregs[REG_S0],
43+ (unsigned long) uc->uc_mcontext.__gregs[REG_S1],
44+ (unsigned long) uc->uc_mcontext.__gregs[REG_S2],
45+ (unsigned long) uc->uc_mcontext.__gregs[REG_SP],
46+ (unsigned long) uc->uc_mcontext.__gregs[REG_PC],
47+ (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 0],
48+ (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 1],
49+ (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 2],
50+ (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 3],
51+ (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 4]
52+ );
53+ logStackContent((void**)uc->uc_mcontext.__gregs[REG_SP]);
54 /* Linux x86 */
Andrew Geisslere34f8962021-04-15 15:53:51 -050055- #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
56+ #elif defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
Andrew Geisslerbbbd5f42020-10-30 15:42:48 -050057 serverLog(LL_WARNING,
58 "\n"
59 "EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n"
Andrew Geissler517393d2023-01-13 08:55:19 -060060--
612.25.1
62