vm_dump.c: Dump machine registers on RISC-V Linux

Fixes [Bug #17615]

Co-Authored-By: xtkoba (Tee KOBAYASHI) <xtkoba+ruby@gmail.com>
This commit is contained in:
Yusuke Endoh 2021-02-10 04:39:41 +09:00
Родитель e7a831de8e
Коммит 66394aec98
1 изменённых файлов: 24 добавлений и 2 удалений

Просмотреть файл

@ -781,7 +781,7 @@ rb_print_backtrace(void)
#endif
#if defined __linux__
# if defined __x86_64__ || defined __i386__ || defined __aarch64__ || defined __arm__
# if defined __x86_64__ || defined __i386__ || defined __aarch64__ || defined __arm__ || defined __riscv
# define HAVE_PRINT_MACHINE_REGISTERS 1
# endif
#elif defined __APPLE__
@ -813,7 +813,7 @@ print_machine_register(size_t reg, const char *reg_name, int col_count, int max_
# ifdef __linux__
# if defined(__x86_64__) || defined(__i386__)
# define dump_machine_register(reg) (col_count = print_machine_register(mctx->gregs[REG_##reg], #reg, col_count, 80))
# elif defined(__aarch64__) || defined(__arm__)
# elif defined(__aarch64__) || defined(__arm__) || defined(__riscv)
# define dump_machine_register(reg, regstr) (col_count = print_machine_register(reg, regstr, col_count, 80))
# endif
# elif defined __APPLE__
@ -908,6 +908,28 @@ rb_dump_machine_register(const ucontext_t *ctx)
dump_machine_register(mctx->arm_r10, "r10");
dump_machine_register(mctx->arm_sp, "sp");
dump_machine_register(mctx->fault_address, "fault_address");
# elif defined __riscv
dump_machine_register(mctx->__gregs[REG_SP], "sp");
dump_machine_register(mctx->__gregs[REG_S0], "s0");
dump_machine_register(mctx->__gregs[REG_S1], "s1");
dump_machine_register(mctx->__gregs[REG_A0], "a0");
dump_machine_register(mctx->__gregs[REG_A0+1], "a1");
dump_machine_register(mctx->__gregs[REG_A0+2], "a2");
dump_machine_register(mctx->__gregs[REG_A0+3], "a3");
dump_machine_register(mctx->__gregs[REG_A0+4], "a4");
dump_machine_register(mctx->__gregs[REG_A0+5], "a5");
dump_machine_register(mctx->__gregs[REG_A0+6], "a6");
dump_machine_register(mctx->__gregs[REG_A0+7], "a7");
dump_machine_register(mctx->__gregs[REG_S2], "s2");
dump_machine_register(mctx->__gregs[REG_S2+1], "s3");
dump_machine_register(mctx->__gregs[REG_S2+2], "s4");
dump_machine_register(mctx->__gregs[REG_S2+3], "s5");
dump_machine_register(mctx->__gregs[REG_S2+4], "s6");
dump_machine_register(mctx->__gregs[REG_S2+5], "s7");
dump_machine_register(mctx->__gregs[REG_S2+6], "s8");
dump_machine_register(mctx->__gregs[REG_S2+7], "s9");
dump_machine_register(mctx->__gregs[REG_S2+8], "s10");
dump_machine_register(mctx->__gregs[REG_S2+9], "s11");
# endif
}
# elif defined __APPLE__