24 #include <sys/ptrace.h>
27 #include <sys/syscall.h>
33 #define __WNOTHREAD 0x20000000
37 #define PTRACE_TYPE_RET long
38 #define PTRACE_TYPE_ARG3 long
41 #define SPU_NUM_REGS 130
42 #define SPU_NUM_CORE_REGS 128
45 #define SPU_ID_REGNUM 128
46 #define SPU_PC_REGNUM 129
49 #define INSTR_SC 0x44000002
50 #define NR_spu_run 0x0116
76 ptrace (PPC_PTRACE_PEEKUSR_3264, tid,
79 ptrace (PPC_PTRACE_PEEKUSR_3264, tid,
82 return (
CORE_ADDR) *(
unsigned long long *)buf;
87 res = ptrace (PT_READ_U, tid,
92 sprintf (mess,
"reading PPC register #%d", regno);
105 #ifndef __powerpc64__
108 unsigned long long addr_8 = (
unsigned long long) memaddr;
124 #ifndef __powerpc64__
127 unsigned long long addr_8 = (
unsigned long long) memaddr;
184 &buffer[count - 1])) != 0)
228 const unsigned char *writebuf,
239 fd = open (buf, writebuf? O_WRONLY : O_RDONLY);
244 && lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
251 ret = write (fd, writebuf, (
size_t) len);
253 ret = read (fd, readbuf, (
size_t) len);
276 ptrace (PTRACE_TRACEME, 0, 0, 0);
280 execv (program, allargs);
282 execvp (program, allargs);
284 fprintf (stderr,
"Cannot exec %s: %s.\n", program,
305 if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0)
307 fprintf (stderr,
"Cannot attach to process %ld: %s (%d)\n", pid,
329 ptrace (PTRACE_KILL, pid, 0, 0);
332 ret = waitpid (pid, &status, 0);
335 }
while (ret != -1 ||
errno != ECHILD);
350 ptrace (PTRACE_DETACH, pid, 0, 0);
369 ret = waitpid (pid, &status, 0);
372 }
while (ret != -1 ||
errno != ECHILD);
388 for (i = 0; i < n; i++)
398 if (resume_info[i].kind == resume_step)
399 fprintf (stderr,
"Hardware single-step not supported.\n");
448 fprintf (stderr,
"\nChild exited with retcode = %x \n",
WEXITSTATUS (w));
449 ourstatus->kind = TARGET_WAITKIND_EXITED;
456 fprintf (stderr,
"\nChild terminated with signal = %x \n",
WTERMSIG (w));
457 ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
467 ourstatus->kind = TARGET_WAITKIND_STOPPED;
468 ourstatus->value.sig = GDB_SIGNAL_0;
472 ourstatus->kind = TARGET_WAITKIND_STOPPED;
507 sprintf (annex,
"%d/regs", fd);
547 sprintf (annex,
"%d/regs", fd);
559 char annex[32], lslr_annex[32], buf[32];
567 sprintf (annex,
"%d/mem", fd);
570 return ret == len ? 0 : EIO;
576 sprintf (lslr_annex,
"%d/lslr", fd);
577 memset (buf, 0,
sizeof buf);
582 lslr = strtoul (buf, NULL, 16);
585 return ret == len ? 0 : EIO;
597 char annex[32], lslr_annex[32], buf[32];
605 sprintf (annex,
"%d/mem", fd);
608 return ret == len ? 0 : EIO;
614 sprintf (lslr_annex,
"%d/lslr", fd);
615 memset (buf, 0,
sizeof buf);
620 lslr = strtoul (buf, NULL, 16);
623 return ret == len ? 0 : EIO;
677 static const unsigned char breakpoint[] = { 0x00, 0x00, 0x3f, 0xff };
static void spu_request_interrupt(void)
void collect_register(struct regcache *regcache, int n, void *buf)
static void spu_store_registers(struct regcache *regcache, int regno)
struct process_info * add_process(int pid, int attached)
static void spu_resume(struct thread_resume *resume_info, size_t n)
static void spu_look_up_symbols(void)
static int store_ppc_memory(CORE_ADDR memaddr, char *myaddr, int len)
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
static int spu_kill(int pid)
struct process_info * find_process_pid(int pid)
void set_breakpoint_data(const unsigned char *bp_data, int bp_len)
static int fetch_ppc_memory(CORE_ADDR memaddr, char *myaddr, int len)
static int spu_proc_xfer_spu(const char *annex, unsigned char *readbuf, const unsigned char *writebuf, CORE_ADDR offset, int len)
const struct target_desc * tdesc
ptid_t ptid_build(int pid, long lwp, long tid)
static int store_ppc_memory_1(int tid, CORE_ADDR memaddr, PTRACE_TYPE_RET word)
static int spu_create_inferior(char *program, char **allargs)
const struct target_desc * tdesc_spu
void regcache_invalidate(void)
ptid_t pid_to_ptid(int pid)
enum gdb_signal gdb_signal_from_host(int)
static int spu_thread_alive(ptid_t ptid)
static CORE_ADDR fetch_ppc_register(int regno)
void remove_process(struct process_info *process)
void set_target_ops(struct target_ops *target)
static int spu_detach(int pid)
void close_most_fds(void)
int ptid_get_pid(ptid_t ptid)
static int spu_write_memory(CORE_ADDR memaddr, const unsigned char *myaddr, int len)
static ptid_t spu_wait(ptid_t ptid, struct target_waitstatus *ourstatus, int options)
void hostio_last_error_from_errno(char *buf)
static int fetch_ppc_memory_1(int tid, CORE_ADDR memaddr, PTRACE_TYPE_RET *word)
void perror_with_name(const char *string)
static void spu_fetch_registers(struct regcache *regcache, int regno)
int spu_attach(unsigned long pid)
long ptid_get_lwp(ptid_t ptid)
void init_registers_spu(void)
static void spu_join(int pid)
void initialize_low(void)
static void spu_mourn(struct process_info *process)
static int parse_spufs_run(int *fd, CORE_ADDR *addr)
#define SPU_NUM_CORE_REGS
void supply_register(struct regcache *regcache, int n, const void *buf)
struct thread_info * add_thread(ptid_t ptid, void *target_data)
static int spu_read_memory(CORE_ADDR memaddr, unsigned char *myaddr, int len)
void clear_inferiors(void)