This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH/RFC] gag some compiler warnings


I am seeing these on a 64 bit system, when building gdb in 32-bit mode:

/home/cygnus/ezannoni/gdb-6/src/gdb/infptrace.c: In function `child_xfer_memory':
/home/cygnus/ezannoni/gdb-6/src/gdb/infptrace.c:570: warning: cast to pointer from integer of different size
/home/cygnus/ezannoni/gdb-6/src/gdb/infptrace.c:578: warning: cast to pointer from integer of different size
/home/cygnus/ezannoni/gdb-6/src/gdb/infptrace.c:590: warning: cast to pointer from integer of different size
/home/cygnus/ezannoni/gdb-6/src/gdb/infptrace.c:597: warning: cast to pointer from integer of different size
/home/cygnus/ezannoni/gdb-6/src/gdb/infptrace.c:613: warning: cast to pointer from integer of different size

The problem is that we pass a CORE_ADDR (which is 8 bytes long) to
ptrace and we cast it to PTRACE_ARG3_TYPE (which is 4 bytes long).

Is this ok? Not too pretty, I know.


elena

   * infptrace.c (child_xfer_memory): Cast ptrace argument to long,
     for cases in which CORE_ADDR size and pointer size don't agree.

Index: infptrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infptrace.c,v
retrieving revision 1.26
diff -u -p -r1.26 infptrace.c
--- infptrace.c	22 May 2003 15:46:20 -0000	1.26
+++ infptrace.c	3 Jul 2003 15:45:34 -0000
@@ -564,14 +564,14 @@ child_xfer_memory (CORE_ADDR memaddr, ch
 	{
 	  /* Need part of initial word -- fetch it.  */
 	  buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_ptid), 
-			      (PTRACE_ARG3_TYPE) addr, 0);
+			      (PTRACE_ARG3_TYPE) (long) addr, 0);
 	}
 
       if (count > 1)		/* FIXME, avoid if even boundary.  */
 	{
 	  buffer[count - 1] =
 	    ptrace (PT_READ_I, PIDGET (inferior_ptid),
-		    ((PTRACE_ARG3_TYPE)
+		    ((PTRACE_ARG3_TYPE) (long)
 		     (addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))), 0);
 	}
 
@@ -584,14 +584,14 @@ child_xfer_memory (CORE_ADDR memaddr, ch
 	{
 	  errno = 0;
 	  ptrace (PT_WRITE_D, PIDGET (inferior_ptid), 
-		  (PTRACE_ARG3_TYPE) addr, buffer[i]);
+		  (PTRACE_ARG3_TYPE) (long) addr, buffer[i]);
 	  if (errno)
 	    {
 	      /* Using the appropriate one (I or D) is necessary for
 	         Gould NP1, at least.  */
 	      errno = 0;
 	      ptrace (PT_WRITE_I, PIDGET (inferior_ptid), 
-		      (PTRACE_ARG3_TYPE) addr, buffer[i]);
+		      (PTRACE_ARG3_TYPE) (long) addr, buffer[i]);
 	    }
 	  if (errno)
 	    return 0;
@@ -607,7 +607,7 @@ child_xfer_memory (CORE_ADDR memaddr, ch
 	{
 	  errno = 0;
 	  buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_ptid),
-			      (PTRACE_ARG3_TYPE) addr, 0);
+			      (PTRACE_ARG3_TYPE) (long) addr, 0);
 	  if (errno)
 	    return 0;
 	  QUIT;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]