static void sh3e_open (char *args, int from_tty) { char *serial_port_name = args; char *parallel_port_name = 0; if (args) { char *cursor = serial_port_name = xstrdup (args); while (*cursor && *cursor != ' ') cursor++; if (*cursor) *cursor++ = 0; while (*cursor == ' ') cursor++; if (*cursor) parallel_port_name = cursor; } /* Set up the SH-3E monitor commands structure. */ memcpy (&sh3e_cmds, &sh3_cmds, sizeof (struct monitor_ops)); sh3e_cmds.target = &sh3e_ops; sh3e_cmds.regnames = sh3e_regnames; monitor_open (serial_port_name, &sh3e_cmds, from_tty); if (parallel_port_name) { parallel = serial_open (parallel_port_name); if (!parallel) perror_with_name (_("Unable to open parallel port.")); parallel_in_use = 1; } /* If we connected successfully, we know the processor is an SH3E. */ { struct gdbarch_info info; gdbarch_info_init (&info); info.bfd_arch_info = bfd_lookup_arch (bfd_arch_sh, bfd_mach_sh3); if (!gdbarch_update_p (info)) error (_("Target is not an SH3")); } }
int monitor_stat(const char *path, struct stat *sb) { int fd, r, saved_errno; /* O_NONBLOCK is needed for stat'ing fifos. */ fd = monitor_open(path, O_RDONLY | O_NONBLOCK, 0); if (fd < 0) return -1; r = fstat(fd, sb); saved_errno = errno; close(fd); errno = saved_errno; return r; }
FILE * monitor_fopen(const char *path, const char *mode) { FILE *fp; int fd, flags = 0, saved_errno; mode_t mask, cur_umask; /* Only the child process is supposed to run this. */ if (m_state.pid) log_fatal("[priv] bad call to monitor_fopen"); switch (mode[0]) { case 'r': flags = (mode[1] == '+' ? O_RDWR : O_RDONLY); break; case 'w': flags = (mode[1] == '+' ? O_RDWR : O_WRONLY) | O_CREAT | O_TRUNC; break; case 'a': flags = (mode[1] == '+' ? O_RDWR : O_WRONLY) | O_CREAT | O_APPEND; break; default: log_fatal("monitor_fopen: bad call"); } cur_umask = umask(0); (void)umask(cur_umask); mask = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; mask &= ~cur_umask; fd = monitor_open(path, flags, mask); if (fd < 0) return NULL; /* Got the fd, attach a FILE * to it. */ fp = fdopen(fd, mode); if (!fp) { log_error("monitor_fopen: fdopen() failed"); saved_errno = errno; close(fd); errno = saved_errno; return NULL; } return fp; }
static void dbug_open (char *args, int from_tty) { monitor_open (args, &dbug_cmds, from_tty); }
static void ppcbug_open1 (char *args, int from_tty) { monitor_open (args, &ppcbug_cmds1, from_tty); }
static void w89k_open (char *args, int from_tty) { monitor_open (args, &w89k_cmds, from_tty); }
static void rom68k_open (char *args, int from_tty) { monitor_open (args, &rom68k_cmds, from_tty); }
static void picobug_open (const char *args, int from_tty) { monitor_open (args, &picobug_cmds, from_tty); }
static void est_open (char *args, int from_tty) { monitor_open (args, &est_cmds, from_tty); }
static void ppcbug_open0 (const char *args, int from_tty) { monitor_open (args, &ppcbug_cmds0, from_tty); }
static void hms_open (char *args, int from_tty) { monitor_open (args, &hms_cmds, from_tty); }
static void init_op50n_cmds(void) { op50n_cmds.flags = MO_CLR_BREAK_USES_ADDR /*| MO_GETMEM_READ_SINGLE*/; /* flags */ op50n_cmds.init = op50n_inits; /* Init strings */ op50n_cmds.cont = "g\r"; /* continue command */ op50n_cmds.step = "t\r"; /* single step */ op50n_cmds.stop = "\003.\r"; /* Interrupt char */ op50n_cmds.set_break = "b %x\r"; /* set a breakpoint */ op50n_cmds.clr_break = "b %x;0\r"; /* clear breakpoint at addr */ op50n_cmds.clr_all_break = "bx\r"; /* clear all breakpoints */ op50n_cmds.fill = "fx %x s%x %x\r"; /* memory fill cmd (addr, len, val) */ op50n_cmds.setmem.cmdb = "sx %x %x\r"; /* setmem.cmdb (addr, value) */ op50n_cmds.setmem.cmdw = "sh %x %x\r"; /* setmem.cmdw (addr, value) */ op50n_cmds.setmem.cmdl = "s %x %x\r"; /* setmem.cmdl (addr, value) */ op50n_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */ op50n_cmds.setmem.resp_delim = NULL; /* setmem.resp_delim */ op50n_cmds.setmem.term = NULL; /* setmem.term */ op50n_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */ #if 0 { "sx %x\r", /* getmem.cmdb (addr, len) */ "sh %x\r", /* getmem.cmdw (addr, len) */ "s %x\r", /* getmem.cmdl (addr, len) */ NULL, /* getmem.cmdll (addr, len) */ " : ", /* getmem.resp_delim */ " ", /* getmem.term */ ".\r", /* getmem.term_cmd */ } ; #else op50n_cmds.getmem.cmdb = "dx %x s%x\r"; /* getmem.cmdb (addr, len) */ op50n_cmds.getmem.cmdw = NULL; /* getmem.cmdw (addr, len) */ op50n_cmds.getmem.cmdl = NULL; /* getmem.cmdl (addr, len) */ op50n_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */ op50n_cmds.getmem.resp_delim = " : "; /* getmem.resp_delim */ op50n_cmds.getmem.term = NULL; /* getmem.term */ op50n_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */ #endif op50n_cmds.setreg.cmd = "x %s %x\r"; /* setreg.cmd (name, value) */ op50n_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */ op50n_cmds.setreg.term = NULL; /* setreg.term */ op50n_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */ op50n_cmds.getreg.cmd = "x %s\r"; /* getreg.cmd (name) */ op50n_cmds.getreg.resp_delim = "="; /* getreg.resp_delim */ op50n_cmds.getreg.term = " "; /* getreg.term */ op50n_cmds.getreg.term_cmd = ".\r"; /* getreg.term_cmd */ op50n_cmds.dump_registers = NULL; /* dump_registers */ op50n_cmds.register_pattern = NULL; /* register_pattern */ op50n_cmds.supply_register = NULL; /* supply_register */ op50n_cmds.load_routine = NULL; /* load routine */ op50n_cmds.load = "r 0\r"; /* download command */ op50n_cmds.loadresp = NULL; /* load response */ op50n_cmds.prompt = "\n#"; /* monitor command prompt */ op50n_cmds.line_term = "\r"; /* end-of-command delimitor */ op50n_cmds.cmd_end = NULL; /* optional command terminator */ op50n_cmds.target = &op50n_ops; /* target operations */ op50n_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ op50n_cmds.regnames = op50n_regnames; /* register names */ op50n_cmds.magic = MONITOR_OPS_MAGIC; /* magic */ }; static void op50n_open (args, from_tty) char *args; int from_tty; { monitor_open (args, &op50n_cmds, from_tty); } void _initialize_op50n () { init_op50n_cmds() ; init_monitor_ops (&op50n_ops); op50n_ops.to_shortname = "op50n"; op50n_ops.to_longname = "Oki's debug monitor for the Op50n Eval board"; op50n_ops.to_doc = "Debug on a Oki OP50N eval board.\n\ Specify the serial device it is connected to (e.g. /dev/ttya)."; op50n_ops.to_open = op50n_open; add_target (&op50n_ops); }
static void dink32_open (char *args, int from_tty) { monitor_open (args, &dink32_cmds, from_tty); }