Move `dump_machine_register` definitions

This commit is contained in:
Nobuyoshi Nakada 2023-02-22 16:45:58 +09:00
Родитель e9e4e1cb46
Коммит da0e6b99c7
1 изменённых файлов: 10 добавлений и 19 удалений

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

@ -808,16 +808,20 @@ rb_print_backtrace(void)
#endif
#if defined __linux__
# if defined __x86_64__ || defined __i386__ || defined __aarch64__ || defined __arm__ || defined __riscv || defined __loongarch64
# define HAVE_PRINT_MACHINE_REGISTERS 1
# 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__) || defined(__riscv) || defined(__loongarch64)
# define dump_machine_register(reg, regstr) (col_count = print_machine_register(reg, regstr, col_count, 80))
# endif
#elif defined __APPLE__
# if defined __x86_64__ || defined __i386__ || defined __aarch64__
# define HAVE_PRINT_MACHINE_REGISTERS 1
# if defined(__aarch64__)
# define dump_machine_register(reg, regstr) (col_count = print_machine_register(mctx->MCTX_SS_REG(reg), regstr, col_count, 80))
# else
# define dump_machine_register(reg) (col_count = print_machine_register(mctx->MCTX_SS_REG(reg), #reg, col_count, 80))
# endif
#endif
#ifdef HAVE_PRINT_MACHINE_REGISTERS
#ifdef dump_machine_register
static int
print_machine_register(size_t reg, const char *reg_name, int col_count, int max_col)
{
@ -834,19 +838,6 @@ print_machine_register(size_t reg, const char *reg_name, int col_count, int max_
fputs(buf, stderr);
return col_count;
}
# 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__) || defined(__riscv) || defined(__loongarch64)
# define dump_machine_register(reg, regstr) (col_count = print_machine_register(reg, regstr, col_count, 80))
# endif
# elif defined __APPLE__
# if defined(__aarch64__)
# define dump_machine_register(reg, regstr) (col_count = print_machine_register(mctx->MCTX_SS_REG(reg), regstr, col_count, 80))
# else
# define dump_machine_register(reg) (col_count = print_machine_register(mctx->MCTX_SS_REG(reg), #reg, col_count, 80))
# endif
# endif
static void
rb_dump_machine_register(const ucontext_t *ctx)
@ -1051,7 +1042,7 @@ rb_dump_machine_register(const ucontext_t *ctx)
}
#else
# define rb_dump_machine_register(ctx) ((void)0)
#endif /* HAVE_PRINT_MACHINE_REGISTERS */
#endif /* dump_machine_register */
void
rb_vm_bugreport(const void *ctx)