From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23943 invoked by alias); 25 Nov 2003 22:51:33 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 23931 invoked from network); 25 Nov 2003 22:51:32 -0000 Received: from unknown (HELO localhost.redhat.com) (207.219.125.105) by sources.redhat.com with SMTP; 25 Nov 2003 22:51:32 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id 188222B8F for ; Tue, 25 Nov 2003 17:51:29 -0500 (EST) Message-ID: <3FC3DCF1.4090009@redhat.com> Date: Tue, 25 Nov 2003 22:51:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [rfa/ppc64/GNU/Linux] Fix obvious 32x64 probs in ppc-linux-nat.c Content-Type: multipart/mixed; boundary="------------080106090401000908030801" X-SW-Source: 2003-11/txt/msg00583.txt.bz2 This is a multi-part message in MIME format. --------------080106090401000908030801 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 145 Hello, This fixes three "obvious" 32x64 problems in ppc-linux-nat.c - it uses the PTRACE "wordsize" where applicable. ok for mainline? Andrew --------------080106090401000908030801 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 3047 2003-11-25 Andrew Cagney * ppc-linux-nat.c (store_register, fetch_register): Convert between ptrace and regcache's wordsize. (ppc_register_u_addr): Use the ptrace wordsize. Index: ./gdb/ppc-linux-nat.c =================================================================== RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v retrieving revision 1.26 diff -u -r1.26 ppc-linux-nat.c --- ./gdb/ppc-linux-nat.c 2 Oct 2003 20:28:30 -0000 1.26 +++ ./gdb/ppc-linux-nat.c 25 Nov 2003 22:43:04 -0000 @@ -127,7 +127,9 @@ { int u_addr = -1; struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); - int wordsize = tdep->wordsize; + /* 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); /* General purpose registers occupy 1 slot each in the buffer */ if (regno >= tdep->ppc_gp0_regnum && regno <= tdep->ppc_gplast_regnum ) @@ -235,6 +237,9 @@ return; } + /* Read the raw register using PTRACE_XFER_TYPE sized chunks. On a + 32-bit platform, 64-bit floating-point registers will require two + transfers. */ for (i = 0; i < DEPRECATED_REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE)) { errno = 0; @@ -248,7 +253,19 @@ perror_with_name (mess); } } - supply_register (regno, buf); + + /* Now supply the register. Be careful to map between ptrace's and + the current_regcache's idea of the current wordsize. */ + if ((regno >= FP0_REGNUM && regno < FP0_REGNUM +32) + || gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_LITTLE) + /* FPs are always 64 bits. Little endian values are always found + at the left-hand end of the register. */ + regcache_raw_supply (current_regcache, regno, buf); + else + /* Big endian register, need to fetch the right-hand end. */ + regcache_raw_supply (current_regcache, regno, + (buf + sizeof (PTRACE_XFER_TYPE) + - register_size (current_gdbarch, regno))); } static void @@ -380,7 +397,21 @@ if (regaddr == -1) return; - regcache_collect (regno, buf); + /* First collect the register value from the regcache. Be careful + to to convert the regcache's wordsize into ptrace's wordsize. */ + memset (buf, 0, sizeof buf); + if ((regno >= FP0_REGNUM && regno < FP0_REGNUM + 32) + || TARGET_BYTE_ORDER == BFD_ENDIAN_LITTLE) + /* Floats are always 64-bit. Little endian registers are always + at the left-hand end of the register cache. */ + regcache_raw_collect (current_regcache, regno, buf); + else + /* Big-endian registers belong at the right-hand end of the + buffer. */ + regcache_raw_collect (current_regcache, regno, + (buf + sizeof (PTRACE_XFER_TYPE) + - register_size (current_gdbarch, regno))); + for (i = 0; i < DEPRECATED_REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE)) { errno = 0; --------------080106090401000908030801--