Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Elena Zannoni <ezannoni@cygnus.com>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] W.I.P. AltiVec ppc registers support.
Date: Thu, 29 Nov 2001 14:27:00 -0000	[thread overview]
Message-ID: <15366.47050.390230.767150@krustylu.cygnus.com> (raw)
In-Reply-To: <1011129220956.ZM19532@ocotillo.lan>

Kevin Buettner writes:
 > On Nov 29,  2:32pm, Kevin Buettner wrote:
 > 
 > > If Elena makes the changes that I have in mind,...
 > > code which affects the interface will collapse down to 5 lines or so. 
 > > Of course, if PTRACE_GETFPXREGS (or the like) ends up being used,
 > > ppc-linux-nat.c need to be substantially rewritten anyway.  But the
 > > point is that the five lines (or so) that I have in mind can then just
 > > be deleted.
 > 
 > It occurred to me that it might help Elena more if I provided a
 > patch with what I had in mind.  See below.  (Completely untested.)

I am not that helpless :-)

Let me wait a bit on this until the ptrace issue is clarified somewhat.

Elena


 > 
 > Anyway, the five lines that I refer to above is this part:
 > 
 > +#ifdef PT_VR0
 > +      u_addr = (PT_VR0 + (regno - gdbarch_tdep (current_gdbarch)->first_altivec_regnum) * 4) * 4;
 > +#else
 > +      u_addr = -1;
 > +#endif
 > 
 > 
 > Index: ppc-linux-nat.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
 > retrieving revision 1.10
 > diff -u -p -r1.10 ppc-linux-nat.c
 > --- ppc-linux-nat.c	2001/11/20 16:35:24	1.10
 > +++ ppc-linux-nat.c	2001/11/29 22:05:26
 > @@ -32,31 +32,243 @@
 >  #include <sys/wait.h>
 >  #include <fcntl.h>
 >  #include <sys/procfs.h>
 > +#include <sys/ptrace.h>
 >  
 >  /* Prototypes for supply_gregset etc. */
 >  #include "gregset.h"
 > +#include "ppc-tdep.h"
 >  
 > +/* Default the type of the ptrace transfer to int.  */
 > +#ifndef PTRACE_XFER_TYPE
 > +#define PTRACE_XFER_TYPE long
 > +#endif
 > +
 >  int
 >  kernel_u_size (void)
 >  {
 >    return (sizeof (struct user));
 >  }
 > +
 > +/* *INDENT-OFF* */
 > +/* registers layout, as presented by the ptrace interface:
 > +PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
 > +PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
 > +PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
 > +PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
 > +PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
 > +PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
 > +PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
 > +PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
 > +PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ */
 > +/* *INDENT_ON * */
 > +
 > +static int 
 > +ppc_register_u_addr (int regno)
 > +{
 > +  int u_addr = -1;
 > +
 > +  /* General purpose registers occupy 1 slot each in the buffer */
 > +  if (regno >= PPC_GP0_REGNUM && regno <= PPC_GPLAST_REGNUM )
 > +    u_addr = (PT_R0 + regno) * 4;
 > +
 > +  /* Floating point regs: 2 slots each */
 > +  if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
 > +    u_addr = (PT_FPR0 + (regno - FP0_REGNUM) * 2) * 4;
 > +
 > +  /* Altivec registers: 4 slots each. */
 > +  if (altivec_register_p (regno))
 > +    {
 > +#ifdef PT_VR0
 > +      u_addr = (PT_VR0 + (regno - gdbarch_tdep (current_gdbarch)->first_altivec_regnum) * 4) * 4;
 > +#else
 > +      u_addr = -1;
 > +#endif
 > +    }
 > +
 > +  /* UISA special purpose registers: 1 slot each */
 > +  if (regno == PC_REGNUM)
 > +    u_addr = PT_NIP * 4;
 > +  if (regno == PPC_LR_REGNUM)
 > +    u_addr = PT_LNK * 4;
 > +  if (regno == PPC_CR_REGNUM)
 > +    u_addr = PT_CCR * 4;
 > +  if (regno == PPC_XER_REGNUM)
 > +    u_addr = PT_XER * 4;
 > +  if (regno == PPC_CTR_REGNUM)
 > +    u_addr = PT_CTR * 4;
 > +  if (regno == PPC_MQ_REGNUM)
 > +    u_addr = PT_MQ * 4;
 > +  if (regno == PPC_PS_REGNUM)
 > +    u_addr = PT_MSR * 4;
 > +
 > +  return u_addr;
 > +}
 > +
 > +static int
 > +ppc_ptrace_cannot_fetch_store_register (int regno)
 > +{
 > +  return (ppc_register_u_addr (regno) == -1);
 > +}
 > +
 > +static void
 > +fetch_register (int regno)
 > +{
 > +  /* This isn't really an address.  But ptrace thinks of it as one.  */
 > +  CORE_ADDR regaddr;
 > +  char mess[128];              /* For messages */
 > +  register int i;
 > +  char buf[MAX_REGISTER_RAW_SIZE];
 > +  int tid;
 > +
 > +  if (ppc_ptrace_cannot_fetch_store_register (regno))
 > +    {
 > +      memset (buf, '\0', REGISTER_RAW_SIZE (regno));   /* Supply zeroes */
 > +      supply_register (regno, buf);
 > +      return;
 > +    }
 > +
 > +  /* Overload thread id onto process id */
 > +  if ((tid = TIDGET (inferior_ptid)) == 0)
 > +    tid = PIDGET (inferior_ptid);      /* no thread id, just use process id */
 > +
 > +  regaddr = ppc_register_u_addr (regno);
 > +  if (regaddr < 0)
 > +    return;
 > +  for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
 > +    {
 > +      errno = 0;
 > +      *(PTRACE_XFER_TYPE *) & buf[i] = ptrace (PTRACE_PEEKUSR, tid,
 > +					       (PTRACE_ARG3_TYPE) regaddr, 0);
 > +      regaddr += sizeof (PTRACE_XFER_TYPE);
 > +      if (errno != 0)
 > +	{
 > +	  sprintf (mess, "reading register %s (#%d)", 
 > +		   REGISTER_NAME (regno), regno);
 > +	  perror_with_name (mess);
 > +	}
 > +    }
 > +  supply_register (regno, buf);
 > +}
 > +
 > +static void 
 > +fetch_ppc_registers (void)
 > +{
 > +  int last_register;
 > +  int i;
 > +
 > +  last_register = PPC_MQ_REGNUM;
 > +  for (i = 0; i <= last_register; i++)
 > +    fetch_register (i);
 > +}
 > +
 > +static void 
 > +fetch_altivec_registers (void)
 > +{
 > +  int i;
 > +
 > +  for (i = 0;
 > +       i < gdbarch_tdep (current_gdbarch)->last_altivec_regnum
 > +	 - gdbarch_tdep (current_gdbarch)->first_altivec_regnum;
 > +       i++)
 > +    fetch_register (gdbarch_tdep (current_gdbarch)->first_altivec_regnum + i);
 > +}
 > +
 > +/* Fetch registers from the child process.  Fetch all registers if
 > +   regno == -1, otherwise fetch all general registers or all floating
 > +   point registers depending upon the value of regno.  */
 > +
 > +void
 > +fetch_inferior_registers (int regno)
 > +{
 > +  if (regno == -1)
 > +    {
 > +      fetch_ppc_registers ();
 > +      fetch_altivec_registers ();
 > +    }
 > +  else 
 > +    {
 > +      if (altivec_register_p (regno))
 > +	fetch_altivec_register (regno);
 > +      else
 > +	fetch_register (regno);
 > +    }
 > +}
 > +
 > +/* Store one register. */
 > +static void
 > +store_register (int regno)
 > +{
 > +  /* This isn't really an address.  But ptrace thinks of it as one.  */
 > +  CORE_ADDR regaddr;
 > +  char mess[128];              /* For messages */
 > +  register int i;
 > +  int tid;
 > +  char *buf = alloca (MAX_REGISTER_RAW_SIZE);
 > +
 > +  if (ppc_ptrace_cannot_fetch_store_register (regno))
 > +    {
 > +      return;
 > +    }
 > +
 > +  /* Overload thread id onto process id */
 > +  if ((tid = TIDGET (inferior_ptid)) == 0)
 > +    tid = PIDGET (inferior_ptid);      /* no thread id, just use process id */
 > +
 > +  regaddr = ppc_register_u_addr (regno);
 > +  regcache_collect (regno, buf);
 > +  for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
 > +    {
 > +      errno = 0;
 > +      ptrace (PTRACE_POKEUSR, tid, (PTRACE_ARG3_TYPE) regaddr,
 > +	      *(PTRACE_XFER_TYPE *) & buf[i]);
 > +      regaddr += sizeof (PTRACE_XFER_TYPE);
 > +      if (errno != 0)
 > +	{
 > +	  sprintf (mess, "writing register %s (#%d)", 
 > +		   REGISTER_NAME (regno), regno);
 > +	  perror_with_name (mess);
 > +	}
 > +    }
 > +}
 > +
 > +static void
 > +store_ppc_registers (void)
 > +{
 > +  int last_register;
 > +  int i;
 > +
 > +  last_register = PPC_MQ_REGNUM;
 > +  for (i = 0; i <= last_register; i++)
 > +    store_register (i);
 > +}
 > +
 > +static void
 > +store_altivec_registers (void)
 > +{
 > +  int i;
 >  
 > -static int regmap[] =
 > -{PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
 > - PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
 > - PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
 > - PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
 > - PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
 > - PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
 > - PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
 > - PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
 > - PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ};
 > +  for (i = 0; 
 > +       i < gdbarch_tdep (current_gdbarch)->last_altivec_regnum 
 > +	 - gdbarch_tdep (current_gdbarch)->first_altivec_regnum; 
 > +       i++)
 > +    store_register (gdbarch_tdep (current_gdbarch)->first_altivec_regnum + i);
 > +}
 >  
 > -int 
 > -ppc_register_u_addr (int ustart, int regnum)
 > +void
 > +store_inferior_registers (int regno)
 >  {
 > -  return (ustart + 4 * regmap[regnum]);
 > +  if (regno >= 0)
 > +    {
 > +      if (altivec_register_p (regno))
 > +        store_altivec_register (regno);
 > +      else
 > +        store_register (regno);
 > +    }
 > +  else
 > +    {
 > +      store_ppc_registers ();
 > +      store_altivec_registers ();
 > +    }
 >  }
 >  
 >  void
 > @@ -68,8 +280,13 @@ supply_gregset (gdb_gregset_t *gregsetp)
 >    for (regi = 0; regi < 32; regi++)
 >      supply_register (regi, (char *) (regp + regi));
 >  
 > -  for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++)
 > -    supply_register (regi, (char *) (regp + regmap[regi]));
 > +  supply_register (PC_REGNUM, (char *) (regp + PT_NIP));
 > +  supply_register (PPC_LR_REGNUM, (char *) (regp + PT_LNK));
 > +  supply_register (PPC_CR_REGNUM, (char *) (regp + PT_CCR));
 > +  supply_register (PPC_XER_REGNUM, (char *) (regp + PT_XER));
 > +  supply_register (PPC_CTR_REGNUM, (char *) (regp + PT_CTR));
 > +  supply_register (PPC_MQ_REGNUM, (char *) (regp + PT_MQ));
 > +  supply_register (PPC_PS_REGNUM, (char *) (regp + PT_MSR));
 >  }
 >  
 >  void
 > @@ -78,19 +295,26 @@ fill_gregset (gdb_gregset_t *gregsetp, i
 >    int regi;
 >    elf_greg_t *regp = (elf_greg_t *) gregsetp;
 >  
 > -#define COPY_REG(_idx_,_regi_) \
 > -  if ((regno == -1) || regno == _regi_) \
 > -    regcache_collect (_regi_, regp + _idx_)
 > -
 >    for (regi = 0; regi < 32; regi++)
 >      {
 > -      COPY_REG (regmap[regi], regi);
 > +      if ((regno == -1) || regno == regi)
 > +        regcache_collect (regi, regp + PT_R0 + regi);
 >      }
 >  
 > -  for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++)
 > -    {
 > -      COPY_REG (regmap[regi], regi);
 > -    }
 > +  if ((regno == -1) || regno == PC_REGNUM)
 > +    regcache_collect (PC_REGNUM, regp + PT_NIP);
 > +  if ((regno == -1) || regno == PPC_LR_REGNUM)
 > +    regcache_collect (PPC_LR_REGNUM, regp + PT_LNK);
 > +  if ((regno == -1) || regno == PPC_CR_REGNUM)
 > +    regcache_collect (PPC_CR_REGNUM, regp + PT_CCR);
 > +  if ((regno == -1) || regno == PPC_XER_REGNUM)
 > +    regcache_collect (PPC_XER_REGNUM, regp + PT_XER);
 > +  if ((regno == -1) || regno == PPC_CTR_REGNUM)
 > +    regcache_collect (PPC_CTR_REGNUM, regp + PT_CTR);
 > +  if ((regno == -1) || regno == PPC_MQ_REGNUM)
 > +    regcache_collect (PPC_MQ_REGNUM, regp + PT_MQ);
 > +  if ((regno == -1) || regno == PPC_PS_REGNUM)
 > +    regcache_collect (PPC_PS_REGNUM, regp + PT_MSR);
 >  }
 >  
 >  void
 > Index: config/powerpc/nm-linux.h
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/config/powerpc/nm-linux.h,v
 > retrieving revision 1.9
 > diff -u -p -r1.9 nm-linux.h
 > --- nm-linux.h	2001/11/20 16:36:44	1.9
 > +++ nm-linux.h	2001/11/29 22:05:32
 > @@ -23,15 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridg
 >  
 >  #define NM_LINUX_H
 >  
 > -/* Return sizeof user struct to callers in less machine dependent routines */
 > -
 > -#define KERNEL_U_SIZE kernel_u_size()
 > -extern int kernel_u_size (void);
 > -
 > -#define U_REGS_OFFSET 0
 > -
 > -extern int ppc_register_u_addr (int, int);
 > -#define REGISTER_U_ADDR(addr, blockend, regno) \
 > -        (addr) = ppc_register_u_addr ((blockend),(regno));
 > +#define FETCH_INFERIOR_REGISTERS
 >  
 >  #endif /* #ifndef NM_LINUX_H */


