@@ -808,7 +808,7 @@ rb_print_backtrace(void)
808808#endif
809809
810810#if defined __linux__
811- # if defined __x86_64__ || defined __i386__ || defined __aarch64__ || defined __arm__ || defined __riscv
811+ # if defined __x86_64__ || defined __i386__ || defined __aarch64__ || defined __arm__ || defined __riscv || defined __loongarch64
812812# define HAVE_PRINT_MACHINE_REGISTERS 1
813813# endif
814814#elif defined __APPLE__
@@ -837,7 +837,7 @@ print_machine_register(size_t reg, const char *reg_name, int col_count, int max_
837837# ifdef __linux__
838838# if defined(__x86_64__ ) || defined(__i386__ )
839839# define dump_machine_register (reg ) (col_count = print_machine_register(mctx->gregs[REG_##reg], #reg, col_count, 80))
840- # elif defined(__aarch64__ ) || defined(__arm__ ) || defined(__riscv )
840+ # elif defined(__aarch64__ ) || defined(__arm__ ) || defined(__riscv ) || defined( __loongarch64 )
841841# define dump_machine_register (reg , regstr ) (col_count = print_machine_register(reg, regstr, col_count, 80))
842842# endif
843843# elif defined __APPLE__
@@ -958,6 +958,28 @@ rb_dump_machine_register(const ucontext_t *ctx)
958958 dump_machine_register (mctx -> __gregs [REG_S2 + 7 ], "s9" );
959959 dump_machine_register (mctx -> __gregs [REG_S2 + 8 ], "s10" );
960960 dump_machine_register (mctx -> __gregs [REG_S2 + 9 ], "s11" );
961+ # elif defined __loongarch64
962+ dump_machine_register (mctx -> __gregs [LARCH_REG_SP ], "sp" );
963+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 ], "s0" );
964+ dump_machine_register (mctx -> __gregs [LARCH_REG_S1 ], "s1" );
965+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 ], "a0" );
966+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 + 1 ], "a1" );
967+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 + 2 ], "a2" );
968+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 + 3 ], "a3" );
969+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 + 4 ], "a4" );
970+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 + 5 ], "a5" );
971+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 + 6 ], "a6" );
972+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 + 7 ], "a7" );
973+ dump_machine_register (mctx -> __gregs [LARCH_REG_A0 + 7 ], "a7" );
974+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 ], "s0" );
975+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 + 1 ], "s1" );
976+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 + 2 ], "s2" );
977+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 + 3 ], "s3" );
978+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 + 4 ], "s4" );
979+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 + 5 ], "s5" );
980+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 + 6 ], "s6" );
981+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 + 7 ], "s7" );
982+ dump_machine_register (mctx -> __gregs [LARCH_REG_S0 + 8 ], "s8" );
961983# endif
962984 }
963985# elif defined __APPLE__
0 commit comments