/* SPU native-dependent code for GDB, the GNU debugger.
- Copyright (C) 2006-2012 Free Software Foundation, Inc.
+ Copyright (C) 2006-2014 Free Software Foundation, Inc.
Contributed by Ulrich Weigand <uweigand@de.ibm.com>.
#include "defs.h"
#include "gdbcore.h"
-#include "gdb_string.h"
+#include <string.h>
#include "target.h"
#include "inferior.h"
+#include "inf-child.h"
#include "inf-ptrace.h"
#include "regcache.h"
#include "symfile.h"
#include "gdb_wait.h"
#include "gdbthread.h"
+#include "gdb_bfd.h"
#include <sys/ptrace.h>
#include <asm/ptrace.h>
#include <sys/types.h>
-#include <sys/param.h>
#include "spu-tdep.h"
{
PTRACE_TYPE_RET res;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
#ifndef __powerpc64__
/* If running as a 32-bit process on a 64-bit system, we attempt
/ sizeof (PTRACE_TYPE_RET));
PTRACE_TYPE_RET *buffer;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
/ sizeof (PTRACE_TYPE_RET));
PTRACE_TYPE_RET *buffer;
- int tid = TIDGET (inferior_ptid);
+ int tid = ptid_get_lwp (inferior_ptid);
if (tid == 0)
- tid = PIDGET (inferior_ptid);
+ tid = ptid_get_pid (inferior_ptid);
buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
static int
parse_spufs_run (int *fd, ULONGEST *addr)
{
- enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch ());
gdb_byte buf[4];
ULONGEST pc = fetch_ppc_register (32); /* nip */
char buf[128];
int fd = 0;
int ret = -1;
- int pid = PIDGET (inferior_ptid);
+ int pid = ptid_get_pid (inferior_ptid);
if (!annex)
return 0;
spu_bfd_iovec_close (struct bfd *nbfd, void *stream)
{
xfree (stream);
- return 1;
+
+ /* Zero means success. */
+ return 0;
}
static file_ptr
ULONGEST *open_closure = xmalloc (sizeof (ULONGEST));
*open_closure = addr;
- nbfd = bfd_openr_iovec (xstrdup ("<in-memory>"), "elf32-spu",
- spu_bfd_iovec_open, open_closure,
- spu_bfd_iovec_pread, spu_bfd_iovec_close,
- spu_bfd_iovec_stat);
+ nbfd = gdb_bfd_openr_iovec ("<in-memory>", "elf32-spu",
+ spu_bfd_iovec_open, open_closure,
+ spu_bfd_iovec_pread, spu_bfd_iovec_close,
+ spu_bfd_iovec_stat);
if (!nbfd)
return NULL;
if (!bfd_check_format (nbfd, bfd_object))
{
- bfd_close (nbfd);
+ gdb_bfd_unref (nbfd);
return NULL;
}
/* Open BFD representing SPE executable and read its symbols. */
nbfd = spu_bfd_open (addr);
if (nbfd)
- symbol_file_add_from_bfd (nbfd, SYMFILE_VERBOSE | SYMFILE_MAINLINE,
- NULL, 0, NULL);
+ {
+ struct cleanup *cleanup = make_cleanup_bfd_unref (nbfd);
+
+ symbol_file_add_from_bfd (nbfd, SYMFILE_VERBOSE | SYMFILE_MAINLINE,
+ NULL, 0, NULL);
+ do_cleanups (cleanup);
+ }
}
int fd;
ULONGEST addr;
- int tid = TIDGET (ptid);
+ int tid = ptid_get_lwp (ptid);
if (tid == 0)
- tid = PIDGET (ptid);
+ tid = ptid_get_pid (ptid);
while (!parse_spufs_run (&fd, &addr))
{
set_sigint_trap (); /* Causes SIGINT to be passed on to the
attached process. */
- pid = waitpid (PIDGET (ptid), &status, 0);
+ pid = waitpid (ptid_get_pid (ptid), &status, 0);
if (pid == -1 && errno == ECHILD)
/* Try again with __WCLONE to check cloned processes. */
- pid = waitpid (PIDGET (ptid), &status, __WCLONE);
+ pid = waitpid (ptid_get_pid (ptid), &status, __WCLONE);
save_errno = errno;
/* Make sure we don't report an event for the exit of the
original program, if we've detached from it. */
- if (pid != -1 && !WIFSTOPPED (status) && pid != PIDGET (inferior_ptid))
+ if (pid != -1 && !WIFSTOPPED (status)
+ && pid != ptid_get_pid (inferior_ptid))
{
pid = -1;
save_errno = EINTR;
/* Claim it exited with unknown signal. */
ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
- ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
+ ourstatus->value.sig = GDB_SIGNAL_UNKNOWN;
return inferior_ptid;
}
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
- char buf[4];
+ gdb_byte buf[4];
store_unsigned_integer (buf, 4, byte_order, fd);
regcache_raw_supply (regcache, SPU_ID_REGNUM, buf);
}