This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [patch] Fix a few bugs in hppa-linux-nat
- From: Andrew Cagney <cagney at gnu dot org>
- To: Randolph Chung <randolph at tausq dot org>
- Cc: gdb-patches at sources dot redhat dot com
- Date: Fri, 07 May 2004 10:40:16 -0400
- Subject: Re: [patch] Fix a few bugs in hppa-linux-nat
- References: <20040429061207.GW3965@tausq.org>
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