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.
This commit is contained in:
Michael Snyder 2000-05-26 23:22:41 +00:00
parent a799cbe274
commit c60c0f5f88
23 changed files with 131 additions and 61 deletions

View File

@ -199,6 +199,9 @@ kernel_u_size ()
#if defined(USE_PROC_FS) || defined(HAVE_GREGSET_T)
#include <sys/procfs.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/*
* See the comment in m68k-tdep.c regarding the utility of these functions.
*/

View File

@ -28,6 +28,9 @@
#include <sys/utsname.h>
#include <sys/procfs.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
extern int arm_apcs_32;
#define typeNone 0x00

View File

@ -59,3 +59,8 @@ linuxthreads_prepare_to_proceed PARAMS ((int step));
#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16))
/* Use elf_gregset_t and elf_fpregset_t, rather than
gregset_t and fpregset_t. */
#define GDB_GREGSET_T prgregset_t
#define GDB_FPREGSET_T prfpregset_t

View File

@ -48,6 +48,9 @@
#include "command.h"
#include "gdbcore.h"
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
void _initialize_core_regset PARAMS ((void));

View File

@ -40,6 +40,9 @@
#include "command.h"
#include "gdbcore.h"
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
static void fetch_core_registers PARAMS ((char *, unsigned, int, CORE_ADDR));
static void

View File

@ -281,6 +281,9 @@ m88k_register_u_addr (blockend, regnum)
#include <sys/procfs.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* Given a pointer to a general register set in /proc format (gregset_t *),
unpack the register contents and supply them as gdb's idea of the current
register values. */

50
gdb/gregset.h Normal file
View File

@ -0,0 +1,50 @@
/* Interface for functions using gregset and fpregset types.
Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of GDB.
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.
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.
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. */
#ifndef GDB_GREGSET_T
#define GDB_GREGSET_T gregset_t
#endif
#ifndef GDB_FPREGSET_T
#define GDB_FPREGSET_T fpregset_t
#endif
typedef GDB_GREGSET_T gdb_gregset_t;
typedef GDB_FPREGSET_T gdb_fpregset_t;
/* A gregset is a data structure supplied by the native OS containing
the general register values of the debugged process. Usually this
includes integer registers and control registers. An fpregset is a
data structure containing the floating point registers. These data
structures were originally a part of the /proc interface, but have
been borrowed or copied by other GDB targets, eg. Linux. */
/* Copy register values from the native target gregset / fpregset
into GDB's internal register cache. */
extern void supply_gregset (gdb_gregset_t *gregs);
extern void supply_fpregset (gdb_fpregset_t *fpregs);
/* Copy register values from GDB's register cache into
the native target gregset / fpregset. If regno is -1,
copy all the registers. */
extern void fill_gregset (gdb_gregset_t *gregs, int regno);
extern void fill_fpregset (gdb_fpregset_t *fpregs, int regno);

View File

@ -35,6 +35,9 @@
#include <sys/reg.h>
#endif
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* On Linux, threads are implemented as pseudo-processes, in which
case we may be tracing more than one process at a time. In that
case, inferior_pid will contain the main process ID and the

View File

@ -31,6 +31,9 @@
#include <sys/procfs.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* The /proc interface divides the target machine's register set up into
two different sets, the general register set (gregset) and the floating
point register set (fpregset). For each set, there is an ioctl to get

View File

@ -34,6 +34,9 @@
#include <asm/ptrace_offsets.h>
#include <sys/procfs.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* These must match the order of the register names.
Some sort of lookup table is needed because the offsets associated

View File

@ -30,6 +30,9 @@
#include <sys/procfs.h>
#include <setjmp.h> /* For JB_XXX. */
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* Size of elements in jmpbuf */
#define JB_ELEMENT_SIZE 4

View File

@ -33,6 +33,9 @@
#include <sys/procfs.h>
#include <setjmp.h> /* For JB_XXX. */
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
static void
fetch_core_registers PARAMS ((char *, unsigned int, int, CORE_ADDR));

View File

@ -125,6 +125,9 @@
#include <dlfcn.h> /* dynamic library interface */
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
#ifndef TIDGET
#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16)
#define PIDGET(PID) (((PID) & 0xffff))

View File

