Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH/RFC] gag some compiler warnings
@ 2003-07-03 16:42 Elena Zannoni
  2003-07-03 16:49 ` Richard Henderson
  2003-07-03 20:49 ` Mark Kettenis
  0 siblings, 2 replies; 4+ messages in thread
From: Elena Zannoni @ 2003-07-03 16:42 UTC (permalink / raw)
  To: gdb-patches


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;


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] gag some compiler warnings
  2003-07-03 16:42 [PATCH/RFC] gag some compiler warnings Elena Zannoni
@ 2003-07-03 16:49 ` Richard Henderson
  2003-07-03 20:49 ` Mark Kettenis
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2003-07-03 16:49 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

On Thu, Jul 03, 2003 at 12:49:22PM -0400, Elena Zannoni wrote:
> -			      (PTRACE_ARG3_TYPE) addr, 0);
> +			      (PTRACE_ARG3_TYPE) (long) addr, 0);

The Most Correct type is intptr_t, from <stdint.h>.  Except
that's a C99 thing, and doesn't exist everywhere.  You could
do something with configure...

Failing that, I think size_t is the best choice.


r~


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] gag some compiler warnings
  2003-07-03 16:42 [PATCH/RFC] gag some compiler warnings Elena Zannoni
  2003-07-03 16:49 ` Richard Henderson
@ 2003-07-03 20:49 ` Mark Kettenis
  2003-07-07 18:35   ` Elena Zannoni
  1 sibling, 1 reply; 4+ messages in thread
From: Mark Kettenis @ 2003-07-03 20:49 UTC (permalink / raw)
  To: Elena Zannoni; +Cc: gdb-patches

Elena Zannoni <ezannoni@redhat.com> writes:

> 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
> 
> 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.
>    * infptrace.c (child_xfer_memory): Cast ptrace argument to long,
>      for cases in which CORE_ADDR size and pointer size don't agree.

Hmm.  I don't think this is OK.  This could easily hide genuine
problems.  What system is this?  Or perhaps a better question: what is
the prototype of ptrace() in 32-bit mode on this system, and what is
your definition of PTRACE_ARG3_TYPE on this system?

Mark


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH/RFC] gag some compiler warnings
  2003-07-03 20:49 ` Mark Kettenis
@ 2003-07-07 18:35   ` Elena Zannoni
  0 siblings, 0 replies; 4+ messages in thread
From: Elena Zannoni @ 2003-07-07 18:35 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: Elena Zannoni, gdb-patches

Mark Kettenis writes:
 > Elena Zannoni <ezannoni@redhat.com> writes:
 > 
 > > 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
 > > 
 > > 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.
 > >    * infptrace.c (child_xfer_memory): Cast ptrace argument to long,
 > >      for cases in which CORE_ADDR size and pointer size don't agree.
 > 
 > Hmm.  I don't think this is OK.  This could easily hide genuine
 > problems.  What system is this?  Or perhaps a better question: what is
 > the prototype of ptrace() in 32-bit mode on this system, and what is
 > your definition of PTRACE_ARG3_TYPE on this system?
 > 
 > Mark

This is a ppc64 system. But I think I have some local screw ups in the
way the machine is set up.  PTRACE_ARG3_TYPE is void * (4 bytes) from
config/powerpc/nm-ppc64-linux.h while CORE_ADDR is 8 bytes.

Ignore this patch until I figure out what is really going on.

elena


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-07-07 18:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-03 16:42 [PATCH/RFC] gag some compiler warnings Elena Zannoni
2003-07-03 16:49 ` Richard Henderson
2003-07-03 20:49 ` Mark Kettenis
2003-07-07 18:35   ` Elena Zannoni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox