This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH] Use PTRACE_ARG3_TYPE consistently in linux-low.c
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 5 Feb 2002 14:05:32 -0500
- Subject: [PATCH] Use PTRACE_ARG3_TYPE consistently in linux-low.c
If we have a 64-bit CORE_ADDR, and we try to use it as an argument to
(variadic) ptrace, the argument passing gets all messed up. We need to cast
it back to the type ptrace expects. We were doing this some, but not all,
of the time.
Committed, linux-low.c only since low-linux.c will shortly be dead.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
2002-02-05 Daniel Jacobowitz <drow@mvista.com>
* gdbserver/linux-low.c: Define PTRACE_ARG3_TYPE.
(read_inferior_memory): Use it.
(write_inferior_memory): Likewise.
Index: linux-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v
retrieving revision 1.2
diff -u -p -r1.2 linux-low.c
--- linux-low.c 2002/02/05 18:49:55 1.2
+++ linux-low.c 2002/02/05 19:02:35
@@ -43,10 +43,8 @@ char *registers = my_registers;
#include <sys/reg.h>
#endif
-/* Default the type of the ptrace transfer to int. */
-#ifndef PTRACE_XFER_TYPE
+#define PTRACE_ARG3_TYPE long
#define PTRACE_XFER_TYPE int
-#endif
extern int errno;
@@ -718,7 +716,7 @@ read_inferior_memory (CORE_ADDR memaddr,
/* Read all the longwords */
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
- buffer[i] = ptrace (PTRACE_PEEKTEXT, inferior_pid, addr, 0);
+ buffer[i] = ptrace (PTRACE_PEEKTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
}
/* Copy appropriate bytes out of the buffer. */
@@ -745,13 +743,16 @@ write_inferior_memory (CORE_ADDR memaddr
/* Fill start and end extra bytes of buffer with existing memory data. */
- buffer[0] = ptrace (PTRACE_PEEKTEXT, inferior_pid, addr, 0);
+ buffer[0] = ptrace (PTRACE_PEEKTEXT, inferior_pid,
+ (PTRACE_ARG3_TYPE) addr, 0);
if (count > 1)
{
buffer[count - 1]
= ptrace (PTRACE_PEEKTEXT, inferior_pid,
- addr + (count - 1) * sizeof (PTRACE_XFER_TYPE), 0);
+ (PTRACE_ARG3_TYPE) (addr + (count - 1)
+ * sizeof (PTRACE_XFER_TYPE)),
+ 0);
}
/* Copy data to be written over corresponding part of buffer */
@@ -763,7 +764,7 @@ write_inferior_memory (CORE_ADDR memaddr
for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
- ptrace (PTRACE_POKETEXT, inferior_pid, addr, buffer[i]);
+ ptrace (PTRACE_POKETEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, buffer[i]);
if (errno)
return errno;
}