@ -507,6 +507,9 @@ lose:;
#include <sys/procfs.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* The /proc interface divides the target machine's register set up into
two different sets, the general register set (gregset) and the floating
point register set (fpregset). For each set, there is an ioctl to get

View File

@ -82,6 +82,9 @@ m68k_linux_register_u_addr (blockend, regnum)
#ifndef USE_PROC_FS
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
void
supply_gregset (gregsetp)
gregset_t *gregsetp;

View File

@ -239,6 +239,9 @@ m88k_register_u_addr (blockend, regnum)
#include <sys/procfs.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* Given a pointer to a general register set in /proc format (gregset_t *),
unpack the register contents and supply them as gdb's idea of the current
register values. */

View File

@ -27,6 +27,9 @@
#include <sys/procfs.h>
#include <setjmp.h> /* For JB_XXX. */
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* Size of elements in jmpbuf */
#define JB_ELEMENT_SIZE 4

View File

@ -31,6 +31,9 @@
#include <fcntl.h>
#include <sys/procfs.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
int
kernel_u_size ()
{

View File

@ -89,6 +89,9 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "proc-utils.h"
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* =================== TARGET_OPS "MODULE" =================== */
/*
@ -245,24 +248,6 @@ typedef prstatus_t gdb_prstatus_t;
typedef prstatus_t gdb_lwpstatus_t;
#endif /* NEW_PROC_API */
/* These #ifdefs are for sol2.x in particular. sol2.x has
both a "gregset_t" and a "prgregset_t", which have
similar uses but different layouts. sol2.x gdb tries to
use prgregset_t (and prfpregset_t) everywhere. */
#ifdef GDB_GREGSET_TYPE
typedef GDB_GREGSET_TYPE gdb_gregset_t;
#else
typedef gregset_t gdb_gregset_t;
#endif
#ifdef GDB_FPREGSET_TYPE
typedef GDB_FPREGSET_TYPE gdb_fpregset_t;
#else
typedef fpregset_t gdb_fpregset_t;
#endif
/* Provide default composite pid manipulation macros for systems that
don't have threads. */
@ -3470,19 +3455,6 @@ do_detach (signo)
* is resumed.
*/
/* These could go in a header file, but the many and various
definitions of gregset_t would make it tricky and ugly. Several
different native operating systems (notably Solaris and Linux) have
various different definitions for gregset_t and fpregset_t. We
have been kludging around this problem for a while, it would be
nice if someday we came up with a prettier way of handling it
(FIXME). */
extern void fill_gregset (gdb_gregset_t *, int);
extern void fill_fpregset (gdb_fpregset_t *, int);
extern void supply_gregset (gdb_gregset_t *);
extern void supply_fpregset (gdb_fpregset_t *);
static void
procfs_fetch_registers (regno)
int regno;

View File

@ -26,6 +26,9 @@
#include <sys/param.h>
#include <fcntl.h>
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* Given a pointer to a general register set in /proc format (gregset_t *),
unpack the register contents and supply them as gdb's idea of the current
register values. */

View File

@ -72,19 +72,8 @@ extern struct target_ops procfs_ops; /* target vector for procfs.c */
extern struct target_ops core_ops; /* target vector for corelow.c */
extern char *procfs_pid_to_str PARAMS ((int pid));
/* Note that these prototypes differ slightly from those used in procfs.c
for of two reasons. One, we can't use gregset_t, as that's got a whole
different meaning under Solaris (also, see above). Two, we can't use the
pointer form here as these are actually arrays of ints (for Sparc's at
least), and are automatically coerced into pointers to ints when used as
parameters. That makes it impossible to avoid a compiler warning when
passing pr{g fp}regset_t's from a parameter to an argument of one of
these functions. */
extern void supply_gregset PARAMS ((const prgregset_t));
extern void fill_gregset PARAMS ((prgregset_t, int));
extern void supply_fpregset PARAMS ((const prfpregset_t *));
extern void fill_fpregset PARAMS ((prfpregset_t *, int));
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* This struct is defined by us, but mainly used for the proc_service interface.
We don't have much use for it, except as a handy place to get a real pid
@ -660,8 +649,8 @@ sol_thread_fetch_registers (regno)
because the td routines call ps_lget* which affect the values stored in the
registers array. */
supply_gregset (gregset);
supply_fpregset (&fpregset);
supply_gregset ((gdb_gregset_t *) &gregset);
supply_fpregset ((gdb_fpregset_t *) &fpregset);
#if 0
/* thread_db doesn't seem to handle this right */
@ -688,7 +677,7 @@ sol_thread_store_registers (regno)
thread_t thread;
td_thrhandle_t thandle;
td_err_e val;
prgregset_t regset;
prgregset_t gregset;
prfpregset_t fpregset;
#if 0
int xregsize;
@ -716,7 +705,7 @@ sol_thread_store_registers (regno)
char old_value[REGISTER_SIZE];
memcpy (old_value, &registers[REGISTER_BYTE (regno)], REGISTER_SIZE);
val = p_td_thr_getgregs (&thandle, regset);
val = p_td_thr_getgregs (&thandle, gregset);
if (val != TD_OK)
error ("sol_thread_store_registers: td_thr_getgregs %s",
td_err_string (val));
@ -746,10 +735,10 @@ sol_thread_store_registers (regno)
#endif
}
fill_gregset (regset, regno);
fill_fpregset (&fpregset, regno);
fill_gregset ((gdb_gregset_t *) &gregset, regno);
fill_fpregset ((gdb_fpregset_t *) &fpregset, regno);
val = p_td_thr_setgregs (&thandle, regset);
val = p_td_thr_setgregs (&thandle, gregset);
if (val != TD_OK)
error ("sol_thread_store_registers: td_thr_setgregs %s",
td_err_string (val));
@ -1163,7 +1152,7 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
procfs_ops.to_fetch_registers (-1);
else
orig_core_ops.to_fetch_registers (-1);
fill_gregset (gregset, -1);
fill_gregset ((gdb_gregset_t *) gregset, -1);
do_cleanups (old_chain);
@ -1182,7 +1171,7 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
inferior_pid = BUILD_LWP (lwpid, PIDGET (inferior_pid));
supply_gregset (gregset);
supply_gregset ((gdb_gregset_t *) gregset);
if (target_has_execution)
procfs_ops.to_store_registers (-1);
else
@ -1295,7 +1284,7 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
procfs_ops.to_fetch_registers (-1);
else
orig_core_ops.to_fetch_registers (-1);
fill_fpregset (fpregset, -1);
fill_fpregset ((gdb_fpregset_t *) fpregset, -1);
do_cleanups (old_chain);
@ -1314,7 +1303,7 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid,
inferior_pid = BUILD_LWP (lwpid, PIDGET (inferior_pid));
supply_fpregset (fpregset);
supply_fpregset ((gdb_fpregset_t *) fpregset);
if (target_has_execution)
procfs_ops.to_store_registers (-1);
else

