33 #include <sys/ptrace.h>
34 #include <asm/ptrace.h>
35 #include <sys/types.h>
40 #define INSTR_SC 0x44000002
41 #define NR_spu_run 0x0116
63 ptrace (PPC_PTRACE_PEEKUSR_3264, tid,
66 ptrace (PPC_PTRACE_PEEKUSR_3264, tid,
79 xsnprintf (mess,
sizeof mess,
"reading PPC register #%d", regno);
95 uint64_t addr_8 = (uint64_t) memaddr;
111 #ifndef __powerpc64__
114 uint64_t addr_8 = (uint64_t) memaddr;
245 xsnprintf (buf,
sizeof buf,
"/proc/%d/fd/%s", pid, annex);
246 fd = open (buf, writebuf? O_WRONLY : O_RDONLY);
251 && lseek (fd, (off_t) offset,
SEEK_SET) != (off_t) offset)
258 ret = write (fd, writebuf, (
size_t) len);
260 ret =
read (fd, readbuf, (
size_t) len);
295 file_ptr nbytes, file_ptr
offset)
301 bfd_set_error (bfd_error_invalid_operation);
316 memset (sb, 0,
sizeof (
struct stat));
328 *open_closure = addr;
337 if (!bfd_check_format (nbfd, bfd_object))
344 spu_name = bfd_get_section_by_name (nbfd,
".note.spu_name");
347 int sect_size = bfd_section_size (nbfd, spu_name);
350 char *buf = alloca (sect_size - 20 + 1);
351 bfd_get_section_contents (nbfd, spu_name, buf, 20, sect_size - 20);
352 buf[sect_size - 20] =
'\0';
354 xfree ((
char *)nbfd->filename);
355 nbfd->filename = xstrdup (buf);
378 xsnprintf (annex,
sizeof annex,
"%d/object-id", inferior_fd);
383 addr =
strtoulst ((
const char *)
id, NULL, 16);
416 waitpid (tid, NULL,
__WALL | __WNOTHREAD);
434 waitpid (pid, NULL,
__WALL | __WNOTHREAD);
459 if (pid == -1 && errno == ECHILD)
476 while (pid == -1 && save_errno == EINTR);
480 warning (
_(
"Child process unexpectedly missing: %s"),
485 ourstatus->
value.
sig = GDB_SIGNAL_UNKNOWN;
524 if (regno == -1 || (regno >= 0 && regno <
SPU_NUM_GPRS))
531 xsnprintf (annex,
sizeof annex,
"%d/regs", fd);
534 && len ==
sizeof buf)
561 if (regno == -1 || (regno >= 0 && regno <
SPU_NUM_GPRS))
571 xsnprintf (annex,
sizeof annex,
"%d/regs", fd);
591 char mem_annex[32], lslr_annex[32];
601 xsnprintf (mem_annex,
sizeof mem_annex,
"%d/mem", fd);
611 xsnprintf (lslr_annex,
sizeof lslr_annex,
"%d/lslr", fd);
612 memset (buf, 0,
sizeof buf);
617 lslr =
strtoulst ((
const char *) buf, NULL, 16);
619 offset & lslr, len, xfered_len);
628 int type,
int cnt,
int othertype)
struct gdbarch * target_gdbarch(void)
void add_target(struct target_ops *t)
ssize_t read(int fd, void *buf, size_t count)
ULONGEST extract_unsigned_integer(const gdb_byte *, int, enum bfd_endian)
static file_ptr spu_bfd_iovec_pread(struct bfd *abfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset)
static int store_ppc_memory_1(int tid, ULONGEST memaddr, PTRACE_TYPE_RET word)
struct gdbarch * get_regcache_arch(const struct regcache *regcache)
struct objfile * symbol_file_add_from_bfd(bfd *abfd, const char *name, int add_flags, struct section_addr_info *addrs, int flags, struct objfile *parent)
static int fetch_ppc_memory(ULONGEST memaddr, gdb_byte *myaddr, int len)
void warning(const char *fmt,...)
void set_sigint_trap(void)
static enum target_xfer_status spu_proc_xfer_spu(const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
ptid_t(* to_wait)(struct target_ops *, ptid_t, struct target_waitstatus *, int TARGET_DEBUG_PRINTER(target_debug_print_options)) TARGET_DEFAULT_NORETURN(noprocess())
struct target_ops * inf_ptrace_target(void)
void store_unsigned_integer(gdb_byte *, int, enum bfd_endian, ULONGEST)
static void spu_symbol_file_add_from_memory(int inferior_fd)
initialize_file_ftype _initialize_spu_nat
static void spu_child_post_attach(struct target_ops *self, int pid)
void gdb_bfd_unref(struct bfd *abfd)
void initialize_file_ftype(void)
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int status
ptid_t pid_to_ptid(int pid)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void store_waitstatus(struct target_waitstatus *ourstatus, int hoststatus)
static int spu_bfd_iovec_stat(struct bfd *abfd, void *stream, struct stat *sb)
union target_waitstatus::@161 value
static int store_ppc_memory(ULONGEST memaddr, const gdb_byte *myaddr, int len)
bfd * gdb_bfd_openr_iovec(const char *filename, const char *target, void *(*open_func)(struct bfd *nbfd, void *open_closure), void *open_closure, file_ptr(*pread_func)(struct bfd *nbfd, void *stream, void *buf, file_ptr nbytes, file_ptr offset), int(*close_func)(struct bfd *nbfd, void *stream), int(*stat_func)(struct bfd *abfd, void *stream, struct stat *sb))
static void spu_fetch_inferior_registers(struct target_ops *ops, struct regcache *regcache, int regno)
enum target_xfer_status(* to_xfer_partial)(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len) TARGET_DEFAULT_RETURN(TARGET_XFER_E_IO)
ULONGEST strtoulst(const char *num, const char **trailer, int base)
static void spu_child_post_startup_inferior(struct target_ops *self, ptid_t ptid)
static int parse_spufs_run(int *fd, ULONGEST *addr)
struct cleanup * make_cleanup_bfd_unref(bfd *abfd)
int ptid_get_pid(ptid_t ptid)
void(* to_fetch_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_IGNORE()
static bfd * spu_bfd_open(ULONGEST addr)
void void void void void void void void void perror_with_name(const char *string) ATTRIBUTE_NORETURN
int(* to_can_use_hw_breakpoint)(struct target_ops *, int, int, int) TARGET_DEFAULT_RETURN(0)
int xsnprintf(char *str, size_t size, const char *format,...)
static int spu_bfd_iovec_close(struct bfd *nbfd, void *stream)
enum target_waitkind kind
char * safe_strerror(int)
void(* to_post_attach)(struct target_ops *, int) TARGET_DEFAULT_IGNORE()
static int fetch_ppc_memory_1(int tid, ULONGEST memaddr, PTRACE_TYPE_RET *word)
static void * spu_bfd_iovec_open(struct bfd *nbfd, void *open_closure)
static enum target_xfer_status spu_xfer_partial(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *readbuf, const gdb_byte *writebuf, ULONGEST offset, ULONGEST len, ULONGEST *xfered_len)
void regcache_raw_supply(struct regcache *regcache, int regnum, const void *buf)
char * get_exec_file(int err)
unsigned long long ULONGEST
static void spu_store_inferior_registers(struct target_ops *ops, struct regcache *regcache, int regno)
void clear_sigint_trap(void)
long ptid_get_lwp(ptid_t ptid)
void regcache_raw_collect(const struct regcache *regcache, int regnum, void *buf)
static ptid_t spu_child_wait(struct target_ops *ops, ptid_t ptid, struct target_waitstatus *ourstatus, int options)
static int spu_can_use_hw_breakpoint(struct target_ops *self, int type, int cnt, int othertype)
static ULONGEST fetch_ppc_register(int regno)
void(* to_store_registers)(struct target_ops *, struct regcache *, int) TARGET_DEFAULT_NORETURN(noprocess())
enum bfd_endian byte_order
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
void do_cleanups(struct cleanup *old_chain)
void(* to_post_startup_inferior)(struct target_ops *, ptid_t) TARGET_DEFAULT_IGNORE()
const ULONGEST const LONGEST len