* [rfc] [4/7] Modernize AIX target: inf-ptrace build fix
@ 2007-04-24 21:38 Ulrich Weigand
2007-04-25 0:16 ` Mark Kettenis
0 siblings, 1 reply; 5+ messages in thread
From: Ulrich Weigand @ 2007-04-24 21:38 UTC (permalink / raw)
To: gdb-patches
Hello,
this is another small build fix that is a pre-requisite for the
next patch (which adds inf-ptrace.c on AIX). The problem is that
on AIX, PTRACE_TYPE_ARG3 is a pointer, and trying to cast a
CORE_ADDR directly to it gives a compile warning.
The patch adds an intermediate cast to "long" to fix this problem;
there is precedent for this method in inf_ptrace_xfer_partial.
Tested on powerpc-aix-ibm5.3.0.0.
Bye,
Ulrich
ChangeLog:
* inf-ptrace.c (inf_ptrace_fetch_register): Add intermediate cast
to "long" before casting CORE_ADDR to PTRACE_TYPE_ARG3.
(inf_ptrace_store_register): Likewise.
diff -urNp gdb-orig/gdb/inf-ptrace.c gdb-head/gdb/inf-ptrace.c
--- gdb-orig/gdb/inf-ptrace.c Wed Apr 18 16:17:19 2007
+++ gdb-head/gdb/inf-ptrace.c Mon Apr 23 21:14:20 2007
@@ -642,7 +642,7 @@ inf_ptrace_fetch_register (int regnum)
for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
{
errno = 0;
- buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)addr, 0);
+ buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)(long)addr, 0);
if (errno != 0)
error (_("Couldn't read register %s (#%d): %s."),
REGISTER_NAME (regnum), regnum, safe_strerror (errno));
@@ -696,7 +696,7 @@ inf_ptrace_store_register (int regnum)
for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++)
{
errno = 0;
- ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)addr, buf[i]);
+ ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)(long)addr, buf[i]);
if (errno != 0)
error (_("Couldn't write register %s (#%d): %s."),
REGISTER_NAME (regnum), regnum, safe_strerror (errno));
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [rfc] [4/7] Modernize AIX target: inf-ptrace build fix 2007-04-24 21:38 [rfc] [4/7] Modernize AIX target: inf-ptrace build fix Ulrich Weigand @ 2007-04-25 0:16 ` Mark Kettenis 2007-04-25 1:25 ` Ulrich Weigand 0 siblings, 1 reply; 5+ messages in thread From: Mark Kettenis @ 2007-04-25 0:16 UTC (permalink / raw) To: uweigand; +Cc: gdb-patches > Date: Tue, 24 Apr 2007 23:37:24 +0200 (CEST) > From: "Ulrich Weigand" <uweigand@de.ibm.com> > > Hello, > > this is another small build fix that is a pre-requisite for the > next patch (which adds inf-ptrace.c on AIX). The problem is that > on AIX, PTRACE_TYPE_ARG3 is a pointer, and trying to cast a > CORE_ADDR directly to it gives a compile warning. > > The patch adds an intermediate cast to "long" to fix this problem; > there is precedent for this method in inf_ptrace_xfer_partial. I don't like this, but I guess this is unavoidable, I think it's more correct to use uintptr_t instead of long though. Mark ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc] [4/7] Modernize AIX target: inf-ptrace build fix 2007-04-25 0:16 ` Mark Kettenis @ 2007-04-25 1:25 ` Ulrich Weigand 2007-04-25 3:09 ` Daniel Jacobowitz 0 siblings, 1 reply; 5+ messages in thread From: Ulrich Weigand @ 2007-04-25 1:25 UTC (permalink / raw) To: Mark Kettenis; +Cc: gdb-patches Mark Kettenis wrote: > > Date: Tue, 24 Apr 2007 23:37:24 +0200 (CEST) > > From: "Ulrich Weigand" <uweigand@de.ibm.com> > > > > Hello, > > > > this is another small build fix that is a pre-requisite for the > > next patch (which adds inf-ptrace.c on AIX). The problem is that > > on AIX, PTRACE_TYPE_ARG3 is a pointer, and trying to cast a > > CORE_ADDR directly to it gives a compile warning. > > > > The patch adds an intermediate cast to "long" to fix this problem; > > there is precedent for this method in inf_ptrace_xfer_partial. > > I don't like this, but I guess this is unavoidable, I think it's more > correct to use uintptr_t instead of long though. I don't particularly like it either ... Can we assume every system where inf-ptrace.c is built has uintptr_t? I notice the type isn't frequently used elsewhere in GDB today. If we decide to use uintptr_t, I guess the existing uses of long in inf_ptrace_xfer_partial should be changed as well. Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc] [4/7] Modernize AIX target: inf-ptrace build fix 2007-04-25 1:25 ` Ulrich Weigand @ 2007-04-25 3:09 ` Daniel Jacobowitz 2007-04-26 0:15 ` Ulrich Weigand 0 siblings, 1 reply; 5+ messages in thread From: Daniel Jacobowitz @ 2007-04-25 3:09 UTC (permalink / raw) To: Ulrich Weigand; +Cc: Mark Kettenis, gdb-patches On Wed, Apr 25, 2007 at 02:26:26AM +0200, Ulrich Weigand wrote: > Can we assume every system where inf-ptrace.c is built has uintptr_t? > I notice the type isn't frequently used elsewhere in GDB today. You Can Now. Take a look at the generated gdb_stdint.h. -- Daniel Jacobowitz CodeSourcery ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfc] [4/7] Modernize AIX target: inf-ptrace build fix 2007-04-25 3:09 ` Daniel Jacobowitz @ 2007-04-26 0:15 ` Ulrich Weigand 0 siblings, 0 replies; 5+ messages in thread From: Ulrich Weigand @ 2007-04-26 0:15 UTC (permalink / raw) To: Daniel Jacobowitz; +Cc: Mark Kettenis, gdb-patches Daniel Jacobowitz wrote: > On Wed, Apr 25, 2007 at 02:26:26AM +0200, Ulrich Weigand wrote: > > Can we assume every system where inf-ptrace.c is built has uintptr_t? > > I notice the type isn't frequently used elsewhere in GDB today. > > You Can Now. Take a look at the generated gdb_stdint.h. Nice! I'll use the following modified patch then. Tested on powerpc-ibm-aix5.3.0.0. Bye, Ulrich ChangeLog: * inf-ptrace.c: Include "gdb_stdint.h". (inf_ptrace_xfer_partial): Use "uintptr_t" instead of "long" as intermediate type when casting CORE_ADDR to PTRACE_TYPE_ARG3. (inf_ptrace_fetch_register): Add intermediate cast to "uintptr_t" before casting CORE_ADDR to PTRACE_TYPE_ARG3. (inf_ptrace_store_register): Likewise. * Makefile.in (inf-ptrace.o): Update dependencies. diff -urNp gdb-orig/gdb/inf-ptrace.c gdb-head/gdb/inf-ptrace.c --- gdb-orig/gdb/inf-ptrace.c 2007-04-14 18:08:02.000000000 +0200 +++ gdb-head/gdb/inf-ptrace.c 2007-04-25 19:22:38.793800264 +0200 @@ -28,6 +28,7 @@ #include "gdbcore.h" #include "regcache.h" +#include "gdb_stdint.h" #include "gdb_assert.h" #include "gdb_string.h" #include "gdb_ptrace.h" @@ -504,7 +505,8 @@ inf_ptrace_xfer_partial (struct target_o < rounded_offset + sizeof (PTRACE_TYPE_RET))) /* Need part of initial word -- fetch it. */ buffer.word = ptrace (PT_READ_I, pid, - (PTRACE_TYPE_ARG3)(long)rounded_offset, 0); + (PTRACE_TYPE_ARG3)(uintptr_t) + rounded_offset, 0); /* Copy data to be written over corresponding part of buffer. */ @@ -513,14 +515,16 @@ inf_ptrace_xfer_partial (struct target_o errno = 0; ptrace (PT_WRITE_D, pid, - (PTRACE_TYPE_ARG3)(long)rounded_offset, buffer.word); + (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset, + buffer.word); if (errno) { /* Using the appropriate one (I or D) is necessary for Gould NP1, at least. */ errno = 0; ptrace (PT_WRITE_I, pid, - (PTRACE_TYPE_ARG3)(long)rounded_offset, buffer.word); + (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset, + buffer.word); if (errno) return 0; } @@ -530,7 +534,8 @@ inf_ptrace_xfer_partial (struct target_o { errno = 0; buffer.word = ptrace (PT_READ_I, pid, - (PTRACE_TYPE_ARG3)(long)rounded_offset, 0); + (PTRACE_TYPE_ARG3)(uintptr_t)rounded_offset, + 0); if (errno) return 0; /* Copy appropriate bytes out of the buffer. */ @@ -642,7 +647,7 @@ inf_ptrace_fetch_register (int regnum) for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++) { errno = 0; - buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)addr, 0); + buf[i] = ptrace (PT_READ_U, pid, (PTRACE_TYPE_ARG3)(uintptr_t)addr, 0); if (errno != 0) error (_("Couldn't read register %s (#%d): %s."), REGISTER_NAME (regnum), regnum, safe_strerror (errno)); @@ -696,7 +701,7 @@ inf_ptrace_store_register (int regnum) for (i = 0; i < size / sizeof (PTRACE_TYPE_RET); i++) { errno = 0; - ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)addr, buf[i]); + ptrace (PT_WRITE_U, pid, (PTRACE_TYPE_ARG3)(uintptr_t)addr, buf[i]); if (errno != 0) error (_("Couldn't write register %s (#%d): %s."), REGISTER_NAME (regnum), regnum, safe_strerror (errno)); diff -urNp gdb-orig/gdb/Makefile.in gdb-head/gdb/Makefile.in --- gdb-orig/gdb/Makefile.in 2007-04-25 19:30:42.240699372 +0200 +++ gdb-head/gdb/Makefile.in 2007-04-25 19:20:02.585131633 +0200 @@ -2170,7 +2170,7 @@ inflow.o: inflow.c $(defs_h) $(frame_h) $(serial_h) $(terminal_h) $(target_h) $(gdbthread_h) $(gdb_string_h) \ $(inflow_h) $(gdb_select_h) inf-ptrace.o: inf-ptrace.c $(defs_h) $(command_h) $(inferior_h) $(inflow_h) \ - $(gdbcore_h) $(regcache_h) $(gdb_assert_h) \ + $(gdbcore_h) $(regcache_h) $(gdb_stdint_h) $(gdb_assert_h) \ $(gdb_string_h) $(gdb_ptrace_h) $(gdb_wait_h) $(inf_child_h) infptrace.o: infptrace.c $(defs_h) $(command_h) $(frame_h) $(gdbcore_h) \ $(inferior_h) $(regcache_h) $(target_h) $(gdb_assert_h) \ -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2007-04-25 22:40 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2007-04-24 21:38 [rfc] [4/7] Modernize AIX target: inf-ptrace build fix Ulrich Weigand 2007-04-25 0:16 ` Mark Kettenis 2007-04-25 1:25 ` Ulrich Weigand 2007-04-25 3:09 ` Daniel Jacobowitz 2007-04-26 0:15 ` Ulrich Weigand
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox