[PATCH] i386-linux-nat.c: Permit access to all registers if GETREGS is available
Peter.Schauer
Peter.Schauer@regent.e-technik.tu-muenchen.de
Fri Sep 22 10:48:00 GMT 2000
> The Linux/x86 changes look fine to me, so consider those to be
> approved :-).
>
> Mark
FYI,
I checked in the attached patch.
2000-09-22 Peter Schauer <pes@regent.e-technik.tu-muenchen.de>
* i386-linux-nat.c (OLD_CANNOT_FETCH_REGISTER,
OLD_CANNOT_FETCH_REGISTER): New definitions for accessible registers
when accessing the registers via the U area.
(fetch_register, store_register): Use them.
(cannot_fetch_register, cannot_store_register): New functions,
all registers should be accessible if we have GETREGS support.
* config/i386/nm-linux.h: Use cannot_fetch/store_register for
CANNOT_FETCH/STORE_REGISTER definitions.
*** ./config/i386/nm-linux.h.orig Fri Sep 15 21:27:38 2000
--- ./config/i386/nm-linux.h Sun Sep 17 12:24:45 2000
***************
*** 65,76 ****
/* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */
#define FETCH_INFERIOR_REGISTERS
! /* Nevertheless, define CANNOT_{FETCH,STORE}_REGISTER, because we fall
back on the code `infptrace.c' (well a copy of that code in
`i386-linux-nat.c' for now) and we can access only the
general-purpose registers in that way. */
! #define CANNOT_FETCH_REGISTER(regno) ((regno) >= NUM_GREGS)
! #define CANNOT_STORE_REGISTER(regno) CANNOT_FETCH_REGISTER (regno)
/* Override child_resume in `infptrace.c'. */
#define CHILD_RESUME
--- 65,78 ----
/* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */
#define FETCH_INFERIOR_REGISTERS
! /* Nevertheless, define CANNOT_{FETCH,STORE}_REGISTER, because we might fall
back on the code `infptrace.c' (well a copy of that code in
`i386-linux-nat.c' for now) and we can access only the
general-purpose registers in that way. */
! extern int cannot_fetch_register (int regno);
! extern int cannot_store_register (int regno);
! #define CANNOT_FETCH_REGISTER(regno) cannot_store_register (regno)
! #define CANNOT_STORE_REGISTER(regno) cannot_fetch_register (regno)
/* Override child_resume in `infptrace.c'. */
#define CHILD_RESUME
*** ./i386-linux-nat.c.orig Fri Sep 15 21:27:11 2000
--- ./i386-linux-nat.c Fri Sep 22 12:42:47 2000
***************
*** 133,141 ****
#endif
/* Registers we shouldn't try to fetch. */
! #if !defined (CANNOT_FETCH_REGISTER)
! #define CANNOT_FETCH_REGISTER(regno) 0
! #endif
/* Fetch one register. */
--- 133,139 ----
#endif
/* Registers we shouldn't try to fetch. */
! #define OLD_CANNOT_FETCH_REGISTER(regno) ((regno) >= NUM_GREGS)
/* Fetch one register. */
***************
*** 150,156 ****
char buf[MAX_REGISTER_RAW_SIZE];
int tid;
! if (CANNOT_FETCH_REGISTER (regno))
{
memset (buf, '\0', REGISTER_RAW_SIZE (regno)); /* Supply zeroes */
supply_register (regno, buf);
--- 148,154 ----
char buf[MAX_REGISTER_RAW_SIZE];
int tid;
! if (OLD_CANNOT_FETCH_REGISTER (regno))
{
memset (buf, '\0', REGISTER_RAW_SIZE (regno)); /* Supply zeroes */
supply_register (regno, buf);
***************
*** 201,209 ****
}
/* Registers we shouldn't try to store. */
! #if !defined (CANNOT_STORE_REGISTER)
! #define CANNOT_STORE_REGISTER(regno) 0
! #endif
/* Store one register. */
--- 199,205 ----
}
/* Registers we shouldn't try to store. */
! #define OLD_CANNOT_STORE_REGISTER(regno) ((regno) >= NUM_GREGS)
/* Store one register. */
***************
*** 217,223 ****
unsigned int offset; /* Offset of registers within the u area. */
int tid;
! if (CANNOT_STORE_REGISTER (regno))
{
return;
}
--- 213,219 ----
unsigned int offset; /* Offset of registers within the u area. */
int tid;
! if (OLD_CANNOT_STORE_REGISTER (regno))
{
return;
}
***************
*** 513,518 ****
--- 509,534 ----
/* Transferring arbitrary registers between GDB and inferior. */
+ /* Check if register REGNO in the child process is accessible.
+ If we are accessing registers directly via the U area, only the
+ general-purpose registers are available.
+ All registers should be accessible if we have GETREGS support. */
+
+ int
+ cannot_fetch_register (int regno)
+ {
+ if (! have_ptrace_getregs)
+ return OLD_CANNOT_FETCH_REGISTER (regno);
+ return 0;
+ }
+ int
+ cannot_store_register (int regno)
+ {
+ if (! have_ptrace_getregs)
+ return OLD_CANNOT_STORE_REGISTER (regno);
+ return 0;
+ }
+
/* Fetch register REGNO from the child process. If REGNO is -1, do
this for all registers (including the floating point and SSE
registers). */
--
Peter Schauer pes@regent.e-technik.tu-muenchen.de
More information about the Gdb-patches
mailing list