WARNING: multiple messages have this Message-ID
From: Elena Zannoni <ezannoni@cygnus.com>
To: Kevin Buettner <kevinb@redhat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [RFA] W.I.P. AltiVec ppc registers support.
Date: Mon, 19 Nov 2001 23:55:00 -0000	[thread overview]
Message-ID: <15366.47050.390230.767150@krustylu.cygnus.com> (raw)
Message-ID: <20011119235500.1MG41hJ2AxishZlsE5hgcVlS8z0p1jIh52Rml9_9t08@z> (raw)
In-Reply-To: <1011129220956.ZM19532@ocotillo.lan>

Kevin Buettner writes:
 > On Nov 29,  2:32pm, Kevin Buettner wrote:
 > 
 > > If Elena makes the changes that I have in mind,...
 > > code which affects the interface will collapse down to 5 lines or so. 
 > > Of course, if PTRACE_GETFPXREGS (or the like) ends up being used,
 > > ppc-linux-nat.c need to be substantially rewritten anyway.  But the
 > > point is that the five lines (or so) that I have in mind can then just
 > > be deleted.
 > 
 > It occurred to me that it might help Elena more if I provided a
 > patch with what I had in mind.  See below.  (Completely untested.)

I am not that helpless :-)

Let me wait a bit on this until the ptrace issue is clarified somewhat.

Elena


 > 
 > Anyway, the five lines that I refer to above is this part:
 > 
 > +#ifdef PT_VR0
 > +      u_addr = (PT_VR0 + (regno - gdbarch_tdep (current_gdbarch)->first_altivec_regnum) * 4) * 4;
 > +#else
 > +      u_addr = -1;
 > +#endif
 > 
 > 
 > Index: ppc-linux-nat.c
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/ppc-linux-nat.c,v
 > retrieving revision 1.10
 > diff -u -p -r1.10 ppc-linux-nat.c
 > --- ppc-linux-nat.c	2001/11/20 16:35:24	1.10
 > +++ ppc-linux-nat.c	2001/11/29 22:05:26
 > @@ -32,31 +32,243 @@
 >  #include <sys/wait.h>
 >  #include <fcntl.h>
 >  #include <sys/procfs.h>
 > +#include <sys/ptrace.h>
 >  
 >  /* Prototypes for supply_gregset etc. */
 >  #include "gregset.h"
 > +#include "ppc-tdep.h"
 >  
 > +/* Default the type of the ptrace transfer to int.  */
 > +#ifndef PTRACE_XFER_TYPE
 > +#define PTRACE_XFER_TYPE long
 > +#endif
 > +
 >  int
 >  kernel_u_size (void)
 >  {
 >    return (sizeof (struct user));
 >  }
 > +
 > +/* *INDENT-OFF* */
 > +/* registers layout, as presented by the ptrace interface:
 > +PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
 > +PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
 > +PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
 > +PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
 > +PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
 > +PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
 > +PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
 > +PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
 > +PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ */
 > +/* *INDENT_ON * */
 > +
 > +static int 
 > +ppc_register_u_addr (int regno)
 > +{
 > +  int u_addr = -1;
 > +
 > +  /* General purpose registers occupy 1 slot each in the buffer */
 > +  if (regno >= PPC_GP0_REGNUM && regno <= PPC_GPLAST_REGNUM )
 > +    u_addr = (PT_R0 + regno) * 4;
 > +
 > +  /* Floating point regs: 2 slots each */
 > +  if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM)
 > +    u_addr = (PT_FPR0 + (regno - FP0_REGNUM) * 2) * 4;
 > +
 > +  /* Altivec registers: 4 slots each. */
 > +  if (altivec_register_p (regno))
 > +    {
 > +#ifdef PT_VR0
 > +      u_addr = (PT_VR0 + (regno - gdbarch_tdep (current_gdbarch)->first_altivec_regnum) * 4) * 4;
 > +#else
 > +      u_addr = -1;
 > +#endif
 > +    }
 > +
 > +  /* UISA special purpose registers: 1 slot each */
 > +  if (regno == PC_REGNUM)
 > +    u_addr = PT_NIP * 4;
 > +  if (regno == PPC_LR_REGNUM)
 > +    u_addr = PT_LNK * 4;
 > +  if (regno == PPC_CR_REGNUM)
 > +    u_addr = PT_CCR * 4;
 > +  if (regno == PPC_XER_REGNUM)
 > +    u_addr = PT_XER * 4;
 > +  if (regno == PPC_CTR_REGNUM)
 > +    u_addr = PT_CTR * 4;
 > +  if (regno == PPC_MQ_REGNUM)
 > +    u_addr = PT_MQ * 4;
 > +  if (regno == PPC_PS_REGNUM)
 > +    u_addr = PT_MSR * 4;
 > +
 > +  return u_addr;
 > +}
 > +
 > +static int
 > +ppc_ptrace_cannot_fetch_store_register (int regno)
 > +{
 > +  return (ppc_register_u_addr (regno) == -1);
 > +}
 > +
 > +static void
 > +fetch_register (int regno)
 > +{
 > +  /* This isn't really an address.  But ptrace thinks of it as one.  */
 > +  CORE_ADDR regaddr;
 > +  char mess[128];              /* For messages */
 > +  register int i;
 > +  char buf[MAX_REGISTER_RAW_SIZE];
 > +  int tid;
 > +
 > +  if (ppc_ptrace_cannot_fetch_store_register (regno))
 > +    {
 > +      memset (buf, '\0', REGISTER_RAW_SIZE (regno));   /* Supply zeroes */
 > +      supply_register (regno, buf);
 > +      return;
 > +    }
 > +
 > +  /* Overload thread id onto process id */
 > +  if ((tid = TIDGET (inferior_ptid)) == 0)
 > +    tid = PIDGET (inferior_ptid);      /* no thread id, just use process id */
 > +
 > +  regaddr = ppc_register_u_addr (regno);
 > +  if (regaddr < 0)
 > +    return;
 > +  for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
 > +    {
 > +      errno = 0;
 > +      *(PTRACE_XFER_TYPE *) & buf[i] = ptrace (PTRACE_PEEKUSR, tid,
 > +					       (PTRACE_ARG3_TYPE) regaddr, 0);
 > +      regaddr += sizeof (PTRACE_XFER_TYPE);
 > +      if (errno != 0)
 > +	{
 > +	  sprintf (mess, "reading register %s (#%d)", 
 > +		   REGISTER_NAME (regno), regno);
 > +	  perror_with_name (mess);
 > +	}
 > +    }
 > +  supply_register (regno, buf);
 > +}
 > +
 > +static void 
 > +fetch_ppc_registers (void)
 > +{
 > +  int last_register;
 > +  int i;
 > +
 > +  last_register = PPC_MQ_REGNUM;
 > +  for (i = 0; i <= last_register; i++)
 > +    fetch_register (i);
 > +}
 > +
 > +static void 
 > +fetch_altivec_registers (void)
 > +{
 > +  int i;
 > +
 > +  for (i = 0;
 > +       i < gdbarch_tdep (current_gdbarch)->last_altivec_regnum
 > +	 - gdbarch_tdep (current_gdbarch)->first_altivec_regnum;
 > +       i++)
 > +    fetch_register (gdbarch_tdep (current_gdbarch)->first_altivec_regnum + i);
 > +}
 > +
 > +/* Fetch registers from the child process.  Fetch all registers if
 > +   regno == -1, otherwise fetch all general registers or all floating
 > +   point registers depending upon the value of regno.  */
 > +
 > +void
 > +fetch_inferior_registers (int regno)
 > +{
 > +  if (regno == -1)
 > +    {
 > +      fetch_ppc_registers ();
 > +      fetch_altivec_registers ();
 > +    }
 > +  else 
 > +    {
 > +      if (altivec_register_p (regno))
 > +	fetch_altivec_register (regno);
 > +      else
 > +	fetch_register (regno);
 > +    }
 > +}
 > +
 > +/* Store one register. */
 > +static void
 > +store_register (int regno)
 > +{
 > +  /* This isn't really an address.  But ptrace thinks of it as one.  */
 > +  CORE_ADDR regaddr;
 > +  char mess[128];              /* For messages */
 > +  register int i;
 > +  int tid;
 > +  char *buf = alloca (MAX_REGISTER_RAW_SIZE);
 > +
 > +  if (ppc_ptrace_cannot_fetch_store_register (regno))
 > +    {
 > +      return;
 > +    }
 > +
 > +  /* Overload thread id onto process id */
 > +  if ((tid = TIDGET (inferior_ptid)) == 0)
 > +    tid = PIDGET (inferior_ptid);      /* no thread id, just use process id */
 > +
 > +  regaddr = ppc_register_u_addr (regno);
 > +  regcache_collect (regno, buf);
 > +  for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (PTRACE_XFER_TYPE))
 > +    {
 > +      errno = 0;
 > +      ptrace (PTRACE_POKEUSR, tid, (PTRACE_ARG3_TYPE) regaddr,
 > +	      *(PTRACE_XFER_TYPE *) & buf[i]);
 > +      regaddr += sizeof (PTRACE_XFER_TYPE);
 > +      if (errno != 0)
 > +	{
 > +	  sprintf (mess, "writing register %s (#%d)", 
 > +		   REGISTER_NAME (regno), regno);
 > +	  perror_with_name (mess);
 > +	}
 > +    }
 > +}
 > +
 > +static void
 > +store_ppc_registers (void)
 > +{
 > +  int last_register;
 > +  int i;
 > +
 > +  last_register = PPC_MQ_REGNUM;
 > +  for (i = 0; i <= last_register; i++)
 > +    store_register (i);
 > +}
 > +
 > +static void
 > +store_altivec_registers (void)
 > +{
 > +  int i;
 >  
 > -static int regmap[] =
 > -{PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5, PT_R6, PT_R7,
 > - PT_R8, PT_R9, PT_R10, PT_R11, PT_R12, PT_R13, PT_R14, PT_R15,
 > - PT_R16, PT_R17, PT_R18, PT_R19, PT_R20, PT_R21, PT_R22, PT_R23,
 > - PT_R24, PT_R25, PT_R26, PT_R27, PT_R28, PT_R29, PT_R30, PT_R31,
 > - PT_FPR0, PT_FPR0 + 2, PT_FPR0 + 4, PT_FPR0 + 6, PT_FPR0 + 8, PT_FPR0 + 10, PT_FPR0 + 12, PT_FPR0 + 14,
 > - PT_FPR0 + 16, PT_FPR0 + 18, PT_FPR0 + 20, PT_FPR0 + 22, PT_FPR0 + 24, PT_FPR0 + 26, PT_FPR0 + 28, PT_FPR0 + 30,
 > - PT_FPR0 + 32, PT_FPR0 + 34, PT_FPR0 + 36, PT_FPR0 + 38, PT_FPR0 + 40, PT_FPR0 + 42, PT_FPR0 + 44, PT_FPR0 + 46,
 > - PT_FPR0 + 48, PT_FPR0 + 50, PT_FPR0 + 52, PT_FPR0 + 54, PT_FPR0 + 56, PT_FPR0 + 58, PT_FPR0 + 60, PT_FPR0 + 62,
 > - PT_NIP, PT_MSR, PT_CCR, PT_LNK, PT_CTR, PT_XER, PT_MQ};
 > +  for (i = 0; 
 > +       i < gdbarch_tdep (current_gdbarch)->last_altivec_regnum 
 > +	 - gdbarch_tdep (current_gdbarch)->first_altivec_regnum; 
 > +       i++)
 > +    store_register (gdbarch_tdep (current_gdbarch)->first_altivec_regnum + i);
 > +}
 >  
 > -int 
 > -ppc_register_u_addr (int ustart, int regnum)
 > +void
 > +store_inferior_registers (int regno)
 >  {
 > -  return (ustart + 4 * regmap[regnum]);
 > +  if (regno >= 0)
 > +    {
 > +      if (altivec_register_p (regno))
 > +        store_altivec_register (regno);
 > +      else
 > +        store_register (regno);
 > +    }
 > +  else
 > +    {
 > +      store_ppc_registers ();
 > +      store_altivec_registers ();
 > +    }
 >  }
 >  
 >  void
 > @@ -68,8 +280,13 @@ supply_gregset (gdb_gregset_t *gregsetp)
 >    for (regi = 0; regi < 32; regi++)
 >      supply_register (regi, (char *) (regp + regi));
 >  
 > -  for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++)
 > -    supply_register (regi, (char *) (regp + regmap[regi]));
 > +  supply_register (PC_REGNUM, (char *) (regp + PT_NIP));
 > +  supply_register (PPC_LR_REGNUM, (char *) (regp + PT_LNK));
 > +  supply_register (PPC_CR_REGNUM, (char *) (regp + PT_CCR));
 > +  supply_register (PPC_XER_REGNUM, (char *) (regp + PT_XER));
 > +  supply_register (PPC_CTR_REGNUM, (char *) (regp + PT_CTR));
 > +  supply_register (PPC_MQ_REGNUM, (char *) (regp + PT_MQ));
 > +  supply_register (PPC_PS_REGNUM, (char *) (regp + PT_MSR));
 >  }
 >  
 >  void
 > @@ -78,19 +295,26 @@ fill_gregset (gdb_gregset_t *gregsetp, i
 >    int regi;
 >    elf_greg_t *regp = (elf_greg_t *) gregsetp;
 >  
 > -#define COPY_REG(_idx_,_regi_) \
 > -  if ((regno == -1) || regno == _regi_) \
 > -    regcache_collect (_regi_, regp + _idx_)
 > -
 >    for (regi = 0; regi < 32; regi++)
 >      {
 > -      COPY_REG (regmap[regi], regi);
 > +      if ((regno == -1) || regno == regi)
 > +        regcache_collect (regi, regp + PT_R0 + regi);
 >      }
 >  
 > -  for (regi = FIRST_UISA_SP_REGNUM; regi <= LAST_UISA_SP_REGNUM; regi++)
 > -    {
 > -      COPY_REG (regmap[regi], regi);
 > -    }
 > +  if ((regno == -1) || regno == PC_REGNUM)
 > +    regcache_collect (PC_REGNUM, regp + PT_NIP);
 > +  if ((regno == -1) || regno == PPC_LR_REGNUM)
 > +    regcache_collect (PPC_LR_REGNUM, regp + PT_LNK);
 > +  if ((regno == -1) || regno == PPC_CR_REGNUM)
 > +    regcache_collect (PPC_CR_REGNUM, regp + PT_CCR);
 > +  if ((regno == -1) || regno == PPC_XER_REGNUM)
 > +    regcache_collect (PPC_XER_REGNUM, regp + PT_XER);
 > +  if ((regno == -1) || regno == PPC_CTR_REGNUM)
 > +    regcache_collect (PPC_CTR_REGNUM, regp + PT_CTR);
 > +  if ((regno == -1) || regno == PPC_MQ_REGNUM)
 > +    regcache_collect (PPC_MQ_REGNUM, regp + PT_MQ);
 > +  if ((regno == -1) || regno == PPC_PS_REGNUM)
 > +    regcache_collect (PPC_PS_REGNUM, regp + PT_MSR);
 >  }
 >  
 >  void
 > Index: config/powerpc/nm-linux.h
 > ===================================================================
 > RCS file: /cvs/src/src/gdb/config/powerpc/nm-linux.h,v
 > retrieving revision 1.9
 > diff -u -p -r1.9 nm-linux.h
 > --- nm-linux.h	2001/11/20 16:36:44	1.9
 > +++ nm-linux.h	2001/11/29 22:05:32
 > @@ -23,15 +23,6 @@ Foundation, Inc., 675 Mass Ave, Cambridg
 >  
 >  #define NM_LINUX_H
 >  
 > -/* Return sizeof user struct to callers in less machine dependent routines */
 > -
 > -#define KERNEL_U_SIZE kernel_u_size()
 > -extern int kernel_u_size (void);
 > -
 > -#define U_REGS_OFFSET 0
 > -
 > -extern int ppc_register_u_addr (int, int);
 > -#define REGISTER_U_ADDR(addr, blockend, regno) \
 > -        (addr) = ppc_register_u_addr ((blockend),(regno));
 > +#define FETCH_INFERIOR_REGISTERS
 >  
 >  #endif /* #ifndef NM_LINUX_H */


  parent reply	other threads:[~2001-11-29 14:27 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-28 18:09 Elena Zannoni
2001-11-18 13:27 ` Elena Zannoni
2001-11-18 14:11 ` Daniel Jacobowitz
2001-11-19 12:59   ` Andrew Cagney
2001-11-29  9:04     ` Andrew Cagney
2001-11-29 13:10     ` Daniel Jacobowitz
2001-11-19 16:00       ` Daniel Jacobowitz
2001-11-29 13:34       ` Kevin Buettner
2001-11-19 16:42         ` Kevin Buettner
2001-11-29 14:11         ` Kevin Buettner
2001-11-19 22:22           ` Kevin Buettner
2001-11-29 14:27           ` Elena Zannoni [this message]
2001-11-19 23:55             ` Elena Zannoni
2001-11-28 22:27   ` Daniel Jacobowitz
2001-12-02 10:28   ` Elena Zannoni
2001-12-02 12:19     ` Andrew Cagney
2001-12-02 14:59     ` Daniel Jacobowitz
2001-12-02 22:25       ` Andrew Cagney
2001-11-28 18:33 ` Daniel Jacobowitz
2001-11-18 13:40   ` Daniel Jacobowitz
2001-11-29 10:40 ` Kevin Buettner
2001-11-19 15:15   ` Kevin Buettner
2001-11-19 18:51   ` Elena Zannoni
2001-11-29 13:53     ` Elena Zannoni
2001-11-29 14:21     ` Kevin Buettner
2001-11-19 22:53       ` Kevin Buettner
2001-11-29 14:42       ` Elena Zannoni
2001-11-20  8:37         ` Elena Zannoni
2001-11-29 15:03         ` Andrew Cagney
2001-11-20  8:54           ` Andrew Cagney
2001-11-29 16:27           ` Kevin Buettner
2001-11-20 16:00             ` Kevin Buettner
2001-11-20 16:14             ` Andrew Cagney
2001-11-21  3:33               ` Daniel Jacobowitz
2001-11-29 17:41                 ` Daniel Jacobowitz
2001-11-29 16:43               ` Andrew Cagney
2001-11-29 16:36             ` Elena Zannoni
2001-11-20 16:10               ` Elena Zannoni
2001-11-29 17:40               ` Daniel Jacobowitz
2001-11-20 18:00                 ` Daniel Jacobowitz
2001-11-29 14:47       ` Daniel Jacobowitz
2001-11-20  8:37         ` Daniel Jacobowitz
2001-11-20  9:07         ` Kevin Buettner
2001-11-20  9:08           ` Andrew Cagney
2001-11-29 15:33             ` Andrew Cagney
2001-11-29 15:15           ` Kevin Buettner
2001-11-29 15:38           ` Daniel Jacobowitz
2001-11-20  9:13             ` Daniel Jacobowitz
2001-11-20 10:09             ` Kevin Buettner
2001-11-29 15:47               ` Kevin Buettner
2001-11-29 15:58               ` Andrew Cagney
2001-11-20 10:59                 ` Andrew Cagney
2001-11-29 15:59               ` Daniel Jacobowitz
2001-11-20 11:07                 ` Daniel Jacobowitz
2001-11-29 16:17                 ` Andrew Cagney
2001-11-20 11:17                   ` Andrew Cagney
2001-11-20 17:52                   ` Daniel Jacobowitz
2001-11-29 17:39                     ` Daniel Jacobowitz
2001-11-29 18:20                     ` Andrew Cagney
2001-11-21  4:10                       ` Andrew Cagney
2001-11-29 22:36                       ` Daniel Jacobowitz
2001-11-21  5:56                         ` Daniel Jacobowitz
2001-12-20 10:02         ` Elena Zannoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15366.47050.390230.767150@krustylu.cygnus.com \
    --to=ezannoni@cygnus.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=kevinb@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox