Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 1 | From b6b2c652abfa98093401b232baca8719c50cadf4 Mon Sep 17 00:00:00 2001 |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Mon, 26 Oct 2020 21:32:22 -0700 |
| 4 | Subject: [PATCH] Define correct gregs for RISCV32 |
| 5 | |
| 6 | Upstream-Status: Pending |
| 7 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 8 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 9 | Updated patch for 6.2.8 |
| 10 | Signed-off-by: Changqing Li <changqing.li@windriver.com> |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 11 | --- |
| 12 | src/debug.c | 26 ++++++++++++++++++++++++-- |
| 13 | 1 file changed, 24 insertions(+), 2 deletions(-) |
| 14 | |
| 15 | diff --git a/src/debug.c b/src/debug.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 16 | index ebda858..90bc450 100644 |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 17 | --- a/src/debug.c |
| 18 | +++ b/src/debug.c |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 19 | @@ -1168,7 +1168,9 @@ static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) { |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 20 | #endif |
| 21 | #elif defined(__linux__) |
| 22 | /* Linux */ |
| 23 | - #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__)) |
| 24 | + #if defined(__riscv) && __riscv_xlen == 32 |
| 25 | + return (void*) uc->uc_mcontext.__gregs[REG_PC]; |
| 26 | + #elif defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__)) |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 27 | GET_SET_RETURN(uc->uc_mcontext.gregs[14], eip); |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 28 | #elif defined(__X86_64__) || defined(__x86_64__) |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 29 | GET_SET_RETURN(uc->uc_mcontext.gregs[16], eip); |
| 30 | @@ -1350,8 +1352,28 @@ void logRegisters(ucontext_t *uc) { |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 31 | #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 */ |
| 55 | - #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__)) |
| 56 | + #elif defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__)) |
| 57 | serverLog(LL_WARNING, |
| 58 | "\n" |
| 59 | "EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n" |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame^] | 60 | -- |
| 61 | 2.25.1 |
| 62 | |