From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31749 invoked by alias); 5 May 2006 20:21:10 -0000 Received: (qmail 31740 invoked by uid 22791); 5 May 2006 20:21:08 -0000 X-Spam-Check-By: sourceware.org Received: from e2.ny.us.ibm.com (HELO e2.ny.us.ibm.com) (32.97.182.142) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 05 May 2006 20:21:03 +0000 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e2.ny.us.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id k45KL1El008415 for ; Fri, 5 May 2006 16:21:01 -0400 Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by d01relay04.pok.ibm.com (8.12.10/NCO/VER6.8) with ESMTP id k45KL1Hm238716 for ; Fri, 5 May 2006 16:21:01 -0400 Received: from d01av04.pok.ibm.com (loopback [127.0.0.1]) by d01av04.pok.ibm.com (8.12.11/8.13.3) with ESMTP id k45KL1Sf009284 for ; Fri, 5 May 2006 16:21:01 -0400 Received: from dufur.beaverton.ibm.com (dufur.beaverton.ibm.com [9.47.22.20]) by d01av04.pok.ibm.com (8.12.11/8.12.11) with ESMTP id k45KL0N9009236; Fri, 5 May 2006 16:21:00 -0400 Subject: Re: [patch] Can't build ppc32 GDB From: PAUL GILLIAM Reply-To: pgilliam@us.ibm.com To: Mark Kettenis Cc: drow@false.org, gdb-patches@sources.redhat.com In-Reply-To: <1146860412.16180.21.camel@dufur.beaverton.ibm.com> References: <1145924338.18934.45.camel@dufur.beaverton.ibm.com> <1145924593.18934.48.camel@dufur.beaverton.ibm.com> <200604251938.k3PJc9dl014571@elgar.sibelius.xs4all.nl> <1146699224.16180.4.camel@dufur.beaverton.ibm.com> <25493.192.87.1.22.1146726734.squirrel@webmail.xs4all.nl> <20060505162955.GB31029@nevyn.them.org> <200605051649.k45GnKob023219@elgar.sibelius.xs4all.nl> <1146853938.16180.11.camel@dufur.beaverton.ibm.com> <200605051954.k45JsOhL021761@elgar.sibelius.xs4all.nl> <1146860412.16180.21.camel@dufur.beaverton.ibm.com> Content-Type: multipart/mixed; boundary="=-VeRVnHlViz5GI1/L6HXf" Date: Fri, 05 May 2006 20:21:00 -0000 Message-Id: <1146860542.16180.25.camel@dufur.beaverton.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.2.2 (2.2.2-5) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00099.txt.bz2 --=-VeRVnHlViz5GI1/L6HXf Content-Type: text/plain Content-Transfer-Encoding: 7bit Content-length: 1252 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 > > > 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 > > > #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 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 #=- > --=-VeRVnHlViz5GI1/L6HXf 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 Content-length: 6051 2006-05-05: Paul Gilliam * 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 #include #include #include @@ -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 --=-VeRVnHlViz5GI1/L6HXf--