* [patch] Can't build ppc32 GDB
@ 2006-04-25 0:18 PAUL GILLIAM
2006-04-25 0:22 ` PAUL GILLIAM
0 siblings, 1 reply; 13+ messages in thread
From: PAUL GILLIAM @ 2006-04-25 0:18 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1272 bytes --]
I don't know if all ppc systems have this problem. But on a PowerPC-64
system, I get the following when I try to build a 32-bit gdb:
gcc -c -g -O2 -mminimal-toc -I. -I.././gdb -I.././gdb/config
-DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
-I.././gdb/../include/opcode -I.././gdb/../readline/.. -I../bfd
-I.././gdb/../bfd -I.././gdb/../include -I../intl -I.././gdb/../intl
-DMI_OUT=1 -DTUI=1 -Wimplicit -Wreturn-type -Wcomment -Wtrigraphs
-Wformat -Wparentheses -Wpointer-arith -Wformat-nonliteral
-Wunused-label -Wunused-function -Wno-pointer-sign -Wuninitialized
-Werror ppc-linux-nat.c
cc1: warnings being treated as errors
ppc-linux-nat.c: In function âfetch_registerâ:
ppc-linux-nat.c:396: warning: cast to pointer from integer of different
size
ppc-linux-nat.c: In function âstore_registerâ:
ppc-linux-nat.c:691: warning: cast to pointer from integer of different
size
ppc-linux-nat.c: In function âppc_linux_stopped_by_watchpointâ:
ppc-linux-nat.c:904: warning: cast from pointer to integer of different
size
make: *** [ppc-linux-nat.o] Error 1
So as a starting point, I have attached a patch that gets rid of the
warnings.
OK to commit? (not expecting a 'yes', but you never know unless you ask
8-)
-=# Paul #=-
[-- Attachment #2: Type: text/x-patch, Size: 2352 bytes --]
? .NEWS.annotate.swp
? .gdbinit
? Makefile
? ada-exp.c
? ada-lex.c
? c-exp.c
? chit.diff
? config.cache
? config.h
? config.log
? config.status
? cp-name-parser.c
? f-exp.c
? gdb
? gdbtui
? hope.patch
? init.c
? jv-exp.c
? m2-exp.c
? maintainers.patch
? objc-exp.c
? observer.h
? observer.inc
? p-exp.c
? stamp-h
? tweek.patch
? version.c
? doc/Makefile
? doc/config.log
? doc/config.status
? gdbserver/Makefile
? gdbserver/config.h
? gdbserver/config.log
? gdbserver/config.status
? gdbserver/gdbreplay
? gdbserver/gdbserver
? gdbserver/reg-ppc64.c
? gdbserver/stamp-h
? gdbserver/version.c
? testsuite/Makefile
? testsuite/config.log
? testsuite/config.status
? testsuite/gdb.ada/Makefile
? testsuite/gdb.arch/Makefile
? testsuite/gdb.asm/Makefile
? testsuite/gdb.base/Makefile
? testsuite/gdb.cp/Makefile
? testsuite/gdb.disasm/Makefile
? testsuite/gdb.dwarf2/Makefile
? testsuite/gdb.fortran/Makefile
? testsuite/gdb.java/Makefile
? testsuite/gdb.mi/Makefile
? testsuite/gdb.objc/Makefile
? testsuite/gdb.server/Makefile
? testsuite/gdb.stabs/Makefile
? testsuite/gdb.stabs/config.log
? testsuite/gdb.stabs/config.status
? testsuite/gdb.threads/Makefile
? testsuite/gdb.trace/Makefile
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.60
diff -a -u -r1.60 ppc-linux-nat.c
--- ppc-linux-nat.c 24 Mar 2006 23:08:16 -0000 1.60
+++ ppc-linux-nat.c 25 Apr 2006 00:10:12 -0000
@@ -393,7 +393,7 @@
{
errno = 0;
*(PTRACE_XFER_TYPE *) & buf[bytes_transferred]
- = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) regaddr, 0);
+ = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) (long) regaddr, 0);
regaddr += sizeof (PTRACE_XFER_TYPE);
if (errno != 0)
{
@@ -688,7 +688,7 @@
for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
- ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
+ ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) (long) regaddr,
*(PTRACE_XFER_TYPE *) & buf[i]);
regaddr += sizeof (PTRACE_XFER_TYPE);
@@ -901,7 +901,7 @@
(siginfo.si_code & 0xffff) != 0x0004)
return 0;
- last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
+ last_stopped_data_address = (CORE_ADDR) (long) siginfo.si_addr;
return 1;
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-04-25 0:18 [patch] Can't build ppc32 GDB PAUL GILLIAM
@ 2006-04-25 0:22 ` PAUL GILLIAM
2006-04-25 19:38 ` Mark Kettenis
0 siblings, 1 reply; 13+ messages in thread
From: PAUL GILLIAM @ 2006-04-25 0:22 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1486 bytes --]
Darn! I forgot to 'trim' the patch'.
I have attached the 'trimmed' version.
-=# Paul #=-
On Mon, 2006-04-24 at 17:18 -0700, PAUL GILLIAM wrote:
> I don't know if all ppc systems have this problem. But on a PowerPC-64
> system, I get the following when I try to build a 32-bit gdb:
>
> gcc -c -g -O2 -mminimal-toc -I. -I.././gdb -I.././gdb/config
> -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
> -I.././gdb/../include/opcode -I.././gdb/../readline/.. -I../bfd
> -I.././gdb/../bfd -I.././gdb/../include -I../intl -I.././gdb/../intl
> -DMI_OUT=1 -DTUI=1 -Wimplicit -Wreturn-type -Wcomment -Wtrigraphs
> -Wformat -Wparentheses -Wpointer-arith -Wformat-nonliteral
> -Wunused-label -Wunused-function -Wno-pointer-sign -Wuninitialized
> -Werror ppc-linux-nat.c
> cc1: warnings being treated as errors
> ppc-linux-nat.c: In function âfetch_registerâ:
> ppc-linux-nat.c:396: warning: cast to pointer from integer of different
> size
> ppc-linux-nat.c: In function âstore_registerâ:
> ppc-linux-nat.c:691: warning: cast to pointer from integer of different
> size
> ppc-linux-nat.c: In function âppc_linux_stopped_by_watchpointâ:
> ppc-linux-nat.c:904: warning: cast from pointer to integer of different
> size
> make: *** [ppc-linux-nat.o] Error 1
>
>
> So as a starting point, I have attached a patch that gets rid of the
> warnings.
>
> OK to commit? (not expecting a 'yes', but you never know unless you ask
> 8-)
>
> -=# Paul #=-
>
>
[-- Attachment #2: cast.diff --]
[-- Type: text/x-patch, Size: 1163 bytes --]
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.60
diff -a -u -r1.60 ppc-linux-nat.c
--- ppc-linux-nat.c 24 Mar 2006 23:08:16 -0000 1.60
+++ ppc-linux-nat.c 25 Apr 2006 00:10:12 -0000
@@ -393,7 +393,7 @@
{
errno = 0;
*(PTRACE_XFER_TYPE *) & buf[bytes_transferred]
- = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) regaddr, 0);
+ = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) (long) regaddr, 0);
regaddr += sizeof (PTRACE_XFER_TYPE);
if (errno != 0)
{
@@ -688,7 +688,7 @@
for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_XFER_TYPE))
{
errno = 0;
- ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
+ ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) (long) regaddr,
*(PTRACE_XFER_TYPE *) & buf[i]);
regaddr += sizeof (PTRACE_XFER_TYPE);
@@ -901,7 +901,7 @@
(siginfo.si_code & 0xffff) != 0x0004)
return 0;
- last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
+ last_stopped_data_address = (CORE_ADDR) (long) siginfo.si_addr;
return 1;
}
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-04-25 0:22 ` PAUL GILLIAM
@ 2006-04-25 19:38 ` Mark Kettenis
2006-05-03 23:32 ` PAUL GILLIAM
0 siblings, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2006-04-25 19:38 UTC (permalink / raw)
To: pgilliam; +Cc: gdb-patches
> From: PAUL GILLIAM <pgilliam@us.ibm.com>
> Date: Mon, 24 Apr 2006 17:23:13 -0700
>
> Darn! I forgot to 'trim' the patch'.
>
> I have attached the 'trimmed' version.
Get rid of the PTRACE_XFER_TYPE and PTRACE_ARG3_TYPE. Replace them
with PTRACE_TYPE_RET and PTRACE_TYPE_ARG3. Or better yet, if the
prototype for ptrace(2) is consistent for all powerpc Linux variants,
simply replace them with the proper type (which is probably "long").
Oh and while you're there, get rid of PT_READ_U/PT_WRITE_U in favour
of PTRACE_PEEKUSR/PTRACE_POKEUSR.
Mark
> On Mon, 2006-04-24 at 17:18 -0700, PAUL GILLIAM wrote:
> > I don't know if all ppc systems have this problem. But on a PowerPC-64
> > system, I get the following when I try to build a 32-bit gdb:
> >
> > gcc -c -g -O2 -mminimal-toc -I. -I.././gdb -I.././gdb/config
> > -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H
> > -I.././gdb/../include/opcode -I.././gdb/../readline/.. -I../bfd
> > -I.././gdb/../bfd -I.././gdb/../include -I../intl -I.././gdb/../intl
> > -DMI_OUT=1 -DTUI=1 -Wimplicit -Wreturn-type -Wcomment -Wtrigraphs
> > -Wformat -Wparentheses -Wpointer-arith -Wformat-nonliteral
> > -Wunused-label -Wunused-function -Wno-pointer-sign -Wuninitialized
> > -Werror ppc-linux-nat.c
> > cc1: warnings being treated as errors
> > ppc-linux-nat.c: In function âfetch_registerâ:
> > ppc-linux-nat.c:396: warning: cast to pointer from integer of different
> > size
> > ppc-linux-nat.c: In function âstore_registerâ:
> > ppc-linux-nat.c:691: warning: cast to pointer from integer of different
> > size
> > ppc-linux-nat.c: In function âppc_linux_stopped_by_watchpointâ:
> > ppc-linux-nat.c:904: warning: cast from pointer to integer of different
> > size
> > make: *** [ppc-linux-nat.o] Error 1
> >
> >
> > So as a starting point, I have attached a patch that gets rid of the
> > warnings.
> >
> > OK to commit? (not expecting a 'yes', but you never know unless you ask
> > 8-)
> >
> > -=# Paul #=-
> >
> >
>
> --=-vPdNruxeVr+2Uj34B6nP
> Content-Disposition: attachment; filename=cast.diff
> Content-Type: text/x-patch; name=cast.diff; charset=utf-8
> Content-Transfer-Encoding: 7bit
>
> Index: ppc-linux-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
> retrieving revision 1.60
> diff -a -u -r1.60 ppc-linux-nat.c
> --- ppc-linux-nat.c 24 Mar 2006 23:08:16 -0000 1.60
> +++ ppc-linux-nat.c 25 Apr 2006 00:10:12 -0000
> @@ -393,7 +393,7 @@
> {
> errno = 0;
> *(PTRACE_XFER_TYPE *) & buf[bytes_transferred]
> - = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) regaddr, 0);
> + = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) (long) regaddr, 0);
> regaddr += sizeof (PTRACE_XFER_TYPE);
> if (errno != 0)
> {
> @@ -688,7 +688,7 @@
> for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_XFER_TYPE))
> {
> errno = 0;
> - ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
> + ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) (long) regaddr,
> *(PTRACE_XFER_TYPE *) & buf[i]);
> regaddr += sizeof (PTRACE_XFER_TYPE);
>
> @@ -901,7 +901,7 @@
> (siginfo.si_code & 0xffff) != 0x0004)
> return 0;
>
> - last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
> + last_stopped_data_address = (CORE_ADDR) (long) siginfo.si_addr;
> return 1;
> }
>
>
> --=-vPdNruxeVr+2Uj34B6nP--
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-04-25 19:38 ` Mark Kettenis
@ 2006-05-03 23:32 ` PAUL GILLIAM
2006-05-04 7:12 ` Mark Kettenis
0 siblings, 1 reply; 13+ messages in thread
From: PAUL GILLIAM @ 2006-05-03 23:32 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 2329 bytes --]
Sorry if this is a dup, I seem to be having mailer problems...
On Tue, 2006-04-25 at 21:38 +0200, Mark Kettenis wrote:
> > From: PAUL GILLIAM <pgilliam@us.ibm.com>
> > Date: Mon, 24 Apr 2006 17:23:13 -0700
> >
> > Darn! I forgot to 'trim' the patch'.
> >
> > I have attached the 'trimmed' version.
>
> Get rid of the PTRACE_XFER_TYPE and PTRACE_ARG3_TYPE. Replace them
> with PTRACE_TYPE_RET and PTRACE_TYPE_ARG3. Or better yet, if the
> prototype for ptrace(2) is consistent for all powerpc Linux variants,
> simply replace them with the proper type (which is probably "long").
>
> Oh and while you're there, get rid of PT_READ_U/PT_WRITE_U in favour
> of PTRACE_PEEKUSR/PTRACE_POKEUSR.
>
> Mark
>
Changeing the PTRACE_... stuff had kind of a wrinkle (see below)
but the big problem is with this line in ppc_linux_nat.c:
last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
in subroutine ppc_linux_stopped_by_watchpoint()
A 'CORE_ADDR' is a 'bfd_vma' and on ppc64 systems, a 'bfd_vma' is an
'unsigned long long'. If gdb is built on such a system with CC='gcc
-m64', an 'unsigned long long' is 64 bits as are an 'unsigned long' and
a 'void *'. No problem.
But if CC is just 'gcc', then an 'unsigned long long' is still 64 bits,
but an 'unsigned long' and a 'void *' are 32 bits.
Changing the line to:
last_stopped_data_address = (CORE_ADDR) (unsigned long)
siginfo.si_addr;
Fixes the problem because the extra cast does nothing when CC='gcc -m64'
but when CC='gcc', siginfo.si_addr is cast from a 'void *' to an integer
of the same size, which is then cast to an integer of a larger size,
avoiding the warning.
I have attached the new patch, OK to commit?
-=# Paul #=-
PS:
Here is the wrinkle
On a ppc64 system:
This is from /usr/include/sys/ptrace.h:
extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
So I think PTRACE_TYPE_RET should default to 'long' in ppc_linux_nat.c
Also from /usr/include/sys/ptrace.h:
enum __ptrace_request
{
...
/* Return the word in the process's user area at offset ADDR. */
PTRACE_PEEKUSER = 3,
#define PT_READ_U PTRACE_PEEKUSER
...
/* Write the word DATA into the process's user area at offset ADDR.
*/
PTRACE_POKEUSER = 6,
#define PT_WRITE_U PTRACE_POKEUSER
...
Even though the man pages says PTRACE_PEEKUSR and PTRACE_POKEUSR
[-- Attachment #2: ppc-linux-nat.diff --]
[-- Type: text/x-patch, Size: 4980 bytes --]
2006-04-26: Paul Gilliam <pgilliam@us.ibm.com>
* ppc-linux-nat.c: Clean up types for ptrace.
Insert an 'extra' cast to account for the size difference between
a CORE_ADDR and a void* on ppc64 systems compiled for 32-bits.
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.60
diff -a -u -r1.60 ppc-linux-nat.c
--- ppc-linux-nat.c 24 Mar 2006 23:08:16 -0000 1.60
+++ ppc-linux-nat.c 27 Apr 2006 01:35:37 -0000
@@ -44,16 +44,16 @@
#include "gregset.h"
#include "ppc-tdep.h"
-#ifndef PT_READ_U
-#define PT_READ_U PTRACE_PEEKUSR
+#ifndef PTRACE_PEEKUSR
+#define PTRACE_PEEKUSR PTRACE_PEEKUSER
#endif
-#ifndef PT_WRITE_U
-#define PT_WRITE_U PTRACE_POKEUSR
+#ifndef PTRACE_POKEUSR
+#define PTRACE_POKEUSR PTRACE_POKEUSER
#endif
-/* Default the type of the ptrace transfer to int. */
-#ifndef PTRACE_XFER_TYPE
-#define PTRACE_XFER_TYPE int
+/* Default the type of the ptrace transfer to long. */
+#ifndef PTRACE_TYPE_RET
+#define PTRACE_TYPE_RET long
#endif
/* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a
@@ -190,7 +190,7 @@
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (PTRACE_TYPE_RET);
/* General purpose registers occupy 1 slot each in the buffer */
if (regno >= tdep->ppc_gp0_regnum
@@ -384,17 +384,17 @@
return;
}
- /* Read the raw register using PTRACE_XFER_TYPE sized chunks. On a
+ /* Read the raw register using PTRACE_TYPE_RET sized chunks. On a
32-bit platform, 64-bit floating-point registers will require two
transfers. */
for (bytes_transferred = 0;
bytes_transferred < register_size (current_gdbarch, regno);
- bytes_transferred += sizeof (PTRACE_XFER_TYPE))
+ bytes_transferred += sizeof (PTRACE_TYPE_RET))
{
errno = 0;
- *(PTRACE_XFER_TYPE *) & buf[bytes_transferred]
- = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) regaddr, 0);
- regaddr += sizeof (PTRACE_XFER_TYPE);
+ *(PTRACE_TYPE_RET *) & buf[bytes_transferred]
+ = ptrace (PTRACE_PEEKUSR, tid, (PTRACE_TYPE_ARG3) regaddr, 0);
+ regaddr += sizeof (PTRACE_TYPE_RET);
if (errno != 0)
{
char message[128];
@@ -406,7 +406,7 @@
/* Now supply the register. Keep in mind that the regcache's idea
of the register's size may not be a multiple of sizeof
- (PTRACE_XFER_TYPE). */
+ (PTRACE_TYPE_RET). */
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
{
/* Little-endian values are always found at the left end of the
@@ -668,10 +668,10 @@
/* First collect the register. Keep in mind that the regcache's
idea of the register's size may not be a multiple of sizeof
- (PTRACE_XFER_TYPE). */
+ (PTRACE_TYPE_RET). */
memset (buf, 0, sizeof buf);
bytes_to_transfer = align_up (register_size (current_gdbarch, regno),
- sizeof (PTRACE_XFER_TYPE));
+ sizeof (PTRACE_TYPE_RET));
if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
/* Little-endian values always sit at the left end of the buffer. */
@@ -685,12 +685,12 @@
regcache_raw_collect (current_regcache, regno, buf + padding);
}
- for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_XFER_TYPE))
+ for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_TYPE_RET))
{
errno = 0;
- ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
- *(PTRACE_XFER_TYPE *) & buf[i]);
- regaddr += sizeof (PTRACE_XFER_TYPE);
+ ptrace (PTRACE_POKEUSR, tid, (PTRACE_TYPE_ARG3) regaddr,
+ *(PTRACE_TYPE_RET *) & buf[i]);
+ regaddr += sizeof (PTRACE_TYPE_RET);
if (errno == EIO
&& regno == tdep->ppc_fpscr_regnum)
@@ -901,7 +901,7 @@
(siginfo.si_code & 0xffff) != 0x0004)
return 0;
- last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
+ last_stopped_data_address = (CORE_ADDR) (unsigned long) siginfo.si_addr;
return 1;
}
@@ -926,7 +926,7 @@
{
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (PTRACE_TYPE_RET);
ppc_linux_supply_gregset (current_regcache, -1, gregsetp,
sizeof (gdb_gregset_t), wordsize);
}
@@ -936,7 +936,7 @@
{
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (PTRACE_TYPE_RET);
/* Right fill the register. */
regcache_raw_collect (current_regcache, regnum,
((bfd_byte *) reg
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-03 23:32 ` PAUL GILLIAM
@ 2006-05-04 7:12 ` Mark Kettenis
2006-05-05 16:30 ` Daniel Jacobowitz
0 siblings, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2006-05-04 7:12 UTC (permalink / raw)
To: pgilliam; +Cc: gdb-patches
> Sorry if this is a dup, I seem to be having mailer problems...
I sort of remember seeing your reply before, but I can't find it in my
mailbox. So the dup was very welcome :).
> On Tue, 2006-04-25 at 21:38 +0200, Mark Kettenis wrote:
> > > From: PAUL GILLIAM <pgilliam@us.ibm.com>
> > > Date: Mon, 24 Apr 2006 17:23:13 -0700
> > >
> > > Darn! I forgot to 'trim' the patch'.
> > >
> > > I have attached the 'trimmed' version.
> >
> > Get rid of the PTRACE_XFER_TYPE and PTRACE_ARG3_TYPE. Replace them
> > with PTRACE_TYPE_RET and PTRACE_TYPE_ARG3. Or better yet, if the
> > prototype for ptrace(2) is consistent for all powerpc Linux variants,
> > simply replace them with the proper type (which is probably "long").
> >
> > Oh and while you're there, get rid of PT_READ_U/PT_WRITE_U in favour
> > of PTRACE_PEEKUSR/PTRACE_POKEUSR.
> >
> > Mark
> >
> Changeing the PTRACE_... stuff had kind of a wrinkle (see below)
> but the big problem is with this line in ppc_linux_nat.c:
>
> last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
>
> in subroutine ppc_linux_stopped_by_watchpoint()
>
> A 'CORE_ADDR' is a 'bfd_vma' and on ppc64 systems, a 'bfd_vma' is an
> 'unsigned long long'. If gdb is built on such a system with CC='gcc
> -m64', an 'unsigned long long' is 64 bits as are an 'unsigned long' and
> a 'void *'. No problem.
>
> But if CC is just 'gcc', then an 'unsigned long long' is still 64 bits,
> but an 'unsigned long' and a 'void *' are 32 bits.
>
> Changing the line to:
> last_stopped_data_address = (CORE_ADDR) (unsigned long)
> siginfo.si_addr;
>
> Fixes the problem because the extra cast does nothing when CC='gcc -m64'
> but when CC='gcc', siginfo.si_addr is cast from a 'void *' to an integer
> of the same size, which is then cast to an integer of a larger size,
> avoiding the warning.
This is where the new ISO C99 <stdint.h> types come in handy. Instead of
casting to CORE_ADDR, try casting to uintptr_t.
> I have attached the new patch, OK to commit?
>
> -=# Paul #=-
>
> PS:
>
> Here is the wrinkle
>
> On a ppc64 system:
>
> This is from /usr/include/sys/ptrace.h:
> extern long int ptrace (enum __ptrace_request __request, ...) __THROW;
>
> So I think PTRACE_TYPE_RET should default to 'long' in ppc_linux_nat.c
I really think you should get rid of the PTRACE_RET_TYPE and
PTRACE_XFER_TYPE nonsense in ppc-linux-nat.c. Just use long because
that's
what they will be defined to on Linux. The #define's only make the code
harder to read I think.
> Also from /usr/include/sys/ptrace.h:
> enum __ptrace_request
> {
> ...
> /* Return the word in the process's user area at offset ADDR. */
> PTRACE_PEEKUSER = 3,
> #define PT_READ_U PTRACE_PEEKUSER
> ...
> /* Write the word DATA into the process's user area at offset ADDR.
> */
> PTRACE_POKEUSER = 6,
> #define PT_WRITE_U PTRACE_POKEUSER
> ...
>
> Even though the man pages says PTRACE_PEEKUSR and PTRACE_POKEUSR
Think someone got fooled by the man page then. PTRACE_PEEKUSER/POKEUSER
are also used by the i386 and hppa code. So use those instead of
PT_READ_U/PTRACE_PEEKUSR, and get rid of the #ifdef maze. Well, it's
not really a maze, but it's all useless unless you're compiling on a Linux
system that predates glibc 2. And I don't think the current GDB will
run on such a system (if there ever were pre-glibc 2 ppc systems).
Cheers,
Mark
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-04 7:12 ` Mark Kettenis
@ 2006-05-05 16:30 ` Daniel Jacobowitz
2006-05-05 16:50 ` Mark Kettenis
0 siblings, 1 reply; 13+ messages in thread
From: Daniel Jacobowitz @ 2006-05-05 16:30 UTC (permalink / raw)
To: Mark Kettenis; +Cc: pgilliam, gdb-patches
On Thu, May 04, 2006 at 09:12:14AM +0200, Mark Kettenis wrote:
> This is where the new ISO C99 <stdint.h> types come in handy. Instead of
> casting to CORE_ADDR, try casting to uintptr_t.
Can we rely on <stdint.h> on GNU/Linux? I know we can't in general.
Conveniently, I have a patch on one of my pending branches that
provides a gdb_stdint.h.
But for this case there's an easier solution, which IIRC is roughly
what Paul did: I can pretty much promise you that sizeof (long) ==
sizeof (void *) on any GNU/Linux system. So either I can merge
gdb_stdint.h and we can start using that, which might be a nice idea in
general, or for now I think "long" is fine.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-05 16:30 ` Daniel Jacobowitz
@ 2006-05-05 16:50 ` Mark Kettenis
2006-05-05 18:31 ` PAUL GILLIAM
0 siblings, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2006-05-05 16:50 UTC (permalink / raw)
To: drow; +Cc: pgilliam, gdb-patches
> Date: Fri, 5 May 2006 12:29:55 -0400
> From: Daniel Jacobowitz <drow@false.org>
>
> On Thu, May 04, 2006 at 09:12:14AM +0200, Mark Kettenis wrote:
> > This is where the new ISO C99 <stdint.h> types come in handy. Instead of
> > casting to CORE_ADDR, try casting to uintptr_t.
>
> Can we rely on <stdint.h> on GNU/Linux? I know we can't in general.
> Conveniently, I have a patch on one of my pending branches that
> provides a gdb_stdint.h.
Having a gdb_stdint.h would be cool ;-).
> But for this case there's an easier solution, which IIRC is roughly
> what Paul did: I can pretty much promise you that sizeof (long) ==
> sizeof (void *) on any GNU/Linux system. So either I can merge
> gdb_stdint.h and we can start using that, which might be a nice idea in
> general, or for now I think "long" is fine.
Well, we already use uintptr_t in linux-thread-db.c, and
gdb_thread_db.h errors out if it isn't available (and has been doing
so for ages). So we can be pretty sure that nobody is trying to
compile on systems with libc5 or really old glibc versions.
That said, it is probably safe to assume that all (powerpc) Linux
ports are either ILP32 or LP64, so casting to (unsigned long) should
be perfectly safe. It's just that I think that a uintptr_t cast
better expresses what's happening here. But either way is fine with
me.
Mark
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-05 16:50 ` Mark Kettenis
@ 2006-05-05 18:31 ` PAUL GILLIAM
2006-05-05 19:55 ` Mark Kettenis
0 siblings, 1 reply; 13+ messages in thread
From: PAUL GILLIAM @ 2006-05-05 18:31 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1906 bytes --]
OK, How about this? I tried to make everyone happy :-)
Here is an excerpt:
#ifdef HAVE_STDINT_H
#include <stdint.h>
#define CORE_ADDR_CAST (uintptr_t)
#else
#define CORE_ADDR_CAST (CORE_ADDR)(unsigned long)
#endif
. . .
last_stopped_data_address = CORE_ADDR_CAST siginfo.si_addr;
Then when there is a gdb_stdint.h, I'll submit another patch to include
it and replace CORE_ADDR_CAST with just (uintptr_t).
Ok to commit?
-=# Paul #=-
On Fri, 2006-05-05 at 18:49 +0200, Mark Kettenis wrote:
> > Date: Fri, 5 May 2006 12:29:55 -0400
> > From: Daniel Jacobowitz <drow@false.org>
> >
> > On Thu, May 04, 2006 at 09:12:14AM +0200, Mark Kettenis wrote:
> > > This is where the new ISO C99 <stdint.h> types come in handy. Instead of
> > > casting to CORE_ADDR, try casting to uintptr_t.
> >
> > Can we rely on <stdint.h> on GNU/Linux? I know we can't in general.
> > Conveniently, I have a patch on one of my pending branches that
> > provides a gdb_stdint.h.
>
> Having a gdb_stdint.h would be cool ;-).
>
> > But for this case there's an easier solution, which IIRC is roughly
> > what Paul did: I can pretty much promise you that sizeof (long) ==
> > sizeof (void *) on any GNU/Linux system. So either I can merge
> > gdb_stdint.h and we can start using that, which might be a nice idea in
> > general, or for now I think "long" is fine.
>
> Well, we already use uintptr_t in linux-thread-db.c, and
> gdb_thread_db.h errors out if it isn't available (and has been doing
> so for ages). So we can be pretty sure that nobody is trying to
> compile on systems with libc5 or really old glibc versions.
>
> That said, it is probably safe to assume that all (powerpc) Linux
> ports are either ILP32 or LP64, so casting to (unsigned long) should
> be perfectly safe. It's just that I think that a uintptr_t cast
> better expresses what's happening here. But either way is fine with
> me.
>
> Mark
[-- Attachment #2: ppc-linux-nat.diff --]
[-- Type: text/x-patch, Size: 6167 bytes --]
2006-04-26: Paul Gilliam <pgilliam@us.ibm.com>
* ppc-linux-nat.c: Clean up types for ptrace.
New macro 'CORE_ADDR_CAST' accounts for the size difference between
a CORE_ADDR and a void* on ppc64 systems compiled for 32-bits.
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.60
diff -a -u -r1.60 ppc-linux-nat.c
--- ppc-linux-nat.c 24 Mar 2006 23:08:16 -0000 1.60
+++ ppc-linux-nat.c 5 May 2006 18:15:28 -0000
@@ -30,6 +30,13 @@
#include "target.h"
#include "linux-nat.h"
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#define CORE_ADDR_CAST (uintptr_t)
+#else
+#define CORE_ADDR_CAST (CORE_ADDR)(unsigned long)
+#endif
+
#include <sys/types.h>
#include <sys/param.h>
#include <signal.h>
@@ -44,18 +51,6 @@
#include "gregset.h"
#include "ppc-tdep.h"
-#ifndef PT_READ_U
-#define PT_READ_U PTRACE_PEEKUSR
-#endif
-#ifndef PT_WRITE_U
-#define PT_WRITE_U PTRACE_POKEUSR
-#endif
-
-/* Default the type of the ptrace transfer to int. */
-#ifndef PTRACE_XFER_TYPE
-#define PTRACE_XFER_TYPE int
-#endif
-
/* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a
configure time check. Some older glibc's (for instance 2.2.1)
don't have a specific powerpc version of ptrace.h, and fall back on
@@ -126,13 +121,12 @@
/* On PPC processors that support the the Signal Processing Extension
(SPE) APU, the general-purpose registers are 64 bits long.
- However, the ordinary Linux kernel PTRACE_PEEKUSR / PTRACE_POKEUSR
- / PT_READ_U / PT_WRITE_U ptrace calls only access the lower half of
- each register, to allow them to behave the same way they do on
- non-SPE systems. There's a separate pair of calls,
- PTRACE_GETEVRREGS / PTRACE_SETEVRREGS, that read and write the top
- halves of all the general-purpose registers at once, along with
- some SPE-specific registers.
+ However, the ordinary Linux kernel PTRACE_PEEKUSER / PTRACE_POKEUSER
+ ptrace calls only access the lower half of each register, to allow
+ them to behave the same way they do on non-SPE systems. There's a
+ separate pair of calls, PTRACE_GETEVRREGS / PTRACE_SETEVRREGS, that
+ read and write the top halves of all the general-purpose registers
+ at once, along with some SPE-specific registers.
GDB itself continues to claim the general-purpose registers are 32
bits long. It has unnamed raw registers that hold the upper halves
@@ -190,7 +184,7 @@
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (long);
/* General purpose registers occupy 1 slot each in the buffer */
if (regno >= tdep->ppc_gp0_regnum
@@ -384,17 +378,17 @@
return;
}
- /* Read the raw register using PTRACE_XFER_TYPE sized chunks. On a
+ /* Read the raw register using sizeof(long) sized chunks. On a
32-bit platform, 64-bit floating-point registers will require two
transfers. */
for (bytes_transferred = 0;
bytes_transferred < register_size (current_gdbarch, regno);
- bytes_transferred += sizeof (PTRACE_XFER_TYPE))
+ bytes_transferred += sizeof (long))
{
errno = 0;
- *(PTRACE_XFER_TYPE *) & buf[bytes_transferred]
- = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) regaddr, 0);
- regaddr += sizeof (PTRACE_XFER_TYPE);
+ *(long *) & buf[bytes_transferred]
+ = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0);
+ regaddr += sizeof (long);
if (errno != 0)
{
char message[128];
@@ -406,7 +400,7 @@
/* Now supply the register. Keep in mind that the regcache's idea
of the register's size may not be a multiple of sizeof
- (PTRACE_XFER_TYPE). */
+ (long). */
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
{
/* Little-endian values are always found at the left end of the
@@ -668,10 +662,10 @@
/* First collect the register. Keep in mind that the regcache's
idea of the register's size may not be a multiple of sizeof
- (PTRACE_XFER_TYPE). */
+ (long). */
memset (buf, 0, sizeof buf);
bytes_to_transfer = align_up (register_size (current_gdbarch, regno),
- sizeof (PTRACE_XFER_TYPE));
+ sizeof (long));
if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
/* Little-endian values always sit at the left end of the buffer. */
@@ -685,12 +679,12 @@
regcache_raw_collect (current_regcache, regno, buf + padding);
}
- for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_XFER_TYPE))
+ for (i = 0; i < bytes_to_transfer; i += sizeof (long))
{
errno = 0;
- ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
- *(PTRACE_XFER_TYPE *) & buf[i]);
- regaddr += sizeof (PTRACE_XFER_TYPE);
+ ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr,
+ *(long *) & buf[i]);
+ regaddr += sizeof (long);
if (errno == EIO
&& regno == tdep->ppc_fpscr_regnum)
@@ -901,7 +895,7 @@
(siginfo.si_code & 0xffff) != 0x0004)
return 0;
- last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
+ last_stopped_data_address = CORE_ADDR_CAST siginfo.si_addr;
return 1;
}
@@ -926,7 +920,7 @@
{
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (long);
ppc_linux_supply_gregset (current_regcache, -1, gregsetp,
sizeof (gdb_gregset_t), wordsize);
}
@@ -936,7 +930,7 @@
{
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (long);
/* Right fill the register. */
regcache_raw_collect (current_regcache, regnum,
((bfd_byte *) reg
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-05 18:31 ` PAUL GILLIAM
@ 2006-05-05 19:55 ` Mark Kettenis
2006-05-05 20:18 ` PAUL GILLIAM
0 siblings, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2006-05-05 19:55 UTC (permalink / raw)
To: pgilliam; +Cc: drow, gdb-patches
> From: PAUL GILLIAM <pgilliam@us.ibm.com>
> Date: Fri, 05 May 2006 11:32:18 -0700
>
> OK, How about this? I tried to make everyone happy :-)
>
> Here is an excerpt:
>
> #ifdef HAVE_STDINT_H
> #include <stdint.h>
> #define CORE_ADDR_CAST (uintptr_t)
> #else
> #define CORE_ADDR_CAST (CORE_ADDR)(unsigned long)
> #endif
> . . .
> last_stopped_data_address = CORE_ADDR_CAST siginfo.si_addr;
>
> Then when there is a gdb_stdint.h, I'll submit another patch to include
> it and replace CORE_ADDR_CAST with just (uintptr_t).
>
> Ok to commit?
Sorry Paul, this is silly. Just include <stdint.h> and use uintptr_t
unconditionally. Or use unsigned long (the extra CORE_ADDR cast isn't
necessary) if you're really scared that someone will try to compile
GDB on a system with glibc 2.0.x.
Mark
> On Fri, 2006-05-05 at 18:49 +0200, Mark Kettenis wrote:
> > > Date: Fri, 5 May 2006 12:29:55 -0400
> > > From: Daniel Jacobowitz <drow@false.org>
> > >
> > > On Thu, May 04, 2006 at 09:12:14AM +0200, Mark Kettenis wrote:
> > > > This is where the new ISO C99 <stdint.h> types come in handy. Instead of
> > > > casting to CORE_ADDR, try casting to uintptr_t.
> > >
> > > Can we rely on <stdint.h> on GNU/Linux? I know we can't in general.
> > > Conveniently, I have a patch on one of my pending branches that
> > > provides a gdb_stdint.h.
> >
> > Having a gdb_stdint.h would be cool ;-).
> >
> > > But for this case there's an easier solution, which IIRC is roughly
> > > what Paul did: I can pretty much promise you that sizeof (long) ==
> > > sizeof (void *) on any GNU/Linux system. So either I can merge
> > > gdb_stdint.h and we can start using that, which might be a nice idea in
> > > general, or for now I think "long" is fine.
> >
> > Well, we already use uintptr_t in linux-thread-db.c, and
> > gdb_thread_db.h errors out if it isn't available (and has been doing
> > so for ages). So we can be pretty sure that nobody is trying to
> > compile on systems with libc5 or really old glibc versions.
> >
> > That said, it is probably safe to assume that all (powerpc) Linux
> > ports are either ILP32 or LP64, so casting to (unsigned long) should
> > be perfectly safe. It's just that I think that a uintptr_t cast
> > better expresses what's happening here. But either way is fine with
> > me.
> >
> > Mark
>
> --=-+yu21rc4iHrvNYe3G7+v
> Content-Disposition: attachment; filename=ppc-linux-nat.diff
> Content-Type: text/x-patch; name=ppc-linux-nat.diff; charset=utf-8
> Content-Transfer-Encoding: 7bit
>
> 2006-04-26: Paul Gilliam <pgilliam@us.ibm.com>
>
> * ppc-linux-nat.c: Clean up types for ptrace.
> New macro 'CORE_ADDR_CAST' accounts for the size difference between
> a CORE_ADDR and a void* on ppc64 systems compiled for 32-bits.
>
> Index: ppc-linux-nat.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
> retrieving revision 1.60
> diff -a -u -r1.60 ppc-linux-nat.c
> --- ppc-linux-nat.c 24 Mar 2006 23:08:16 -0000 1.60
> +++ ppc-linux-nat.c 5 May 2006 18:15:28 -0000
> @@ -30,6 +30,13 @@
> #include "target.h"
> #include "linux-nat.h"
>
> +#ifdef HAVE_STDINT_H
> +#include <stdint.h>
> +#define CORE_ADDR_CAST (uintptr_t)
> +#else
> +#define CORE_ADDR_CAST (CORE_ADDR)(unsigned long)
> +#endif
> +
> #include <sys/types.h>
> #include <sys/param.h>
> #include <signal.h>
> @@ -44,18 +51,6 @@
> #include "gregset.h"
> #include "ppc-tdep.h"
>
> -#ifndef PT_READ_U
> -#define PT_READ_U PTRACE_PEEKUSR
> -#endif
> -#ifndef PT_WRITE_U
> -#define PT_WRITE_U PTRACE_POKEUSR
> -#endif
> -
> -/* Default the type of the ptrace transfer to int. */
> -#ifndef PTRACE_XFER_TYPE
> -#define PTRACE_XFER_TYPE int
> -#endif
> -
> /* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a
> configure time check. Some older glibc's (for instance 2.2.1)
> don't have a specific powerpc version of ptrace.h, and fall back on
> @@ -126,13 +121,12 @@
>
> /* On PPC processors that support the the Signal Processing Extension
> (SPE) APU, the general-purpose registers are 64 bits long.
> - However, the ordinary Linux kernel PTRACE_PEEKUSR / PTRACE_POKEUSR
> - / PT_READ_U / PT_WRITE_U ptrace calls only access the lower half of
> - each register, to allow them to behave the same way they do on
> - non-SPE systems. There's a separate pair of calls,
> - PTRACE_GETEVRREGS / PTRACE_SETEVRREGS, that read and write the top
> - halves of all the general-purpose registers at once, along with
> - some SPE-specific registers.
> + However, the ordinary Linux kernel PTRACE_PEEKUSER / PTRACE_POKEUSER
> + ptrace calls only access the lower half of each register, to allow
> + them to behave the same way they do on non-SPE systems. There's a
> + separate pair of calls, PTRACE_GETEVRREGS / PTRACE_SETEVRREGS, that
> + read and write the top halves of all the general-purpose registers
> + at once, along with some SPE-specific registers.
>
> GDB itself continues to claim the general-purpose registers are 32
> bits long. It has unnamed raw registers that hold the upper halves
> @@ -190,7 +184,7 @@
> struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
> /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
> interface, and not the wordsize of the program's ABI. */
> - int wordsize = sizeof (PTRACE_XFER_TYPE);
> + int wordsize = sizeof (long);
>
> /* General purpose registers occupy 1 slot each in the buffer */
> if (regno >= tdep->ppc_gp0_regnum
> @@ -384,17 +378,17 @@
> return;
> }
>
> - /* Read the raw register using PTRACE_XFER_TYPE sized chunks. On a
> + /* Read the raw register using sizeof(long) sized chunks. On a
> 32-bit platform, 64-bit floating-point registers will require two
> transfers. */
> for (bytes_transferred = 0;
> bytes_transferred < register_size (current_gdbarch, regno);
> - bytes_transferred += sizeof (PTRACE_XFER_TYPE))
> + bytes_transferred += sizeof (long))
> {
> errno = 0;
> - *(PTRACE_XFER_TYPE *) & buf[bytes_transferred]
> - = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) regaddr, 0);
> - regaddr += sizeof (PTRACE_XFER_TYPE);
> + *(long *) & buf[bytes_transferred]
> + = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0);
> + regaddr += sizeof (long);
> if (errno != 0)
> {
> char message[128];
> @@ -406,7 +400,7 @@
>
> /* Now supply the register. Keep in mind that the regcache's idea
> of the register's size may not be a multiple of sizeof
> - (PTRACE_XFER_TYPE). */
> + (long). */
> if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
> {
> /* Little-endian values are always found at the left end of the
> @@ -668,10 +662,10 @@
>
> /* First collect the register. Keep in mind that the regcache's
> idea of the register's size may not be a multiple of sizeof
> - (PTRACE_XFER_TYPE). */
> + (long). */
> memset (buf, 0, sizeof buf);
> bytes_to_transfer = align_up (register_size (current_gdbarch, regno),
> - sizeof (PTRACE_XFER_TYPE));
> + sizeof (long));
> if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
> {
> /* Little-endian values always sit at the left end of the buffer. */
> @@ -685,12 +679,12 @@
> regcache_raw_collect (current_regcache, regno, buf + padding);
> }
>
> - for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_XFER_TYPE))
> + for (i = 0; i < bytes_to_transfer; i += sizeof (long))
> {
> errno = 0;
> - ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
> - *(PTRACE_XFER_TYPE *) & buf[i]);
> - regaddr += sizeof (PTRACE_XFER_TYPE);
> + ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr,
> + *(long *) & buf[i]);
> + regaddr += sizeof (long);
>
> if (errno == EIO
> && regno == tdep->ppc_fpscr_regnum)
> @@ -901,7 +895,7 @@
> (siginfo.si_code & 0xffff) != 0x0004)
> return 0;
>
> - last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
> + last_stopped_data_address = CORE_ADDR_CAST siginfo.si_addr;
> return 1;
> }
>
> @@ -926,7 +920,7 @@
> {
> /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
> interface, and not the wordsize of the program's ABI. */
> - int wordsize = sizeof (PTRACE_XFER_TYPE);
> + int wordsize = sizeof (long);
> ppc_linux_supply_gregset (current_regcache, -1, gregsetp,
> sizeof (gdb_gregset_t), wordsize);
> }
> @@ -936,7 +930,7 @@
> {
> /* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
> interface, and not the wordsize of the program's ABI. */
> - int wordsize = sizeof (PTRACE_XFER_TYPE);
> + int wordsize = sizeof (long);
> /* Right fill the register. */
> regcache_raw_collect (current_regcache, regnum,
> ((bfd_byte *) reg
>
> --=-+yu21rc4iHrvNYe3G7+v--
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-05 19:55 ` Mark Kettenis
@ 2006-05-05 20:18 ` PAUL GILLIAM
2006-05-05 20:21 ` PAUL GILLIAM
2006-05-05 20:29 ` Mark Kettenis
0 siblings, 2 replies; 13+ messages in thread
From: PAUL GILLIAM @ 2006-05-05 20:18 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, gdb-patches
On Fri, 2006-05-05 at 21:54 +0200, Mark Kettenis wrote:
> > From: PAUL GILLIAM <pgilliam@us.ibm.com>
> > Date: Fri, 05 May 2006 11:32:18 -0700
> >
> > OK, How about this? I tried to make everyone happy :-)
> >
> > Here is an excerpt:
> >
> > #ifdef HAVE_STDINT_H
> > #include <stdint.h>
> > #define CORE_ADDR_CAST (uintptr_t)
> > #else
> > #define CORE_ADDR_CAST (CORE_ADDR)(unsigned long)
> > #endif
> > . . .
> > last_stopped_data_address = CORE_ADDR_CAST siginfo.si_addr;
> >
> > Then when there is a gdb_stdint.h, I'll submit another patch to include
> > it and replace CORE_ADDR_CAST with just (uintptr_t).
> >
> > Ok to commit?
>
> Sorry Paul, this is silly. Just include <stdint.h> and use uintptr_t
> unconditionally. Or use unsigned long (the extra CORE_ADDR cast isn't
> necessary) if you're really scared that someone will try to compile
> GDB on a system with glibc 2.0.x.
Alright, I admit it is a little silly. I thought it would fit right in
with a lot of what I see on this mailing list :-)
Anyway, I changed it as you suggested: OK to commit?
-=# Paul #=-
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-05 20:18 ` PAUL GILLIAM
@ 2006-05-05 20:21 ` PAUL GILLIAM
2006-05-05 20:29 ` Mark Kettenis
1 sibling, 0 replies; 13+ messages in thread
From: PAUL GILLIAM @ 2006-05-05 20:21 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1252 bytes --]
This time with the attachment.... :-(
On Fri, 2006-05-05 at 13:20 -0700, PAUL GILLIAM wrote:
> On Fri, 2006-05-05 at 21:54 +0200, Mark Kettenis wrote:
> > > From: PAUL GILLIAM <pgilliam@us.ibm.com>
> > > Date: Fri, 05 May 2006 11:32:18 -0700
> > >
> > > OK, How about this? I tried to make everyone happy :-)
> > >
> > > Here is an excerpt:
> > >
> > > #ifdef HAVE_STDINT_H
> > > #include <stdint.h>
> > > #define CORE_ADDR_CAST (uintptr_t)
> > > #else
> > > #define CORE_ADDR_CAST (CORE_ADDR)(unsigned long)
> > > #endif
> > > . . .
> > > last_stopped_data_address = CORE_ADDR_CAST siginfo.si_addr;
> > >
> > > Then when there is a gdb_stdint.h, I'll submit another patch to include
> > > it and replace CORE_ADDR_CAST with just (uintptr_t).
> > >
> > > Ok to commit?
> >
> > Sorry Paul, this is silly. Just include <stdint.h> and use uintptr_t
> > unconditionally. Or use unsigned long (the extra CORE_ADDR cast isn't
> > necessary) if you're really scared that someone will try to compile
> > GDB on a system with glibc 2.0.x.
>
> Alright, I admit it is a little silly. I thought it would fit right in
> with a lot of what I see on this mailing list :-)
>
> Anyway, I changed it as you suggested: OK to commit?
>
> -=# Paul #=-
>
[-- Attachment #2: ppc-linux-nat.diff --]
[-- Type: text/x-patch, Size: 6051 bytes --]
2006-05-05: Paul Gilliam <pgilliam@us.ibm.com>
* ppc-linux-nat.c: Clean up types for ptrace.
Replace (CORE_ADDR) with (uintptr_t) to avoid the size difference
between a CORE_ADDR and a void* on ppc64 systems compiled for 32-bits.
Index: ppc-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
retrieving revision 1.60
diff -a -u -r1.60 ppc-linux-nat.c
--- ppc-linux-nat.c 24 Mar 2006 23:08:16 -0000 1.60
+++ ppc-linux-nat.c 5 May 2006 20:12:13 -0000
@@ -30,6 +30,7 @@
#include "target.h"
#include "linux-nat.h"
+#include <stdint.h>
#include <sys/types.h>
#include <sys/param.h>
#include <signal.h>
@@ -44,18 +45,6 @@
#include "gregset.h"
#include "ppc-tdep.h"
-#ifndef PT_READ_U
-#define PT_READ_U PTRACE_PEEKUSR
-#endif
-#ifndef PT_WRITE_U
-#define PT_WRITE_U PTRACE_POKEUSR
-#endif
-
-/* Default the type of the ptrace transfer to int. */
-#ifndef PTRACE_XFER_TYPE
-#define PTRACE_XFER_TYPE int
-#endif
-
/* Glibc's headers don't define PTRACE_GETVRREGS so we cannot use a
configure time check. Some older glibc's (for instance 2.2.1)
don't have a specific powerpc version of ptrace.h, and fall back on
@@ -126,13 +115,12 @@
/* On PPC processors that support the the Signal Processing Extension
(SPE) APU, the general-purpose registers are 64 bits long.
- However, the ordinary Linux kernel PTRACE_PEEKUSR / PTRACE_POKEUSR
- / PT_READ_U / PT_WRITE_U ptrace calls only access the lower half of
- each register, to allow them to behave the same way they do on
- non-SPE systems. There's a separate pair of calls,
- PTRACE_GETEVRREGS / PTRACE_SETEVRREGS, that read and write the top
- halves of all the general-purpose registers at once, along with
- some SPE-specific registers.
+ However, the ordinary Linux kernel PTRACE_PEEKUSER / PTRACE_POKEUSER
+ ptrace calls only access the lower half of each register, to allow
+ them to behave the same way they do on non-SPE systems. There's a
+ separate pair of calls, PTRACE_GETEVRREGS / PTRACE_SETEVRREGS, that
+ read and write the top halves of all the general-purpose registers
+ at once, along with some SPE-specific registers.
GDB itself continues to claim the general-purpose registers are 32
bits long. It has unnamed raw registers that hold the upper halves
@@ -190,7 +178,7 @@
struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (long);
/* General purpose registers occupy 1 slot each in the buffer */
if (regno >= tdep->ppc_gp0_regnum
@@ -384,17 +372,17 @@
return;
}
- /* Read the raw register using PTRACE_XFER_TYPE sized chunks. On a
+ /* Read the raw register using sizeof(long) sized chunks. On a
32-bit platform, 64-bit floating-point registers will require two
transfers. */
for (bytes_transferred = 0;
bytes_transferred < register_size (current_gdbarch, regno);
- bytes_transferred += sizeof (PTRACE_XFER_TYPE))
+ bytes_transferred += sizeof (long))
{
errno = 0;
- *(PTRACE_XFER_TYPE *) & buf[bytes_transferred]
- = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) regaddr, 0);
- regaddr += sizeof (PTRACE_XFER_TYPE);
+ *(long *) & buf[bytes_transferred]
+ = ptrace (PTRACE_PEEKUSER, tid, (PTRACE_TYPE_ARG3) regaddr, 0);
+ regaddr += sizeof (long);
if (errno != 0)
{
char message[128];
@@ -406,7 +394,7 @@
/* Now supply the register. Keep in mind that the regcache's idea
of the register's size may not be a multiple of sizeof
- (PTRACE_XFER_TYPE). */
+ (long). */
if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE)
{
/* Little-endian values are always found at the left end of the
@@ -668,10 +656,10 @@
/* First collect the register. Keep in mind that the regcache's
idea of the register's size may not be a multiple of sizeof
- (PTRACE_XFER_TYPE). */
+ (long). */
memset (buf, 0, sizeof buf);
bytes_to_transfer = align_up (register_size (current_gdbarch, regno),
- sizeof (PTRACE_XFER_TYPE));
+ sizeof (long));
if (TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
/* Little-endian values always sit at the left end of the buffer. */
@@ -685,12 +673,12 @@
regcache_raw_collect (current_regcache, regno, buf + padding);
}
- for (i = 0; i < bytes_to_transfer; i += sizeof (PTRACE_XFER_TYPE))
+ for (i = 0; i < bytes_to_transfer; i += sizeof (long))
{
errno = 0;
- ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) regaddr,
- *(PTRACE_XFER_TYPE *) & buf[i]);
- regaddr += sizeof (PTRACE_XFER_TYPE);
+ ptrace (PTRACE_POKEUSER, tid, (PTRACE_TYPE_ARG3) regaddr,
+ *(long *) & buf[i]);
+ regaddr += sizeof (long);
if (errno == EIO
&& regno == tdep->ppc_fpscr_regnum)
@@ -901,7 +889,7 @@
(siginfo.si_code & 0xffff) != 0x0004)
return 0;
- last_stopped_data_address = (CORE_ADDR) siginfo.si_addr;
+ last_stopped_data_address = (uintptr_t) siginfo.si_addr;
return 1;
}
@@ -926,7 +914,7 @@
{
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (long);
ppc_linux_supply_gregset (current_regcache, -1, gregsetp,
sizeof (gdb_gregset_t), wordsize);
}
@@ -936,7 +924,7 @@
{
/* NOTE: cagney/2003-11-25: This is the word size used by the ptrace
interface, and not the wordsize of the program's ABI. */
- int wordsize = sizeof (PTRACE_XFER_TYPE);
+ int wordsize = sizeof (long);
/* Right fill the register. */
regcache_raw_collect (current_regcache, regnum,
((bfd_byte *) reg
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-05 20:18 ` PAUL GILLIAM
2006-05-05 20:21 ` PAUL GILLIAM
@ 2006-05-05 20:29 ` Mark Kettenis
2006-05-05 20:47 ` PAUL GILLIAM
1 sibling, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2006-05-05 20:29 UTC (permalink / raw)
To: pgilliam; +Cc: drow, gdb-patches
> From: PAUL GILLIAM <pgilliam@us.ibm.com>
> Date: Fri, 05 May 2006 13:20:12 -0700
>
> On Fri, 2006-05-05 at 21:54 +0200, Mark Kettenis wrote:
> > > From: PAUL GILLIAM <pgilliam@us.ibm.com>
> > > Date: Fri, 05 May 2006 11:32:18 -0700
> > >
> > > OK, How about this? I tried to make everyone happy :-)
> > >
> > > Here is an excerpt:
> > >
> > > #ifdef HAVE_STDINT_H
> > > #include <stdint.h>
> > > #define CORE_ADDR_CAST (uintptr_t)
> > > #else
> > > #define CORE_ADDR_CAST (CORE_ADDR)(unsigned long)
> > > #endif
> > > . . .
> > > last_stopped_data_address = CORE_ADDR_CAST siginfo.si_addr;
> > >
> > > Then when there is a gdb_stdint.h, I'll submit another patch to include
> > > it and replace CORE_ADDR_CAST with just (uintptr_t).
> > >
> > > Ok to commit?
> >
> > Sorry Paul, this is silly. Just include <stdint.h> and use uintptr_t
> > unconditionally. Or use unsigned long (the extra CORE_ADDR cast isn't
> > necessary) if you're really scared that someone will try to compile
> > GDB on a system with glibc 2.0.x.
>
> Alright, I admit it is a little silly. I thought it would fit right in
> with a lot of what I see on this mailing list :-)
>
> Anyway, I changed it as you suggested: OK to commit?
Could you do me a favour, and replace:
*(long *) & buf[bytes_transferred]
with
*(long *) &buf[bytes_transferred]
?
That extra space has been there ever since the code was reindented
using indent(1), but really shouldn't be there. It makes me think
it's a bitwise and instead of address off operator.
Otherwise, yes, ok with that change.
Mark
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [patch] Can't build ppc32 GDB
2006-05-05 20:29 ` Mark Kettenis
@ 2006-05-05 20:47 ` PAUL GILLIAM
0 siblings, 0 replies; 13+ messages in thread
From: PAUL GILLIAM @ 2006-05-05 20:47 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, gdb-patches
On Fri, 2006-05-05 at 22:29 +0200, Mark Kettenis wrote:
> Could you do me a favour, and replace:
>
> *(long *) & buf[bytes_transferred]
>
> with
>
> *(long *) &buf[bytes_transferred]
>
> ?
>
> That extra space has been there ever since the code was reindented
> using indent(1), but really shouldn't be there. It makes me think
> it's a bitwise and instead of address off operator.
>
> Otherwise, yes, ok with that change.
>
> Mark
OK, committed. There was another case of *(long *) & buf.... and I
fixed that too.
I also fixed an entry in the ChangeLog that had leading spaces instead
of a tab.
-=# Paul #=-
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2006-05-05 20:47 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-25 0:18 [patch] Can't build ppc32 GDB PAUL GILLIAM
2006-04-25 0:22 ` PAUL GILLIAM
2006-04-25 19:38 ` Mark Kettenis
2006-05-03 23:32 ` PAUL GILLIAM
2006-05-04 7:12 ` Mark Kettenis
2006-05-05 16:30 ` Daniel Jacobowitz
2006-05-05 16:50 ` Mark Kettenis
2006-05-05 18:31 ` PAUL GILLIAM
2006-05-05 19:55 ` Mark Kettenis
2006-05-05 20:18 ` PAUL GILLIAM
2006-05-05 20:21 ` PAUL GILLIAM
2006-05-05 20:29 ` Mark Kettenis
2006-05-05 20:47 ` PAUL GILLIAM
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox