[RFC/PATCH 2/5] powerpc: Cleanup ptrace bits

Ulrich Weigand Ulrich.Weigand at de.ibm.com
Tue May 29 23:37:08 EST 2007


Kumar Gala <galak at kernel.crashing.org> wrote on 05/29/2007 03:19:42 PM:
> On May 29, 2007, at 4:02 AM, Benjamin Herrenschmidt wrote:
> > Hrm.. we do have a subtle difference in vrregs that I've missed.. I'll
> > respin tomorrow. It looks like we don't store the VRSAVE register 
> > at the
> > same place on 32 and 64 bits... yuck. I need to double check tomorrow.
> 
> That's bad.  We really should have VRSAVE in the same location for 
> both.  (wondering if GDB expects it a different locations on 32 vs 64- 
> bits.)

It looks like GDB will expect VRSAVE at offset 33*16 (length 4 bytes)
in the area returned by PTRACE_GETVRREGS, for both 32-bit and 64-bit
applications:

/* This oddity is because the Linux kernel defines elf_vrregset_t as
   an array of 33 16 bytes long elements.  I.e. it leaves out vrsave.
   However the PTRACE_GETVRREGS and PTRACE_SETVRREGS requests return
   the vrsave as an extra 4 bytes at the end.  I opted for creating a
   flat array of chars, so that it is easier to manipulate for gdb.

   There are 32 vector registers 16 bytes longs, plus a VSCR register
   which is only 4 bytes long, but is fetched as a 16 bytes
   quantity. Up to here we have the elf_vrregset_t structure.
   Appended to this there is space for the VRSAVE register: 4 bytes.
   Even though this vrsave register is not included in the regset
   typedef, it is handled by the ptrace requests.

   Note that GNU/Linux doesn't support little endian PPC hardware,
   therefore the offset at which the real value of the VSCR register
   is located will be always 12 bytes.

   The layout is like this (where x is the actual value of the vscr reg): 
*/

/* *INDENT-OFF* */
/*
   |.|.|.|.|.....|.|.|.|.||.|.|.|x||.|
   <------->     <-------><-------><->
     VR0           VR31     VSCR    VRSAVE
*/
/* *INDENT-ON* */

#define SIZEOF_VRREGS 33*16+4

typedef char gdb_vrregset_t[SIZEOF_VRREGS];


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

-- 
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  GNU compiler/toolchain for Linux on System z and Cell BE
  IBM Deutschland Entwicklung GmbH
  Vorsitzender des Aufsichtsrats: Martin Jetter | Geschäftsführung: 
Herbert Kircher
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht 
Stuttgart, HRB 243294
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linuxppc-dev/attachments/20070529/f412ed8f/attachment.htm>


More information about the Linuxppc-dev mailing list