diff options
Diffstat (limited to 'gdb/amd64-linux-nat.c')
-rw-r--r-- | gdb/amd64-linux-nat.c | 154 |
1 files changed, 74 insertions, 80 deletions
diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c index b5b0703..799d79d 100644 --- a/gdb/amd64-linux-nat.c +++ b/gdb/amd64-linux-nat.c @@ -42,7 +42,7 @@ /* This definition comes from prctl.h. Kernels older than 2.5.64 do not have it. */ #ifndef PTRACE_ARCH_PRCTL -#define PTRACE_ARCH_PRCTL 30 +#define PTRACE_ARCH_PRCTL 30 #endif struct amd64_linux_nat_target final : public x86_linux_nat_target @@ -51,8 +51,8 @@ struct amd64_linux_nat_target final : public x86_linux_nat_target void fetch_registers (struct regcache *, int) override; void store_registers (struct regcache *, int) override; - bool low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction) - override; + bool low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, + int direction) override; }; static amd64_linux_nat_target the_amd64_linux_nat_target; @@ -66,28 +66,24 @@ static amd64_linux_nat_target the_amd64_linux_nat_target; little-endian we get away with that. */ /* From <sys/reg.h> on GNU/Linux i386. */ -static int amd64_linux_gregset32_reg_offset[] = -{ - RAX * 8, RCX * 8, /* %eax, %ecx */ - RDX * 8, RBX * 8, /* %edx, %ebx */ - RSP * 8, RBP * 8, /* %esp, %ebp */ - RSI * 8, RDI * 8, /* %esi, %edi */ - RIP * 8, EFLAGS * 8, /* %eip, %eflags */ - CS * 8, SS * 8, /* %cs, %ss */ - DS * 8, ES * 8, /* %ds, %es */ - FS * 8, GS * 8, /* %fs, %gs */ - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */ - -1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */ - -1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */ - -1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */ - -1, /* PKEYS register PKRU */ - ORIG_RAX * 8 /* "orig_eax" */ +static int amd64_linux_gregset32_reg_offset[] = { + RAX * 8, RCX * 8, /* %eax, %ecx */ + RDX * 8, RBX * 8, /* %edx, %ebx */ + RSP * 8, RBP * 8, /* %esp, %ebp */ + RSI * 8, RDI * 8, /* %esi, %edi */ + RIP * 8, EFLAGS * 8, /* %eip, %eflags */ + CS * 8, SS * 8, /* %cs, %ss */ + DS * 8, ES * 8, /* %ds, %es */ + FS * 8, GS * 8, /* %fs, %gs */ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* MPX registers BND0 ... BND3. */ + -1, -1, /* MPX registers BNDCFGU, BNDSTATUS. */ + -1, -1, -1, -1, -1, -1, -1, -1, /* k0 ... k7 (AVX512) */ + -1, -1, -1, -1, -1, -1, -1, -1, /* zmm0 ... zmm7 (AVX512) */ + -1, /* PKEYS register PKRU */ + ORIG_RAX * 8 /* "orig_eax" */ }; - /* Transfering the general-purpose registers between GDB, inferiors and core files. */ @@ -149,7 +145,7 @@ amd64_linux_collect_native_gregset (const struct regcache *regcache, if (regnum == -1 || regnum == I386_EAX_REGNUM) { - void *ptr = ((gdb_byte *) gregs + void *ptr = ((gdb_byte *) gregs + amd64_linux_gregset32_reg_offset[I386_EAX_REGNUM]); *(int64_t *) ptr = *(int32_t *) ptr; @@ -171,8 +167,8 @@ supply_gregset (struct regcache *regcache, const elf_gregset_t *gregsetp) do this for all registers. */ void -fill_gregset (const struct regcache *regcache, - elf_gregset_t *gregsetp, int regnum) +fill_gregset (const struct regcache *regcache, elf_gregset_t *gregsetp, + int regnum) { amd64_linux_collect_native_gregset (regcache, gregsetp, regnum); } @@ -193,12 +189,11 @@ supply_fpregset (struct regcache *regcache, const elf_fpregset_t *fpregsetp) -1, do this for all registers. */ void -fill_fpregset (const struct regcache *regcache, - elf_fpregset_t *fpregsetp, int regnum) +fill_fpregset (const struct regcache *regcache, elf_fpregset_t *fpregsetp, + int regnum) { amd64_collect_fxsave (regcache, regnum, fpregsetp); } - /* Transferring arbitrary registers between GDB and inferior. */ @@ -222,7 +217,7 @@ amd64_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum) elf_gregset_t regs; if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) - perror_with_name (_("Couldn't get registers")); + perror_with_name (_ ("Couldn't get registers")); amd64_supply_native_gregset (regcache, ®s, -1); if (regnum != -1) @@ -246,16 +241,17 @@ amd64_linux_nat_target::fetch_registers (struct regcache *regcache, int regnum) memset (xstateregs, 0, sizeof (xstateregs)); iov.iov_base = xstateregs; iov.iov_len = sizeof (xstateregs); - if (ptrace (PTRACE_GETREGSET, tid, - (unsigned int) NT_X86_XSTATE, (long) &iov) < 0) - perror_with_name (_("Couldn't get extended state status")); + if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE, + (long) &iov) + < 0) + perror_with_name (_ ("Couldn't get extended state status")); amd64_supply_xsave (regcache, -1, xstateregs); } else { if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name (_("Couldn't get floating point status")); + perror_with_name (_ ("Couldn't get floating point status")); amd64_supply_fxsave (regcache, -1, &fpregs); } @@ -282,12 +278,12 @@ amd64_linux_nat_target::store_registers (struct regcache *regcache, int regnum) elf_gregset_t regs; if (ptrace (PTRACE_GETREGS, tid, 0, (long) ®s) < 0) - perror_with_name (_("Couldn't get registers")); + perror_with_name (_ ("Couldn't get registers")); amd64_linux_collect_native_gregset (regcache, ®s, regnum); if (ptrace (PTRACE_SETREGS, tid, 0, (long) ®s) < 0) - perror_with_name (_("Couldn't write registers")); + perror_with_name (_ ("Couldn't write registers")); if (regnum != -1) return; @@ -304,44 +300,45 @@ amd64_linux_nat_target::store_registers (struct regcache *regcache, int regnum) iov.iov_base = xstateregs; iov.iov_len = sizeof (xstateregs); - if (ptrace (PTRACE_GETREGSET, tid, - (unsigned int) NT_X86_XSTATE, (long) &iov) < 0) - perror_with_name (_("Couldn't get extended state status")); + if (ptrace (PTRACE_GETREGSET, tid, (unsigned int) NT_X86_XSTATE, + (long) &iov) + < 0) + perror_with_name (_ ("Couldn't get extended state status")); amd64_collect_xsave (regcache, regnum, xstateregs, 0); - if (ptrace (PTRACE_SETREGSET, tid, - (unsigned int) NT_X86_XSTATE, (long) &iov) < 0) - perror_with_name (_("Couldn't write extended state status")); + if (ptrace (PTRACE_SETREGSET, tid, (unsigned int) NT_X86_XSTATE, + (long) &iov) + < 0) + perror_with_name (_ ("Couldn't write extended state status")); } else { if (ptrace (PTRACE_GETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name (_("Couldn't get floating point status")); + perror_with_name (_ ("Couldn't get floating point status")); amd64_collect_fxsave (regcache, regnum, &fpregs); if (ptrace (PTRACE_SETFPREGS, tid, 0, (long) &fpregs) < 0) - perror_with_name (_("Couldn't write floating point status")); + perror_with_name (_ ("Couldn't write floating point status")); } } } - /* This function is called by libthread_db as part of its handling of a request for a thread's local storage address. */ ps_err_e -ps_get_thread_area (struct ps_prochandle *ph, - lwpid_t lwpid, int idx, void **base) +ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx, + void **base) { if (gdbarch_bfd_arch_info (ph->thread->inf->gdbarch)->bits_per_word == 32) { unsigned int base_addr; ps_err_e result; - result = x86_linux_get_thread_area (lwpid, (void *) (long) idx, - &base_addr); + result + = x86_linux_get_thread_area (lwpid, (void *) (long) idx, &base_addr); if (result == PS_OK) { /* Extend the value to 64 bits. Here it's assumed that @@ -352,7 +349,6 @@ ps_get_thread_area (struct ps_prochandle *ph, } else { - /* FIXME: ezannoni-2003-07-09 see comment above about include file order. We could be getting bogus values for these two. */ gdb_assert (FS < ELF_NGREG); @@ -360,41 +356,40 @@ ps_get_thread_area (struct ps_prochandle *ph, switch (idx) { case FS: - { - unsigned long fs; - errno = 0; - fs = ptrace (PTRACE_PEEKUSER, lwpid, - offsetof (struct user_regs_struct, fs_base), 0); - if (errno == 0) - { - *base = (void *) fs; - return PS_OK; - } - } + { + unsigned long fs; + errno = 0; + fs = ptrace (PTRACE_PEEKUSER, lwpid, + offsetof (struct user_regs_struct, fs_base), 0); + if (errno == 0) + { + *base = (void *) fs; + return PS_OK; + } + } break; case GS: - { - unsigned long gs; - errno = 0; - gs = ptrace (PTRACE_PEEKUSER, lwpid, - offsetof (struct user_regs_struct, gs_base), 0); - if (errno == 0) - { - *base = (void *) gs; - return PS_OK; - } - } + { + unsigned long gs; + errno = 0; + gs = ptrace (PTRACE_PEEKUSER, lwpid, + offsetof (struct user_regs_struct, gs_base), 0); + if (errno == 0) + { + *base = (void *) gs; + return PS_OK; + } + } break; - default: /* Should not happen. */ + default: /* Should not happen. */ return PS_BADADDR; } } - return PS_ERR; /* ptrace failed. */ + return PS_ERR; /* ptrace failed. */ } - /* Convert a ptrace/host siginfo object, into/from the siginfo in the layout of the inferiors' architecture. Returns true if any @@ -403,8 +398,7 @@ ps_get_thread_area (struct ps_prochandle *ph, INF. */ bool -amd64_linux_nat_target::low_siginfo_fixup (siginfo_t *ptrace, - gdb_byte *inf, +amd64_linux_nat_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction) { struct gdbarch *gdbarch = get_frame_arch (get_current_frame ()); @@ -412,8 +406,7 @@ amd64_linux_nat_target::low_siginfo_fixup (siginfo_t *ptrace, /* Is the inferior 32-bit? If so, then do fixup the siginfo object. */ if (gdbarch_bfd_arch_info (gdbarch)->bits_per_word == 32) - return amd64_linux_siginfo_fixup_common (ptrace, inf, direction, - FIXUP_32); + return amd64_linux_siginfo_fixup_common (ptrace, inf, direction, FIXUP_32); /* No fixup for native x32 GDB. */ else if (gdbarch_addr_bit (gdbarch) == 32 && sizeof (void *) == 8) return amd64_linux_siginfo_fixup_common (ptrace, inf, direction, @@ -423,6 +416,7 @@ amd64_linux_nat_target::low_siginfo_fixup (siginfo_t *ptrace, } void _initialize_amd64_linux_nat (); + void _initialize_amd64_linux_nat () { |