gdb/dbug-rom.c - gdb
Global variables defined
Functions defined
Source code
- #include "defs.h"
- #include "gdbcore.h"
- #include "target.h"
- #include "monitor.h"
- #include "serial.h"
- #include "regcache.h"
- #include "m68k-tdep.h"
- static void
- dbug_supply_register (struct regcache *regcache, char *regname,
- int regnamelen, char *val, int vallen)
- {
- int regno;
- struct gdbarch *gdbarch = get_regcache_arch (regcache);
- if (regnamelen != 2)
- return;
- switch (regname[0])
- {
- case 'S':
- if (regname[1] != 'R')
- return;
- regno = gdbarch_ps_regnum (gdbarch);
- break;
- case 'P':
- if (regname[1] != 'C')
- return;
- regno = gdbarch_pc_regnum (gdbarch);
- break;
- case 'D':
- if (regname[1] < '0' || regname[1] > '7')
- return;
- regno = regname[1] - '0' + M68K_D0_REGNUM;
- break;
- case 'A':
- if (regname[1] < '0' || regname[1] > '7')
- return;
- regno = regname[1] - '0' + M68K_A0_REGNUM;
- break;
- default:
- return;
- }
- monitor_supply_register (regcache, regno, val);
- }
- static const char *
- dbug_regname (int index)
- {
- static char *regnames[] =
- {
- "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
- "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
- "SR", "PC"
-
- };
- if (index >= ARRAY_SIZE (regnames) || index < 0)
- return NULL;
- else
- return regnames[index];
- }
- static struct target_ops dbug_ops;
- static struct monitor_ops dbug_cmds;
- static char *dbug_inits[] =
- {"\r", NULL};
- static void
- init_dbug_cmds (void)
- {
- dbug_cmds.flags = MO_CLR_BREAK_USES_ADDR
- | MO_GETMEM_NEEDS_RANGE | MO_FILL_USES_ADDR;
- dbug_cmds.init = dbug_inits;
- dbug_cmds.cont = "go\r";
- dbug_cmds.step = "trace\r";
- dbug_cmds.stop = NULL;
- dbug_cmds.set_break = "br %x\r";
- dbug_cmds.clr_break = "br -r %x\r";
- dbug_cmds.clr_all_break = "br -r\r";
- dbug_cmds.fill = "bf.b %x %x %x\r";
- dbug_cmds.setmem.cmdb = "mm.b %x %x\r";
- dbug_cmds.setmem.cmdw = "mm.w %x %x\r";
- dbug_cmds.setmem.cmdl = "mm.l %x %x\r";
- dbug_cmds.setmem.cmdll = NULL;
- dbug_cmds.setmem.resp_delim = NULL;
- dbug_cmds.setmem.term = NULL;
- dbug_cmds.setmem.term_cmd = NULL;
- dbug_cmds.getmem.cmdb = "md.b %x %x\r";
- dbug_cmds.getmem.cmdw = "md.w %x %x\r";
- dbug_cmds.getmem.cmdl = "md.l %x %x\r";
- dbug_cmds.getmem.cmdll = NULL;
- dbug_cmds.getmem.resp_delim = ":";
- dbug_cmds.getmem.term = NULL;
- dbug_cmds.getmem.term_cmd = NULL;
- dbug_cmds.setreg.cmd = "rm %s %x\r";
- dbug_cmds.setreg.resp_delim = NULL;
- dbug_cmds.setreg.term = NULL;
- dbug_cmds.setreg.term_cmd = NULL;
- dbug_cmds.getreg.cmd = "rd %s\r";
- dbug_cmds.getreg.resp_delim = ":";
- dbug_cmds.getreg.term = NULL;
- dbug_cmds.getreg.term_cmd = NULL;
- dbug_cmds.dump_registers = "rd\r";
-
- dbug_cmds.register_pattern = "\\(\\w+\\) +:\\([0-9a-fA-F]+\\b\\)";
- dbug_cmds.supply_register = dbug_supply_register;
- dbug_cmds.load = "dl\r";
- dbug_cmds.loadresp = "\n";
- dbug_cmds.prompt = "dBUG>";
- dbug_cmds.line_term = "\r";
- dbug_cmds.cmd_end = NULL;
- dbug_cmds.target = &dbug_ops;
- dbug_cmds.stopbits = SERIAL_1_STOPBITS;
- dbug_cmds.regnames = NULL;
- dbug_cmds.regname = dbug_regname;
- dbug_cmds.magic = MONITOR_OPS_MAGIC;
- }
- static void
- dbug_open (const char *args, int from_tty)
- {
- monitor_open (args, &dbug_cmds, from_tty);
- }
- extern initialize_file_ftype _initialize_dbug_rom;
- void
- _initialize_dbug_rom (void)
- {
- init_dbug_cmds ();
- init_monitor_ops (&dbug_ops);
- dbug_ops.to_shortname = "dbug";
- dbug_ops.to_longname = "dBUG monitor";
- dbug_ops.to_doc = "Debug via the dBUG monitor.\n\
- Specify the serial device it is connected to (e.g. /dev/ttya).";
- dbug_ops.to_open = dbug_open;
- add_target (&dbug_ops);
- }