0006-Define-correct-gregs-for-RISCV32.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From dd3ecb07bbf80b986b8f2c656ea11d1346e212f6 Mon Sep 17 00:00:00 2001
  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. Upstream-Status: Pending
  6. Signed-off-by: Khem Raj <raj.khem@gmail.com>
  7. Updated patch for 6.2.8
  8. Signed-off-by: Changqing Li <changqing.li@windriver.com>
  9. ---
  10. src/debug.c | 26 ++++++++++++++++++++++++--
  11. 1 file changed, 24 insertions(+), 2 deletions(-)
  12. diff --git a/src/debug.c b/src/debug.c
  13. index 684f692..2ee151f 100644
  14. --- a/src/debug.c
  15. +++ b/src/debug.c
  16. @@ -1215,7 +1215,9 @@ static void* getAndSetMcontextEip(ucontext_t *uc, void *eip) {
  17. #endif
  18. #elif defined(__linux__)
  19. /* Linux */
  20. - #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
  21. + #if defined(__riscv) && __riscv_xlen == 32
  22. + return (void*) uc->uc_mcontext.__gregs[REG_PC];
  23. + #elif defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
  24. GET_SET_RETURN(uc->uc_mcontext.gregs[14], eip);
  25. #elif defined(__X86_64__) || defined(__x86_64__)
  26. GET_SET_RETURN(uc->uc_mcontext.gregs[16], eip);
  27. @@ -1401,8 +1403,28 @@ void logRegisters(ucontext_t *uc) {
  28. #endif
  29. /* Linux */
  30. #elif defined(__linux__)
  31. + /* Linux RISCV32 */
  32. + #if defined(__riscv) && __riscv_xlen == 32
  33. + serverLog(LL_WARNING,
  34. + "\n"
  35. + "RA:%08lx S0:%08lx S1:%08lx S2:%08lx\n"
  36. + "SP:%08lx PC:%08lx A0:%08lx A1:%08lx\n"
  37. + "A2 :%08lx A3:%08lx A4:%08lx",
  38. + (unsigned long) uc->uc_mcontext.__gregs[REG_RA],
  39. + (unsigned long) uc->uc_mcontext.__gregs[REG_S0],
  40. + (unsigned long) uc->uc_mcontext.__gregs[REG_S1],
  41. + (unsigned long) uc->uc_mcontext.__gregs[REG_S2],
  42. + (unsigned long) uc->uc_mcontext.__gregs[REG_SP],
  43. + (unsigned long) uc->uc_mcontext.__gregs[REG_PC],
  44. + (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 0],
  45. + (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 1],
  46. + (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 2],
  47. + (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 3],
  48. + (unsigned long) uc->uc_mcontext.__gregs[REG_A0 + 4]
  49. + );
  50. + logStackContent((void**)uc->uc_mcontext.__gregs[REG_SP]);
  51. /* Linux x86 */
  52. - #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
  53. + #elif defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__))
  54. serverLog(LL_WARNING,
  55. "\n"
  56. "EAX:%08lx EBX:%08lx ECX:%08lx EDX:%08lx\n"