diff options
author | Jason Thorpe <thorpej@netbsd.org> | 2002-01-05 18:36:32 +0000 |
---|---|---|
committer | Jason Thorpe <thorpej@netbsd.org> | 2002-01-05 18:36:32 +0000 |
commit | 7e89e3575daf98bac9dece8abfab33dc42664626 (patch) | |
tree | d71aa1e80a63622dbc0b9023d444fb7d00c009c0 /gdb/i386bsd-nat.c | |
parent | 3dfe7a8c3a88e7b06afe7f8b98d247de175bec99 (diff) | |
download | gdb-7e89e3575daf98bac9dece8abfab33dc42664626.zip gdb-7e89e3575daf98bac9dece8abfab33dc42664626.tar.gz gdb-7e89e3575daf98bac9dece8abfab33dc42664626.tar.bz2 |
* acconfig.h (HAVE_PT_GETXMMREGS): New.
* config.in: Regenerate.
* configure.in: Update copyright years.
Add test for PT_GETXMMREGS supplied by <sys/ptrace.h>.
* configure: Regenerate.
* i386bsd-nat.c: Update copyright years.
(fill_gregset): Use regcache_collect.
(fetch_inferior_registers): Only fetch integer registers
if requested to do so. Add support for XMM registers
using PT_GETXMMREGS.
(store_inferior_registers): Only store integer registers
if requested to do so. Add support for XMM registers
using PT_SETXMMREGS.
* i386nbsd-nat.c (fetch_inferior_registers): Remove.
(store_inferior_registers): Remove.
(fetch_core_registers): Use supply_gregset and i387_supply_fsave.
(fetch_elfcore_registers): New function.
(i386nbsd_elfcore_fns): New.
(_initialize_i386nbsd_nat): Register i386nbsd_elfcore_fns.
* config/i386/nbsd.mh (NATDEPFILES): Add i387-nat.o and
i386bsd-nat.o.
* config/i386/nbsdelf.mh (NATDEPFILES): Likewise.
* config/i386/nbsd.mt (TDEPFILES): Add i386bsd-nat.o.
* config/i386/nbsdelf.mt (TDEPFILES): Likewise.
* config/i386/tm-nbsd.h: Update copyright years.
(HAVE_SSE_REGS): Define.
(IN_SIGTRAMP): Define as i386bsd_in_sigtramp.
(SIGTRAMP_START): Redefine as i386bsd_sigtramp_start.
(SIGTRAMP_END): Redefine as i386bsd_sigtramp_end.
(SIGCONTEXT_PC_OFFSET): Remove.
(FRAME_SAVED_PC): Define as i386bsd_frame_saved_pc.
Diffstat (limited to 'gdb/i386bsd-nat.c')
-rw-r--r-- | gdb/i386bsd-nat.c | 108 |
1 files changed, 85 insertions, 23 deletions
diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c index 081df2e..5d35830 100644 --- a/gdb/i386bsd-nat.c +++ b/gdb/i386bsd-nat.c @@ -1,5 +1,5 @@ /* Native-dependent code for modern i386 BSD's. - Copyright 2000, 2001 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of GDB. @@ -96,6 +96,16 @@ static int reg_offset[] = #define REG_ADDR(regset, regno) ((char *) (regset) + reg_offset[regno]) +/* Macro to determine if a register is fetched with PT_GETREGS. */ +#define GETREGS_SUPPLIES(regno) \ + ((0 <= (regno) && (regno) <= 15)) + +#ifdef HAVE_PT_GETXMMREGS +/* Set to 1 if the kernel supports PT_GETXMMREGS. Initialized to -1 + so that we try PT_GETXMMREGS the first time around. */ +static int have_ptrace_xmmregs = -1; +#endif + /* Return nonzero if we shouldn't try to fetch register REGNO. */ static int @@ -135,8 +145,7 @@ fill_gregset (gregset_t *gregsetp, int regno) for (i = 0; i < NUM_GREGS; i++) if ((regno == -1 || regno == i) && ! CANNOT_STORE_REGISTER (i)) - memcpy (REG_ADDR (gregsetp, i), ®isters[REGISTER_BYTE (i)], - REGISTER_RAW_SIZE (i)); + regcache_collect (i, REG_ADDR (gregsetp, i)); } #include "i387-nat.h" @@ -166,23 +175,48 @@ fill_fpregset (fpregset_t *fpregsetp, int regno) void fetch_inferior_registers (int regno) { - gregset_t gregs; - if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &gregs, 0) == -1) - perror_with_name ("Couldn't get registers"); + if (regno == -1 || GETREGS_SUPPLIES (regno)) + { + gregset_t gregs; + + if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &gregs, 0) == -1) + perror_with_name ("Couldn't get registers"); - supply_gregset (&gregs); + supply_gregset (&gregs); + if (regno != -1) + return; + } if (regno == -1 || regno >= FP0_REGNUM) { fpregset_t fpregs; +#ifdef HAVE_PT_GETXMMREGS + char xmmregs[512]; + + if (have_ptrace_xmmregs != 0 && + ptrace(PT_GETXMMREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) xmmregs, 0) == 0) + { + have_ptrace_xmmregs = 1; + i387_supply_fxsave (xmmregs); + } + else + { + if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) + perror_with_name ("Couldn't get floating point status"); + supply_fpregset (&fpregs); + } +#else if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) perror_with_name ("Couldn't get floating point status"); supply_fpregset (&fpregs); +#endif } } @@ -192,31 +226,59 @@ fetch_inferior_registers (int regno) void store_inferior_registers (int regno) { - gregset_t gregs; - if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &gregs, 0) == -1) - perror_with_name ("Couldn't get registers"); + if (regno == -1 || GETREGS_SUPPLIES (regno)) + { + gregset_t gregs; + + if (ptrace (PT_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &gregs, 0) == -1) + perror_with_name ("Couldn't get registers"); - fill_gregset (&gregs, regno); + fill_gregset (&gregs, regno); - if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &gregs, 0) == -1) - perror_with_name ("Couldn't write registers"); + if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &gregs, 0) == -1) + perror_with_name ("Couldn't write registers"); + + if (regno != -1) + return; + } if (regno == -1 || regno >= FP0_REGNUM) { fpregset_t fpregs; +#ifdef HAVE_PT_GETXMMREGS + char xmmregs[512]; - if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) - perror_with_name ("Couldn't get floating point status"); + if (have_ptrace_xmmregs != 0 && + ptrace(PT_GETXMMREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) xmmregs, 0) == 0) + { + have_ptrace_xmmregs = 1; + + i387_fill_fxsave (xmmregs, regno); - fill_fpregset (&fpregs, regno); + if (ptrace (PT_SETXMMREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) xmmregs, 0) == -1) + perror_with_name ("Couldn't write XMM registers"); + } + else + { + have_ptrace_xmmregs = 0; +#endif + if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) + perror_with_name ("Couldn't get floating point status"); + + fill_fpregset (&fpregs, regno); - if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), - (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) - perror_with_name ("Couldn't write floating point status"); + if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) &fpregs, 0) == -1) + perror_with_name ("Couldn't write floating point status"); +#ifdef HAVE_PT_GETXMMREGS + } +#endif } } |