Dmitry V. Levin
5105d4ac96
Apparently, there are only two types of instruction pointer printers depending on the architecture: those that print a register that was fetched earlier, and those that fetch a register themselves using upeek. With this change, architectures of the first type have ARCH_PC_REG defined in their arch_regs.c file, architectures of the first type have ARCH_PC_PEEK_ADDR defined there, and the common code in syscall.c uses these macros to print the instruction pointer. * Makefile.am (EXTRA_DIST): Remove linux/*/print_pc.c. * linux/*/print_pc.c: Remove. * linux/aarch64/arch_regs.c(ARCH_PC_REG): Define macro. * linux/arc/arch_regs.c(ARCH_PC_REG): Likewise. * linux/arm/arch_regs.c(ARCH_PC_REG): Likewise. * linux/avr32/arch_regs.c(ARCH_PC_REG): Likewise. * linux/i386/arch_regs.c(ARCH_PC_REG): Likewise. * linux/ia64/arch_regs.c(ARCH_PC_REG): Likewise. * linux/metag/arch_regs.c(ARCH_PC_REG): Likewise. * linux/mips/arch_regs.c(ARCH_PC_REG): Likewise. * linux/nios2/arch_regs.c(ARCH_PC_REG): Likewise. * linux/or1k/arch_regs.c(ARCH_PC_REG): Likewise. * linux/powerpc64/arch_regs.c(ARCH_PC_REG): Likewise. * linux/powerpc/arch_regs.c(ARCH_PC_REG): Likewise. * linux/s390/arch_regs.c(ARCH_PC_REG): Likewise. * linux/s390x/arch_regs.c(ARCH_PC_REG): Likewise. * linux/sparc64/arch_regs.c(ARCH_PC_REG): Likewise. * linux/sparc/arch_regs.c(ARCH_PC_REG): Likewise. * linux/tile/arch_regs.c(ARCH_PC_REG): Likewise. * linux/x32/arch_regs.c(ARCH_PC_REG): Likewise. * linux/x86_64/arch_regs.c(ARCH_PC_REG): Likewise. * linux/alpha/arch_regs.c(ARCH_PC_PEEK_ADDR): Define macro. * linux/bfin/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * linux/crisv10/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * linux/crisv32/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * linux/hppa/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * linux/m68k/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * linux/microblaze/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * linux/sh64/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * linux/sh/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * linux/xtensa/arch_regs.c(ARCH_PC_PEEK_ADDR): Likewise. * syscall.c (print_pc): Stop including "print_pc.c". Use ARCH_PC_REG or ARCH_PC_PEEK_ADDR.
42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
/*
|
|
* On i386, pt_regs and user_regs_struct are the same,
|
|
* but on 64 bit x86, user_regs_struct has six more fields:
|
|
* fs_base, gs_base, ds, es, fs, gs.
|
|
* PTRACE_GETREGS fills them too, so struct pt_regs would overflow.
|
|
*/
|
|
struct i386_user_regs_struct {
|
|
uint32_t ebx;
|
|
uint32_t ecx;
|
|
uint32_t edx;
|
|
uint32_t esi;
|
|
uint32_t edi;
|
|
uint32_t ebp;
|
|
uint32_t eax;
|
|
uint32_t xds;
|
|
uint32_t xes;
|
|
uint32_t xfs;
|
|
uint32_t xgs;
|
|
uint32_t orig_eax;
|
|
uint32_t eip;
|
|
uint32_t xcs;
|
|
uint32_t eflags;
|
|
uint32_t esp;
|
|
uint32_t xss;
|
|
};
|
|
static union {
|
|
struct user_regs_struct x86_64_r;
|
|
struct i386_user_regs_struct i386_r;
|
|
} x86_regs_union;
|
|
#define x86_64_regs x86_regs_union.x86_64_r
|
|
#define i386_regs x86_regs_union.i386_r
|
|
|
|
uint32_t *const i386_esp_ptr = &i386_regs.esp;
|
|
uint64_t *const x86_64_rsp_ptr = (uint64_t *) &x86_64_regs.rsp;
|
|
static struct iovec x86_io = {
|
|
.iov_base = &x86_regs_union
|
|
};
|
|
|
|
#define ARCH_REGS_FOR_GETREGSET x86_regs_union
|
|
#define ARCH_IOVEC_FOR_GETREGSET x86_io
|
|
#define ARCH_PC_REG (x86_io.iov_len == sizeof(i386_regs) ? i386_regs.eip : x86_64_regs.rip)
|