* [patch] Fix a few bugs in hppa-linux-nat
@ 2004-04-29 6:12 Randolph Chung
2004-05-04 15:05 ` Randolph Chung
2004-05-07 14:40 ` Andrew Cagney
0 siblings, 2 replies; 4+ messages in thread
From: Randolph Chung @ 2004-04-29 6:12 UTC (permalink / raw)
To: gdb-patches
These have been sitting in my system for a few days... when i submitted
the hppa-linux-nat code initially these weren't quite working. Finally
managed to track down the bugs. Ok to commit?
Fixes thread_db handling and some corefile stuff.
thanks,
randolph
2004-04-28 Randolph Chung <tausq@debian.org>
* hppa-linux-nat.c (fetch_register, store_register): Define.
(fetch_inferior_registers, store_inferior_registers): Define.
(supply_gregset): Add comment and clean up some unneeded code.
(fill_gregset): Add comment and fix so that it saves registers in
the right place in the gregset.
(fill_fpregset): Fix buffer overrun problem.
* config/pa/nm-linux.h (FETCH_INFERIOR_REGISTERS): Define.
Index: hppa-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-linux-nat.c,v
retrieving revision 1.1
diff -u -p -r1.1 hppa-linux-nat.c
--- hppa-linux-nat.c 29 Apr 2004 03:36:49 -0000 1.1
+++ hppa-linux-nat.c 29 Apr 2004 05:49:59 -0000
@@ -22,8 +22,10 @@
#include "gdbcore.h"
#include "regcache.h"
#include "gdb_string.h"
+#include "inferior.h"
#include <sys/procfs.h>
+#include <sys/ptrace.h>
#include <string.h>
#include <asm/offsets.h>
@@ -199,6 +201,99 @@ static const int greg_map[] =
CCR_REGNUM, EIEM_REGNUM,
};
+
+
+/* Fetch one register. */
+
+static void
+fetch_register (int regno)
+{
+ int tid;
+ int val;
+
+ if (CANNOT_FETCH_REGISTER (regno))
+ {
+ supply_register (regno, NULL);
+ return;
+ }
+
+ /* GNU/Linux LWP ID's are process ID's. */
+ tid = TIDGET (inferior_ptid);
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+
+ errno = 0;
+ val = ptrace (PTRACE_PEEKUSER, tid, register_addr (regno, 0), 0);
+ if (errno != 0)
+ error ("Couldn't read register %s (#%d): %s.", REGISTER_NAME (regno),
+ regno, safe_strerror (errno));
+
+ supply_register (regno, &val);
+}
+
+/* Store one register. */
+
+static void
+store_register (int regno)
+{
+ int tid;
+ int val;
+
+ if (CANNOT_STORE_REGISTER (regno))
+ return;
+
+ /* GNU/Linux LWP ID's are process ID's. */
+ tid = TIDGET (inferior_ptid);
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+
+ errno = 0;
+ regcache_collect (regno, &val);
+ ptrace (PTRACE_POKEUSER, tid, register_addr (regno, 0), val);
+ if (errno != 0)
+ error ("Couldn't write register %s (#%d): %s.", REGISTER_NAME (regno),
+ regno, safe_strerror (errno));
+}
+
+/* Fetch registers from the child process. Fetch all registers if
+ regno == -1, otherwise fetch all general registers or all floating
+ point registers depending upon the value of regno. */
+
+void
+fetch_inferior_registers (int regno)
+{
+ if (-1 == regno)
+ {
+ for (regno = 0; regno < NUM_REGS; regno++)
+ fetch_register (regno);
+ }
+ else
+ {
+ fetch_register (regno);
+ }
+}
+
+/* Store registers back into the inferior. Store all registers if
+ regno == -1, otherwise store all general registers or all floating
+ point registers depending upon the value of regno. */
+
+void
+store_inferior_registers (int regno)
+{
+ if (-1 == regno)
+ {
+ for (regno = 0; regno < NUM_REGS; regno++)
+ store_register (regno);
+ }
+ else
+ {
+ store_register (regno);
+ }
+}
+
+/* Fill GDB's register array with the general-purpose register values
+ in *gregsetp. */
+
void
supply_gregset (gdb_gregset_t *gregsetp)
{
@@ -208,28 +303,26 @@ supply_gregset (gdb_gregset_t *gregsetp)
for (i = 0; i < sizeof (greg_map) / sizeof (greg_map[0]); i++, regp++)
{
int regno = greg_map[i];
- int size = register_size (current_gdbarch, regno);
- /* When running a 64 bit kernel, a greg_t may be larger than the
- actual register, so just pick off the LS bits of big-endian word. */
- supply_register (regno, ((char *) (regp + 1)) - size);
+ supply_register (regno, regp);
}
}
+/* Fill register regno (if it is a general-purpose register) in
+ *gregsetp with the appropriate value from GDB's register array.
+ If regno is -1, do this for all registers. */
+
void
fill_gregset (gdb_gregset_t *gregsetp, int regno)
{
int i;
- greg_t *regp = (greg_t *) gregsetp;
- memset (gregsetp, 0, sizeof (*gregsetp));
- for (i = 0; i < sizeof (greg_map) / sizeof (greg_map[0]); i++, regp++)
+ for (i = 0; i < sizeof (greg_map) / sizeof (greg_map[0]); i++)
{
- int regi = greg_map[i];
+ int mregno = greg_map[i];
- if (regno == -1 || regi == regno)
+ if (regno == -1 || regno == mregno)
{
- int rawsize = register_size (current_gdbarch, regi);
- regcache_collect (regi, ((char *) (regp + 1)) - rawsize);
+ regcache_collect(mregno, &(*gregsetp)[i]);
}
}
}
@@ -262,16 +355,13 @@ fill_fpregset (gdb_fpregset_t *fpregsetp
{
int i;
- for (i = 0; i < NUM_REGS; i++)
+ for (i = HPPA_FP0_REGNUM; i < HPPA_FP0_REGNUM + 32 * 2; i++)
{
- if (regno == -1 || regno == i)
- {
- /* Gross. fpregset_t is double, registers[x] has single
- precision reg. */
- char *to = (char *) &((*fpregsetp)[(i - HPPA_FP0_REGNUM) / 2]);
- if ((i - HPPA_FP0_REGNUM) & 1)
- to += 4;
- regcache_collect (i, to);
- }
+ /* Gross. fpregset_t is double, registers[x] has single
+ precision reg. */
+ char *to = (char *) &((*fpregsetp)[(i - HPPA_FP0_REGNUM) / 2]);
+ if ((i - HPPA_FP0_REGNUM) & 1)
+ to += 4;
+ regcache_collect (i, to);
}
}
Index: config/pa/nm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/pa/nm-linux.h,v
retrieving revision 1.1
diff -u -p -r1.1 nm-linux.h
--- config/pa/nm-linux.h 29 Apr 2004 03:36:50 -0000 1.1
+++ config/pa/nm-linux.h 29 Apr 2004 05:50:01 -0000
@@ -25,5 +25,8 @@
#define U_REGS_OFFSET 0
+/* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */
+#define FETCH_INFERIOR_REGISTERS
+
#endif
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] Fix a few bugs in hppa-linux-nat
2004-04-29 6:12 [patch] Fix a few bugs in hppa-linux-nat Randolph Chung
@ 2004-05-04 15:05 ` Randolph Chung
2004-05-07 14:40 ` Andrew Cagney
1 sibling, 0 replies; 4+ messages in thread
From: Randolph Chung @ 2004-05-04 15:05 UTC (permalink / raw)
To: gdb-patches
> 2004-04-28 Randolph Chung <tausq@debian.org>
>
> * hppa-linux-nat.c (fetch_register, store_register): Define.
> (fetch_inferior_registers, store_inferior_registers): Define.
> (supply_gregset): Add comment and clean up some unneeded code.
> (fill_gregset): Add comment and fix so that it saves registers in
> the right place in the gregset.
> (fill_fpregset): Fix buffer overrun problem.
> * config/pa/nm-linux.h (FETCH_INFERIOR_REGISTERS): Define.
ping?
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [patch] Fix a few bugs in hppa-linux-nat
2004-04-29 6:12 [patch] Fix a few bugs in hppa-linux-nat Randolph Chung
2004-05-04 15:05 ` Randolph Chung
@ 2004-05-07 14:40 ` Andrew Cagney
2004-05-08 3:28 ` Randolph Chung
1 sibling, 1 reply; 4+ messages in thread
From: Andrew Cagney @ 2004-05-07 14:40 UTC (permalink / raw)
To: Randolph Chung; +Cc: gdb-patches
> These have been sitting in my system for a few days... when i submitted
> the hppa-linux-nat code initially these weren't quite working. Finally
> managed to track down the bugs. Ok to commit?
>
> Fixes thread_db handling and some corefile stuff.
Just some tweaks before committing.
> 2004-04-28 Randolph Chung <tausq@debian.org>
>
> * hppa-linux-nat.c (fetch_register, store_register): Define.
> (fetch_inferior_registers, store_inferior_registers): Define.
> (supply_gregset): Add comment and clean up some unneeded code.
> (fill_gregset): Add comment and fix so that it saves registers in
> the right place in the gregset.
> (fill_fpregset): Fix buffer overrun problem.
> * config/pa/nm-linux.h (FETCH_INFERIOR_REGISTERS): Define.
Don't forget Makefile.in, and mention those extra #includes.
> Index: hppa-linux-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/hppa-linux-nat.c,v
> retrieving revision 1.1
> diff -u -p -r1.1 hppa-linux-nat.c
> --- hppa-linux-nat.c 29 Apr 2004 03:36:49 -0000 1.1
> +++ hppa-linux-nat.c 29 Apr 2004 05:49:59 -0000
> @@ -22,8 +22,10 @@
> #include "gdbcore.h"
> #include "regcache.h"
> #include "gdb_string.h"
> +#include "inferior.h"
>
> #include <sys/procfs.h>
> +#include <sys/ptrace.h>
> #include <string.h>
> #include <asm/offsets.h>
>
> @@ -199,6 +201,99 @@ static const int greg_map[] =
> CCR_REGNUM, EIEM_REGNUM,
> };
>
> +
> +
> +/* Fetch one register. */
> +
> +static void
> +fetch_register (int regno)
> +{
> + int tid;
> + int val;
> +
> + if (CANNOT_FETCH_REGISTER (regno))
> + {
> + supply_register (regno, NULL);
> + return;
> + }
> +
> + /* GNU/Linux LWP ID's are process ID's. */
> + tid = TIDGET (inferior_ptid);
> + if (tid == 0)
> + tid = PIDGET (inferior_ptid); /* Not a threaded program. */
> +
> + errno = 0;
> + val = ptrace (PTRACE_PEEKUSER, tid, register_addr (regno, 0), 0);
> + if (errno != 0)
> + error ("Couldn't read register %s (#%d): %s.", REGISTER_NAME (regno),
> + regno, safe_strerror (errno));
> +
> + supply_register (regno, &val);
use regcache_raw_supply.instead.
> +}
> +
> +/* Store one register. */
> +
> +static void
> +store_register (int regno)
> +{
> + int tid;
> + int val;
> +
> + if (CANNOT_STORE_REGISTER (regno))
> + return;
> +
> + /* GNU/Linux LWP ID's are process ID's. */
> + tid = TIDGET (inferior_ptid);
> + if (tid == 0)
> + tid = PIDGET (inferior_ptid); /* Not a threaded program. */
> +
> + errno = 0;
> + regcache_collect (regno, &val);
use regcache_raw_collect instead.
Andrew
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [patch] Fix a few bugs in hppa-linux-nat
2004-05-07 14:40 ` Andrew Cagney
@ 2004-05-08 3:28 ` Randolph Chung
0 siblings, 0 replies; 4+ messages in thread
From: Randolph Chung @ 2004-05-08 3:28 UTC (permalink / raw)
To: gdb-patches
> Just some tweaks before committing.
commited version:
2004-05-07 Randolph Chung <tausq@debian.org>
* Makefile.in (ALLDEPFILES): Add hppa-linux-tdep.c and
hppa-linux-nat.c.
(hppa-linux-tdep.o, hppa-linux-nat.o): Define rules.
* hppa-linux-nat.c (fetch_register, store_register): Define.
(fetch_inferior_registers, store_inferior_registers): Define.
(supply_gregset): Add comment and clean up some unneeded code.
(fill_gregset): Add comment and fix so that it saves registers in
the right place in the gregset.
(fill_fpregset): Fix buffer overrun problem.
* config/pa/nm-linux.h (FETCH_INFERIOR_REGISTERS): Define.
Index: Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.562
diff -u -p -r1.562 Makefile.in
--- Makefile.in 7 May 2004 22:51:52 -0000 1.562
+++ Makefile.in 8 May 2004 03:23:55 -0000
@@ -1329,6 +1329,7 @@ ALLDEPFILES = \
go32-nat.c h8300-tdep.c \
hppa-tdep.c hppa-hpux-tdep.c \
hppah-nat.c hpread.c \
+ hppa-linux-tdep.c hppa-linux-nat.c \
i386-tdep.c i386v-nat.c i386-linux-nat.c \
i386v4-nat.c i386ly-tdep.c i386-cygwin-tdep.c \
i386bsd-nat.c i386bsd-tdep.c i386fbsd-nat.c i386fbsd-tdep.c \
@@ -1837,6 +1838,12 @@ hppa-tdep.o: hppa-tdep.c $(defs_h) $(fra
$(frame_base_h) $(a_out_encap_h) $(gdb_stat_h) $(gdb_wait_h) \
$(gdbcore_h) $(gdbcmd_h) $(target_h) $(symfile_h) $(objfiles_h) \
$(hppa_tdep_h)
+hppa-linux-tdep.o: hppa-linux-tdep.c $(defs_h) $(gdbcore_h) $(osabi_h) \
+ $(target_h) $(objfiles_h) $(solib_svr4_h) $(glibc_tdep_h) \
+ $(frame_unwind_h) $(trad_frame_h) $(dwarf2_frame_h) $(hppa_tdep_h) \
+ $(elf_common_h)
+hppa-linux-nat.o: hppa-linux-nat.c $(defs_h) $(gdbcore_h) $(regcache_h) \
+ $(gdb_string_h) $(inferior_h)
hpread.o: hpread.c $(defs_h) $(bfd_h) $(gdb_string_h) $(hp_symtab_h) \
$(syms_h) $(symtab_h) $(symfile_h) $(objfiles_h) $(buildsym_h) \
$(complaints_h) $(gdb_stabs_h) $(gdbtypes_h) $(demangle_h) \
Index: hppa-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-linux-nat.c,v
retrieving revision 1.2
diff -u -p -r1.2 hppa-linux-nat.c
--- hppa-linux-nat.c 7 May 2004 05:48:49 -0000 1.2
+++ hppa-linux-nat.c 8 May 2004 03:23:55 -0000
@@ -22,8 +22,10 @@
#include "gdbcore.h"
#include "regcache.h"
#include "gdb_string.h"
+#include "inferior.h"
#include <sys/procfs.h>
+#include <sys/ptrace.h>
#include <string.h>
#include <asm/offsets.h>
@@ -201,6 +203,99 @@ static const int greg_map[] =
HPPA_CCR_REGNUM, HPPA_EIEM_REGNUM,
};
+
+
+/* Fetch one register. */
+
+static void
+fetch_register (int regno)
+{
+ int tid;
+ int val;
+
+ if (CANNOT_FETCH_REGISTER (regno))
+ {
+ supply_register (regno, NULL);
+ return;
+ }
+
+ /* GNU/Linux LWP ID's are process ID's. */
+ tid = TIDGET (inferior_ptid);
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+
+ errno = 0;
+ val = ptrace (PTRACE_PEEKUSER, tid, register_addr (regno, 0), 0);
+ if (errno != 0)
+ error ("Couldn't read register %s (#%d): %s.", REGISTER_NAME (regno),
+ regno, safe_strerror (errno));
+
+ regcache_raw_supply (current_regcache, regno, &val);
+}
+
+/* Store one register. */
+
+static void
+store_register (int regno)
+{
+ int tid;
+ int val;
+
+ if (CANNOT_STORE_REGISTER (regno))
+ return;
+
+ /* GNU/Linux LWP ID's are process ID's. */
+ tid = TIDGET (inferior_ptid);
+ if (tid == 0)
+ tid = PIDGET (inferior_ptid); /* Not a threaded program. */
+
+ errno = 0;
+ regcache_raw_collect (current_regcache, regno, &val);
+ ptrace (PTRACE_POKEUSER, tid, register_addr (regno, 0), val);
+ if (errno != 0)
+ error ("Couldn't write register %s (#%d): %s.", REGISTER_NAME (regno),
+ regno, safe_strerror (errno));
+}
+
+/* Fetch registers from the child process. Fetch all registers if
+ regno == -1, otherwise fetch all general registers or all floating
+ point registers depending upon the value of regno. */
+
+void
+fetch_inferior_registers (int regno)
+{
+ if (-1 == regno)
+ {
+ for (regno = 0; regno < NUM_REGS; regno++)
+ fetch_register (regno);
+ }
+ else
+ {
+ fetch_register (regno);
+ }
+}
+
+/* Store registers back into the inferior. Store all registers if
+ regno == -1, otherwise store all general registers or all floating
+ point registers depending upon the value of regno. */
+
+void
+store_inferior_registers (int regno)
+{
+ if (-1 == regno)
+ {
+ for (regno = 0; regno < NUM_REGS; regno++)
+ store_register (regno);
+ }
+ else
+ {
+ store_register (regno);
+ }
+}
+
+/* Fill GDB's register array with the general-purpose register values
+ in *gregsetp. */
+
void
supply_gregset (gdb_gregset_t *gregsetp)
{
@@ -210,28 +305,26 @@ supply_gregset (gdb_gregset_t *gregsetp)
for (i = 0; i < sizeof (greg_map) / sizeof (greg_map[0]); i++, regp++)
{
int regno = greg_map[i];
- int size = register_size (current_gdbarch, regno);
- /* When running a 64 bit kernel, a greg_t may be larger than the
- actual register, so just pick off the LS bits of big-endian word. */
- supply_register (regno, ((char *) (regp + 1)) - size);
+ supply_register (regno, regp);
}
}
+/* Fill register regno (if it is a general-purpose register) in
+ *gregsetp with the appropriate value from GDB's register array.
+ If regno is -1, do this for all registers. */
+
void
fill_gregset (gdb_gregset_t *gregsetp, int regno)
{
int i;
- greg_t *regp = (greg_t *) gregsetp;
- memset (gregsetp, 0, sizeof (*gregsetp));
- for (i = 0; i < sizeof (greg_map) / sizeof (greg_map[0]); i++, regp++)
+ for (i = 0; i < sizeof (greg_map) / sizeof (greg_map[0]); i++)
{
- int regi = greg_map[i];
+ int mregno = greg_map[i];
- if (regno == -1 || regi == regno)
+ if (regno == -1 || regno == mregno)
{
- int rawsize = register_size (current_gdbarch, regi);
- regcache_collect (regi, ((char *) (regp + 1)) - rawsize);
+ regcache_collect(mregno, &(*gregsetp)[i]);
}
}
}
@@ -264,16 +357,13 @@ fill_fpregset (gdb_fpregset_t *fpregsetp
{
int i;
- for (i = 0; i < NUM_REGS; i++)
+ for (i = HPPA_FP0_REGNUM; i < HPPA_FP0_REGNUM + 32 * 2; i++)
{
- if (regno == -1 || regno == i)
- {
- /* Gross. fpregset_t is double, registers[x] has single
- precision reg. */
- char *to = (char *) &((*fpregsetp)[(i - HPPA_FP0_REGNUM) / 2]);
- if ((i - HPPA_FP0_REGNUM) & 1)
- to += 4;
- regcache_collect (i, to);
- }
+ /* Gross. fpregset_t is double, registers[x] has single
+ precision reg. */
+ char *to = (char *) &((*fpregsetp)[(i - HPPA_FP0_REGNUM) / 2]);
+ if ((i - HPPA_FP0_REGNUM) & 1)
+ to += 4;
+ regcache_collect (i, to);
}
}
Index: config/pa/nm-linux.h
===================================================================
RCS file: /cvs/src/src/gdb/config/pa/nm-linux.h,v
retrieving revision 1.1
diff -u -p -r1.1 nm-linux.h
--- config/pa/nm-linux.h 29 Apr 2004 03:36:50 -0000 1.1
+++ config/pa/nm-linux.h 8 May 2004 03:23:55 -0000
@@ -25,5 +25,8 @@
#define U_REGS_OFFSET 0
+/* Override copies of {fetch,store}_inferior_registers in `infptrace.c'. */
+#define FETCH_INFERIOR_REGISTERS
+
#endif
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-05-08 3:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-29 6:12 [patch] Fix a few bugs in hppa-linux-nat Randolph Chung
2004-05-04 15:05 ` Randolph Chung
2004-05-07 14:40 ` Andrew Cagney
2004-05-08 3:28 ` Randolph Chung
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox