gdb/spu-linux-nat.c - gdb

Functions defined

Macros defined

Source code

  1. /* SPU native-dependent code for GDB, the GNU debugger.
  2.    Copyright (C) 2006-2015 Free Software Foundation, Inc.

  3.    Contributed by Ulrich Weigand <uweigand@de.ibm.com>.

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. #include "defs.h"
  16. #include "gdbcore.h"
  17. #include "target.h"
  18. #include "inferior.h"
  19. #include "inf-child.h"
  20. #include "inf-ptrace.h"
  21. #include "regcache.h"
  22. #include "symfile.h"
  23. #include "gdb_wait.h"
  24. #include "gdbthread.h"
  25. #include "gdb_bfd.h"

  26. #include <sys/ptrace.h>
  27. #include <asm/ptrace.h>
  28. #include <sys/types.h>

  29. #include "spu-tdep.h"

  30. /* PPU side system calls.  */
  31. #define INSTR_SC        0x44000002
  32. #define NR_spu_run        0x0116


  33. /* Fetch PPU register REGNO.  */
  34. static ULONGEST
  35. fetch_ppc_register (int regno)
  36. {
  37.   PTRACE_TYPE_RET res;

  38.   int tid = ptid_get_lwp (inferior_ptid);
  39.   if (tid == 0)
  40.     tid = ptid_get_pid (inferior_ptid);

  41. #ifndef __powerpc64__
  42.   /* If running as a 32-bit process on a 64-bit system, we attempt
  43.      to get the full 64-bit register content of the target process.
  44.      If the PPC special ptrace call fails, we're on a 32-bit system;
  45.      just fall through to the regular ptrace call in that case.  */
  46.   {
  47.     gdb_byte buf[8];

  48.     errno = 0;
  49.     ptrace (PPC_PTRACE_PEEKUSR_3264, tid,
  50.             (PTRACE_TYPE_ARG3) (regno * 8), buf);
  51.     if (errno == 0)
  52.       ptrace (PPC_PTRACE_PEEKUSR_3264, tid,
  53.               (PTRACE_TYPE_ARG3) (regno * 8 + 4), buf + 4);
  54.     if (errno == 0)
  55.       return (ULONGEST) *(uint64_t *)buf;
  56.   }
  57. #endif

  58.   errno = 0;
  59.   res = ptrace (PT_READ_U, tid,
  60.                  (PTRACE_TYPE_ARG3) (regno * sizeof (PTRACE_TYPE_RET)), 0);
  61.   if (errno != 0)
  62.     {
  63.       char mess[128];
  64.       xsnprintf (mess, sizeof mess, "reading PPC register #%d", regno);
  65.       perror_with_name (_(mess));
  66.     }

  67.   return (ULONGEST) (unsigned long) res;
  68. }

  69. /* Fetch WORD from PPU memory at (aligned) MEMADDR in thread TID.  */
  70. static int
  71. fetch_ppc_memory_1 (int tid, ULONGEST memaddr, PTRACE_TYPE_RET *word)
  72. {
  73.   errno = 0;

  74. #ifndef __powerpc64__
  75.   if (memaddr >> 32)
  76.     {
  77.       uint64_t addr_8 = (uint64_t) memaddr;
  78.       ptrace (PPC_PTRACE_PEEKTEXT_3264, tid, (PTRACE_TYPE_ARG3) &addr_8, word);
  79.     }
  80.   else
  81. #endif
  82.     *word = ptrace (PT_READ_I, tid, (PTRACE_TYPE_ARG3) (size_t) memaddr, 0);

  83.   return errno;
  84. }

  85. /* Store WORD into PPU memory at (aligned) MEMADDR in thread TID.  */
  86. static int
  87. store_ppc_memory_1 (int tid, ULONGEST memaddr, PTRACE_TYPE_RET word)
  88. {
  89.   errno = 0;

  90. #ifndef __powerpc64__
  91.   if (memaddr >> 32)
  92.     {
  93.       uint64_t addr_8 = (uint64_t) memaddr;
  94.       ptrace (PPC_PTRACE_POKEDATA_3264, tid, (PTRACE_TYPE_ARG3) &addr_8, word);
  95.     }
  96.   else
  97. #endif
  98.     ptrace (PT_WRITE_D, tid, (PTRACE_TYPE_ARG3) (size_t) memaddr, word);

  99.   return errno;
  100. }

  101. /* Fetch LEN bytes of PPU memory at MEMADDR to MYADDR.  */
  102. static int
  103. fetch_ppc_memory (ULONGEST memaddr, gdb_byte *myaddr, int len)
  104. {
  105.   int i, ret;

  106.   ULONGEST addr = memaddr & -(ULONGEST) sizeof (PTRACE_TYPE_RET);
  107.   int count = ((((memaddr + len) - addr) + sizeof (PTRACE_TYPE_RET) - 1)
  108.                / sizeof (PTRACE_TYPE_RET));
  109.   PTRACE_TYPE_RET *buffer;

  110.   int tid = ptid_get_lwp (inferior_ptid);
  111.   if (tid == 0)
  112.     tid = ptid_get_pid (inferior_ptid);

  113.   buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
  114.   for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
  115.     {
  116.       ret = fetch_ppc_memory_1 (tid, addr, &buffer[i]);
  117.       if (ret)
  118.         return ret;
  119.     }

  120.   memcpy (myaddr,
  121.           (char *) buffer + (memaddr & (sizeof (PTRACE_TYPE_RET) - 1)),
  122.           len);

  123.   return 0;
  124. }

  125. /* Store LEN bytes from MYADDR to PPU memory at MEMADDR.  */
  126. static int
  127. store_ppc_memory (ULONGEST memaddr, const gdb_byte *myaddr, int len)
  128. {
  129.   int i, ret;

  130.   ULONGEST addr = memaddr & -(ULONGEST) sizeof (PTRACE_TYPE_RET);
  131.   int count = ((((memaddr + len) - addr) + sizeof (PTRACE_TYPE_RET) - 1)
  132.                / sizeof (PTRACE_TYPE_RET));
  133.   PTRACE_TYPE_RET *buffer;

  134.   int tid = ptid_get_lwp (inferior_ptid);
  135.   if (tid == 0)
  136.     tid = ptid_get_pid (inferior_ptid);

  137.   buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));

  138.   if (addr != memaddr || len < (int) sizeof (PTRACE_TYPE_RET))
  139.     {
  140.       ret = fetch_ppc_memory_1 (tid, addr, &buffer[0]);
  141.       if (ret)
  142.         return ret;
  143.     }

  144.   if (count > 1)
  145.     {
  146.       ret = fetch_ppc_memory_1 (tid, addr + (count - 1)
  147.                                                * sizeof (PTRACE_TYPE_RET),
  148.                                 &buffer[count - 1]);
  149.       if (ret)
  150.         return ret;
  151.     }

  152.   memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_TYPE_RET) - 1)),
  153.           myaddr, len);

  154.   for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
  155.     {
  156.       ret = store_ppc_memory_1 (tid, addr, buffer[i]);
  157.       if (ret)
  158.         return ret;
  159.     }

  160.   return 0;
  161. }


  162. /* If the PPU thread is currently stopped on a spu_run system call,
  163.    return to FD and ADDR the file handle and NPC parameter address
  164.    used with the system call.  Return non-zero if successful.  */
  165. static int
  166. parse_spufs_run (int *fd, ULONGEST *addr)
  167. {
  168.   enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
  169.   gdb_byte buf[4];
  170.   ULONGEST pc = fetch_ppc_register (32);  /* nip */

  171.   /* Fetch instruction preceding current NIP.  */
  172.   if (fetch_ppc_memory (pc-4, buf, 4) != 0)
  173.     return 0;
  174.   /* It should be a "sc" instruction.  */
  175.   if (extract_unsigned_integer (buf, 4, byte_order) != INSTR_SC)
  176.     return 0;
  177.   /* System call number should be NR_spu_run.  */
  178.   if (fetch_ppc_register (0) != NR_spu_run)
  179.     return 0;

  180.   /* Register 3 contains fd, register 4 the NPC param pointer.  */
  181.   *fd = fetch_ppc_register (34);  /* orig_gpr3 */
  182.   *addr = fetch_ppc_register (4);
  183.   return 1;
  184. }


  185. /* Implement the to_xfer_partial target_ops method for TARGET_OBJECT_SPU.
  186.    Copy LEN bytes at OFFSET in spufs file ANNEX into/from READBUF or WRITEBUF,
  187.    using the /proc file system.  */

  188. static enum target_xfer_status
  189. spu_proc_xfer_spu (const char *annex, gdb_byte *readbuf,
  190.                    const gdb_byte *writebuf,
  191.                    ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
  192. {
  193.   char buf[128];
  194.   int fd = 0;
  195.   int ret = -1;
  196.   int pid = ptid_get_pid (inferior_ptid);

  197.   if (!annex)
  198.     return TARGET_XFER_EOF;

  199.   xsnprintf (buf, sizeof buf, "/proc/%d/fd/%s", pid, annex);
  200.   fd = open (buf, writebuf? O_WRONLY : O_RDONLY);
  201.   if (fd <= 0)
  202.     return TARGET_XFER_E_IO;

  203.   if (offset != 0
  204.       && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
  205.     {
  206.       close (fd);
  207.       return TARGET_XFER_EOF;
  208.     }

  209.   if (writebuf)
  210.     ret = write (fd, writebuf, (size_t) len);
  211.   else if (readbuf)
  212.     ret = read (fd, readbuf, (size_t) len);

  213.   close (fd);
  214.   if (ret < 0)
  215.     return TARGET_XFER_E_IO;
  216.   else if (ret == 0)
  217.     return TARGET_XFER_EOF;
  218.   else
  219.     {
  220.       *xfered_len = (ULONGEST) ret;
  221.       return TARGET_XFER_OK;
  222.     }
  223. }


  224. /* Inferior memory should contain an SPE executable image at location ADDR.
  225.    Allocate a BFD representing that executable.  Return NULL on error.  */

  226. static void *
  227. spu_bfd_iovec_open (struct bfd *nbfd, void *open_closure)
  228. {
  229.   return open_closure;
  230. }

  231. static int
  232. spu_bfd_iovec_close (struct bfd *nbfd, void *stream)
  233. {
  234.   xfree (stream);

  235.   /* Zero means success.  */
  236.   return 0;
  237. }

  238. static file_ptr
  239. spu_bfd_iovec_pread (struct bfd *abfd, void *stream, void *buf,
  240.                      file_ptr nbytes, file_ptr offset)
  241. {
  242.   ULONGEST addr = *(ULONGEST *)stream;

  243.   if (fetch_ppc_memory (addr + offset, buf, nbytes) != 0)
  244.     {
  245.       bfd_set_error (bfd_error_invalid_operation);
  246.       return -1;
  247.     }

  248.   return nbytes;
  249. }

  250. static int
  251. spu_bfd_iovec_stat (struct bfd *abfd, void *stream, struct stat *sb)
  252. {
  253.   /* We don't have an easy way of finding the size of embedded spu
  254.      images.  We could parse the in-memory ELF header and section
  255.      table to find the extent of the last section but that seems
  256.      pointless when the size is needed only for checks of other
  257.      parsed values in dbxread.c.  */
  258.   sb->st_size = INT_MAX;
  259.   return 0;
  260. }

  261. static bfd *
  262. spu_bfd_open (ULONGEST addr)
  263. {
  264.   struct bfd *nbfd;
  265.   asection *spu_name;

  266.   ULONGEST *open_closure = xmalloc (sizeof (ULONGEST));
  267.   *open_closure = addr;

  268.   nbfd = gdb_bfd_openr_iovec ("<in-memory>", "elf32-spu",
  269.                               spu_bfd_iovec_open, open_closure,
  270.                               spu_bfd_iovec_pread, spu_bfd_iovec_close,
  271.                               spu_bfd_iovec_stat);
  272.   if (!nbfd)
  273.     return NULL;

  274.   if (!bfd_check_format (nbfd, bfd_object))
  275.     {
  276.       gdb_bfd_unref (nbfd);
  277.       return NULL;
  278.     }

  279.   /* Retrieve SPU name note and update BFD name.  */
  280.   spu_name = bfd_get_section_by_name (nbfd, ".note.spu_name");
  281.   if (spu_name)
  282.     {
  283.       int sect_size = bfd_section_size (nbfd, spu_name);
  284.       if (sect_size > 20)
  285.         {
  286.           char *buf = alloca (sect_size - 20 + 1);
  287.           bfd_get_section_contents (nbfd, spu_name, buf, 20, sect_size - 20);
  288.           buf[sect_size - 20] = '\0';

  289.           xfree ((char *)nbfd->filename);
  290.           nbfd->filename = xstrdup (buf);
  291.         }
  292.     }

  293.   return nbfd;
  294. }

  295. /* INFERIOR_FD is a file handle passed by the inferior to the
  296.    spu_run system call.  Assuming the SPE context was allocated
  297.    by the libspe library, try to retrieve the main SPE executable
  298.    file from its copy within the target process.  */
  299. static void
  300. spu_symbol_file_add_from_memory (int inferior_fd)
  301. {
  302.   ULONGEST addr;
  303.   struct bfd *nbfd;

  304.   gdb_byte id[128];
  305.   char annex[32];
  306.   ULONGEST len;
  307.   enum target_xfer_status status;

  308.   /* Read object ID.  */
  309.   xsnprintf (annex, sizeof annex, "%d/object-id", inferior_fd);
  310.   status = spu_proc_xfer_spu (annex, id, NULL, 0, sizeof id, &len);
  311.   if (status != TARGET_XFER_OK || len >= sizeof id)
  312.     return;
  313.   id[len] = 0;
  314.   addr = strtoulst ((const char *) id, NULL, 16);
  315.   if (!addr)
  316.     return;

  317.   /* Open BFD representing SPE executable and read its symbols.  */
  318.   nbfd = spu_bfd_open (addr);
  319.   if (nbfd)
  320.     {
  321.       struct cleanup *cleanup = make_cleanup_bfd_unref (nbfd);

  322.       symbol_file_add_from_bfd (nbfd, bfd_get_filename (nbfd),
  323.                                 SYMFILE_VERBOSE | SYMFILE_MAINLINE,
  324.                                 NULL, 0, NULL);
  325.       do_cleanups (cleanup);
  326.     }
  327. }


  328. /* Override the post_startup_inferior routine to continue running
  329.    the inferior until the first spu_run system call.  */
  330. static void
  331. spu_child_post_startup_inferior (struct target_ops *self, ptid_t ptid)
  332. {
  333.   int fd;
  334.   ULONGEST addr;

  335.   int tid = ptid_get_lwp (ptid);
  336.   if (tid == 0)
  337.     tid = ptid_get_pid (ptid);

  338.   while (!parse_spufs_run (&fd, &addr))
  339.     {
  340.       ptrace (PT_SYSCALL, tid, (PTRACE_TYPE_ARG3) 0, 0);
  341.       waitpid (tid, NULL, __WALL | __WNOTHREAD);
  342.     }
  343. }

  344. /* Override the post_attach routine to try load the SPE executable
  345.    file image from its copy inside the target process.  */
  346. static void
  347. spu_child_post_attach (struct target_ops *self, int pid)
  348. {
  349.   int fd;
  350.   ULONGEST addr;

  351.   /* Like child_post_startup_inferior, if we happened to attach to
  352.      the inferior while it wasn't currently in spu_run, continue
  353.      running it until we get back there.  */
  354.   while (!parse_spufs_run (&fd, &addr))
  355.     {
  356.       ptrace (PT_SYSCALL, pid, (PTRACE_TYPE_ARG3) 0, 0);
  357.       waitpid (pid, NULL, __WALL | __WNOTHREAD);
  358.     }

  359.   /* If the user has not provided an executable file, try to extract
  360.      the image from inside the target process.  */
  361.   if (!get_exec_file (0))
  362.     spu_symbol_file_add_from_memory (fd);
  363. }

  364. /* Wait for child PTID to do something.  Return id of the child,
  365.    minus_one_ptid in case of error; store status into *OURSTATUS.  */
  366. static ptid_t
  367. spu_child_wait (struct target_ops *ops,
  368.                 ptid_t ptid, struct target_waitstatus *ourstatus, int options)
  369. {
  370.   int save_errno;
  371.   int status;
  372.   pid_t pid;

  373.   do
  374.     {
  375.       set_sigint_trap ();        /* Causes SIGINT to be passed on to the
  376.                                    attached process.  */

  377.       pid = waitpid (ptid_get_pid (ptid), &status, 0);
  378.       if (pid == -1 && errno == ECHILD)
  379.         /* Try again with __WCLONE to check cloned processes.  */
  380.         pid = waitpid (ptid_get_pid (ptid), &status, __WCLONE);

  381.       save_errno = errno;

  382.       /* Make sure we don't report an event for the exit of the
  383.          original program, if we've detached from it.  */
  384.       if (pid != -1 && !WIFSTOPPED (status)
  385.           && pid != ptid_get_pid (inferior_ptid))
  386.         {
  387.           pid = -1;
  388.           save_errno = EINTR;
  389.         }

  390.       clear_sigint_trap ();
  391.     }
  392.   while (pid == -1 && save_errno == EINTR);

  393.   if (pid == -1)
  394.     {
  395.       warning (_("Child process unexpectedly missing: %s"),
  396.                safe_strerror (save_errno));

  397.       /* Claim it exited with unknown signal.  */
  398.       ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
  399.       ourstatus->value.sig = GDB_SIGNAL_UNKNOWN;
  400.       return inferior_ptid;
  401.     }

  402.   store_waitstatus (ourstatus, status);
  403.   return pid_to_ptid (pid);
  404. }

  405. /* Override the fetch_inferior_register routine.  */
  406. static void
  407. spu_fetch_inferior_registers (struct target_ops *ops,
  408.                               struct regcache *regcache, int regno)
  409. {
  410.   int fd;
  411.   ULONGEST addr;

  412.   /* We must be stopped on a spu_run system call.  */
  413.   if (!parse_spufs_run (&fd, &addr))
  414.     return;

  415.   /* The ID register holds the spufs file handle.  */
  416.   if (regno == -1 || regno == SPU_ID_REGNUM)
  417.     {
  418.       struct gdbarch *gdbarch = get_regcache_arch (regcache);
  419.       enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  420.       gdb_byte buf[4];
  421.       store_unsigned_integer (buf, 4, byte_order, fd);
  422.       regcache_raw_supply (regcache, SPU_ID_REGNUM, buf);
  423.     }

  424.   /* The NPC register is found at ADDR.  */
  425.   if (regno == -1 || regno == SPU_PC_REGNUM)
  426.     {
  427.       gdb_byte buf[4];
  428.       if (fetch_ppc_memory (addr, buf, 4) == 0)
  429.         regcache_raw_supply (regcache, SPU_PC_REGNUM, buf);
  430.     }

  431.   /* The GPRs are found in the "regs" spufs file.  */
  432.   if (regno == -1 || (regno >= 0 && regno < SPU_NUM_GPRS))
  433.     {
  434.       gdb_byte buf[16 * SPU_NUM_GPRS];
  435.       char annex[32];
  436.       int i;
  437.       ULONGEST len;

  438.       xsnprintf (annex, sizeof annex, "%d/regs", fd);
  439.       if ((spu_proc_xfer_spu (annex, buf, NULL, 0, sizeof buf, &len)
  440.            == TARGET_XFER_OK)
  441.           && len == sizeof buf)
  442.         for (i = 0; i < SPU_NUM_GPRS; i++)
  443.           regcache_raw_supply (regcache, i, buf + i*16);
  444.     }
  445. }

  446. /* Override the store_inferior_register routine.  */
  447. static void
  448. spu_store_inferior_registers (struct target_ops *ops,
  449.                               struct regcache *regcache, int regno)
  450. {
  451.   int fd;
  452.   ULONGEST addr;

  453.   /* We must be stopped on a spu_run system call.  */
  454.   if (!parse_spufs_run (&fd, &addr))
  455.     return;

  456.   /* The NPC register is found at ADDR.  */
  457.   if (regno == -1 || regno == SPU_PC_REGNUM)
  458.     {
  459.       gdb_byte buf[4];
  460.       regcache_raw_collect (regcache, SPU_PC_REGNUM, buf);
  461.       store_ppc_memory (addr, buf, 4);
  462.     }

  463.   /* The GPRs are found in the "regs" spufs file.  */
  464.   if (regno == -1 || (regno >= 0 && regno < SPU_NUM_GPRS))
  465.     {
  466.       gdb_byte buf[16 * SPU_NUM_GPRS];
  467.       char annex[32];
  468.       int i;
  469.       ULONGEST len;

  470.       for (i = 0; i < SPU_NUM_GPRS; i++)
  471.         regcache_raw_collect (regcache, i, buf + i*16);

  472.       xsnprintf (annex, sizeof annex, "%d/regs", fd);
  473.       spu_proc_xfer_spu (annex, NULL, buf, 0, sizeof buf, &len);
  474.     }
  475. }

  476. /* Override the to_xfer_partial routine.  */
  477. static enum target_xfer_status
  478. spu_xfer_partial (struct target_ops *ops,
  479.                   enum target_object object, const char *annex,
  480.                   gdb_byte *readbuf, const gdb_byte *writebuf,
  481.                   ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
  482. {
  483.   if (object == TARGET_OBJECT_SPU)
  484.     return spu_proc_xfer_spu (annex, readbuf, writebuf, offset, len,
  485.                               xfered_len);

  486.   if (object == TARGET_OBJECT_MEMORY)
  487.     {
  488.       int fd;
  489.       ULONGEST addr;
  490.       char mem_annex[32], lslr_annex[32];
  491.       gdb_byte buf[32];
  492.       ULONGEST lslr;
  493.       enum target_xfer_status ret;

  494.       /* We must be stopped on a spu_run system call.  */
  495.       if (!parse_spufs_run (&fd, &addr))
  496.         return TARGET_XFER_EOF;

  497.       /* Use the "mem" spufs file to access SPU local store.  */
  498.       xsnprintf (mem_annex, sizeof mem_annex, "%d/mem", fd);
  499.       ret = spu_proc_xfer_spu (mem_annex, readbuf, writebuf, offset, len,
  500.                                xfered_len);
  501.       if (ret == TARGET_XFER_OK)
  502.         return ret;

  503.       /* SPU local store access wraps the address around at the
  504.          local store limit.  We emulate this here.  To avoid needing
  505.          an extra access to retrieve the LSLR, we only do that after
  506.          trying the original address first, and getting end-of-file.  */
  507.       xsnprintf (lslr_annex, sizeof lslr_annex, "%d/lslr", fd);
  508.       memset (buf, 0, sizeof buf);
  509.       if (spu_proc_xfer_spu (lslr_annex, buf, NULL, 0, sizeof buf, xfered_len)
  510.           != TARGET_XFER_OK)
  511.         return ret;

  512.       lslr = strtoulst ((const char *) buf, NULL, 16);
  513.       return spu_proc_xfer_spu (mem_annex, readbuf, writebuf,
  514.                                 offset & lslr, len, xfered_len);
  515.     }

  516.   return TARGET_XFER_E_IO;
  517. }

  518. /* Override the to_can_use_hw_breakpoint routine.  */
  519. static int
  520. spu_can_use_hw_breakpoint (struct target_ops *self,
  521.                            int type, int cnt, int othertype)
  522. {
  523.   return 0;
  524. }

  525. /* -Wmissing-prototypes */
  526. extern initialize_file_ftype _initialize_spu_nat;

  527. /* Initialize SPU native target.  */
  528. void
  529. _initialize_spu_nat (void)
  530. {
  531.   /* Generic ptrace methods.  */
  532.   struct target_ops *t;
  533.   t = inf_ptrace_target ();

  534.   /* Add SPU methods.  */
  535.   t->to_post_attach = spu_child_post_attach;
  536.   t->to_post_startup_inferior = spu_child_post_startup_inferior;
  537.   t->to_wait = spu_child_wait;
  538.   t->to_fetch_registers = spu_fetch_inferior_registers;
  539.   t->to_store_registers = spu_store_inferior_registers;
  540.   t->to_xfer_partial = spu_xfer_partial;
  541.   t->to_can_use_hw_breakpoint = spu_can_use_hw_breakpoint;

  542.   /* Register SPU target.  */
  543.   add_target (t);
  544. }