2004-06-27 21:52:21 +00:00
|
|
|
/* Native-dependent code for Unix SVR4 running on i386's.
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
Copyright 1988, 1989, 1991, 1992, 1996, 1997, 1998, 1999, 2000,
|
2004-06-27 21:52:21 +00:00
|
|
|
2001, 2002, 2004
|
2001-03-06 08:22:02 +00:00
|
|
|
Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
This file is part of GDB.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
#include "value.h"
|
1999-04-26 18:34:20 +00:00
|
|
|
#include "inferior.h"
|
2001-03-01 01:39:22 +00:00
|
|
|
#include "regcache.h"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_REG_H
|
|
|
|
#include <sys/reg.h>
|
|
|
|
#endif
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
#include "i386-tdep.h"
|
|
|
|
#include "i387-tdep.h"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_SYS_PROCFS_H
|
|
|
|
|
|
|
|
#include <sys/procfs.h>
|
|
|
|
|
2000-05-26 Michael Snyder <msnyder@seadog.cygnus.com>
* gregset.h: New file. Typedefs for gdb_gregset_t and
gdb_fpregset_t, prototypes for supply_gregset and friends.
* procfs.c: Include gregset.h. Delete local prototypes for
supply_gregset etc., and local typedef gdb_gregset_t etc.
* sol-thread.c: Include gregset.h, delete local prototypes,
add appropriate casts to gdb_gregset_t.
* uw-thread.c, lin-thread.c, core-sol2.c, core-regset.c,
sparc-tdep.c, ptx4-nat.c, ppc-linux-nat.c, mipsv4-nat.c,
m88k-nat.c, m68klinux-nat.c, m68k-tdep.c, irix5-nat.c,
irix4-nat.c, ia64-linux-nat.c, i386v4-nat.c, cxux-nat.c,
arm-linux-nat.c, alpha-nat.c: Include gregset.h.
* config/nm-linux.h: Define GDB_GREGSET_T, GDB_FPREGET_T.
* config/sparc/tm-sun4sol2.h: Ditto.
2000-05-26 23:22:41 +00:00
|
|
|
/* Prototypes for supply_gregset etc. */
|
|
|
|
#include "gregset.h"
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
/* The `/proc' interface divides the target machine's register set up
|
|
|
|
into two different sets, the general purpose register set (gregset)
|
|
|
|
and the floating-point register set (fpregset). For each set,
|
|
|
|
there is an ioctl to get the current register set and another ioctl
|
|
|
|
to set the current values.
|
1999-07-07 20:19:36 +00:00
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
The actual structure passed through the ioctl interface is, of
|
|
|
|
course, naturally machine dependent, and is different for each set
|
|
|
|
of registers. For the i386 for example, the general-purpose
|
|
|
|
register set is typically defined by:
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
|
|
typedef int gregset_t[19]; (in <sys/regset.h>)
|
|
|
|
|
|
|
|
#define GS 0 (in <sys/reg.h>)
|
|
|
|
#define FS 1
|
|
|
|
...
|
|
|
|
#define UESP 17
|
|
|
|
#define SS 18
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
and the floating-point set by:
|
|
|
|
|
|
|
|
typedef struct fpregset {
|
|
|
|
union {
|
|
|
|
struct fpchip_state // fp extension state //
|
|
|
|
{
|
|
|
|
int state[27]; // 287/387 saved state //
|
|
|
|
int status; // status word saved at //
|
|
|
|
// exception //
|
|
|
|
} fpchip_state;
|
|
|
|
struct fp_emul_space // for emulators //
|
|
|
|
{
|
|
|
|
char fp_emul[246];
|
|
|
|
char fp_epad[2];
|
|
|
|
} fp_emul_space;
|
|
|
|
int f_fpregs[62]; // union of the above //
|
|
|
|
} fp_reg_set;
|
|
|
|
long f_wregs[33]; // saved weitek state //
|
1999-07-07 20:19:36 +00:00
|
|
|
} fpregset_t;
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
Incidentally fpchip_state contains the FPU state in the same format
|
|
|
|
as used by the "fsave" instruction, and that's the only thing we
|
|
|
|
support here. I don't know how the emulator stores it state. The
|
|
|
|
Weitek stuff definitely isn't supported.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
The routines defined here, provide the packing and unpacking of
|
|
|
|
gregset_t and fpregset_t formatted data. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_GREGSET_T
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
/* Mapping between the general-purpose registers in `/proc'
|
|
|
|
format and GDB's register array layout. */
|
1999-07-07 20:19:36 +00:00
|
|
|
static int regmap[] =
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
|
|
|
EAX, ECX, EDX, EBX,
|
|
|
|
UESP, EBP, ESI, EDI,
|
|
|
|
EIP, EFL, CS, SS,
|
2004-06-27 21:52:21 +00:00
|
|
|
DS, ES, FS, GS
|
1999-04-16 01:35:26 +00:00
|
|
|
};
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
/* Fill GDB's register array with the general-purpose register values
|
|
|
|
in *GREGSETP. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
supply_gregset (gregset_t *gregsetp)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
2002-06-15 17:22:04 +00:00
|
|
|
greg_t *regp = (greg_t *) gregsetp;
|
2004-06-27 21:52:21 +00:00
|
|
|
int regnum;
|
2002-06-15 17:22:04 +00:00
|
|
|
|
2004-06-27 21:52:21 +00:00
|
|
|
for (regnum = 0; regnum < I386_NUM_GREGS; regnum++)
|
|
|
|
regcache_raw_supply (current_regcache, regnum, regp + regmap[regnum]);
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2004-06-27 21:52:21 +00:00
|
|
|
/* Fill register REGNUM (if it is a general-purpose register) in
|
|
|
|
*GREGSETPS with the value in GDB's register array. If REGNUM is -1,
|
2002-06-15 17:22:04 +00:00
|
|
|
do this for all registers. */
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
void
|
2004-06-27 21:52:21 +00:00
|
|
|
fill_gregset (gregset_t *gregsetp, int regnum)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
2002-06-15 17:22:04 +00:00
|
|
|
greg_t *regp = (greg_t *) gregsetp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < I386_NUM_GREGS; i++)
|
2004-06-27 21:52:21 +00:00
|
|
|
if (regnum == -1 || regnum == i)
|
|
|
|
regcache_raw_collect (current_regcache, i, regp + regmap[i]);
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
#endif /* HAVE_GREGSET_T */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
#ifdef HAVE_FPREGSET_T
|
1999-04-16 01:35:26 +00:00
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
/* Fill GDB's register array with the floating-point register values in
|
|
|
|
*FPREGSETP. */
|
2000-04-13 18:11:41 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
supply_fpregset (fpregset_t *fpregsetp)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
2002-06-15 17:22:04 +00:00
|
|
|
if (FP0_REGNUM == 0)
|
2000-04-13 18:11:41 +00:00
|
|
|
return;
|
|
|
|
|
2003-09-28 13:35:44 +00:00
|
|
|
i387_supply_fsave (current_regcache, -1, fpregsetp);
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
/* Fill register REGNO (if it is a floating-point register) in
|
|
|
|
*FPREGSETP with the value in GDB's register array. If REGNO is -1,
|
|
|
|
do this for all registers. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
fill_fpregset (fpregset_t *fpregsetp, int regno)
|
1999-04-16 01:35:26 +00:00
|
|
|
{
|
2002-06-15 17:22:04 +00:00
|
|
|
if (FP0_REGNUM == 0)
|
2000-04-13 18:11:41 +00:00
|
|
|
return;
|
2002-02-13 08:10:30 +00:00
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
i387_fill_fsave ((char *) fpregsetp, regno);
|
1999-04-16 01:35:26 +00:00
|
|
|
}
|
|
|
|
|
2002-06-15 17:22:04 +00:00
|
|
|
#endif /* HAVE_FPREGSET_T */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
#endif /* HAVE_SYS_PROCFS_H */
|