Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move dump_machine_register definitions #7361

Merged
merged 1 commit into from Feb 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 10 additions & 19 deletions vm_dump.c
Expand Up @@ -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)
{
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down