View File

@ -39,6 +39,9 @@
#include "symfile.h" /* for 'entry_point_address' */
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/*
* Some local macros that have multi-arch and non-multi-arch versions:
*/
@ -1431,15 +1434,13 @@ sunos4_skip_trampoline_code (pc)
*/
/* *INDENT-ON* */
/* Given a pointer to a general register set in /proc format (gregset_t *),
unpack the register contents and supply them as gdb's idea of the current
register values. */
void
supply_gregset (gregsetp)
prgregset_t *gregsetp;
gdb_gregset_t *gregsetp;
{
prgreg_t *regp = (prgreg_t *) gregsetp;
int regi, offset = 0;
@ -1561,7 +1562,7 @@ supply_gregset (gregsetp)
void
fill_gregset (gregsetp, regno)
prgregset_t *gregsetp;
gdb_gregset_t *gregsetp;
int regno;
{
prgreg_t *regp = (prgreg_t *) gregsetp;
@ -1643,7 +1644,7 @@ fill_gregset (gregsetp, regno)
void
supply_fpregset (fpregsetp)
prfpregset_t *fpregsetp;
gdb_fpregset_t *fpregsetp;
{
register int regi;
char *from;
@ -1682,7 +1683,7 @@ supply_fpregset (fpregsetp)
void
fill_fpregset (fpregsetp, regno)
prfpregset_t *fpregsetp;
gdb_fpregset_t *fpregsetp;
int regno;
{
int regi;

View File

@ -112,6 +112,8 @@
#include <synch.h> /* for UnixWare 2.x */
/* Prototypes for supply_gregset etc. */
#include "gregset.h"
/* Whether to emit debugging output. */