gdb/dbug-rom.c - gdb

Global variables defined

Functions defined

Source code

  1. /* Remote debugging interface to dBUG ROM monitor for GDB, the GNU debugger.
  2.    Copyright (C) 1996-2015 Free Software Foundation, Inc.

  3.    Written by Stan Shebs of Cygnus Support.

  4.    This file is part of GDB.

  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 3 of the License, or
  8.    (at your option) any later version.

  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.

  13.    You should have received a copy of the GNU General Public License
  14.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  15. /* dBUG is a monitor supplied on various Motorola boards, including
  16.    m68k, ColdFire, and PowerPC-based designs.  The code here assumes
  17.    the ColdFire, and (as of 9/25/96) has only been tested with a
  18.    ColdFire IDP board.  */

  19. #include "defs.h"
  20. #include "gdbcore.h"
  21. #include "target.h"
  22. #include "monitor.h"
  23. #include "serial.h"
  24. #include "regcache.h"

  25. #include "m68k-tdep.h"

  26. static void
  27. dbug_supply_register (struct regcache *regcache, char *regname,
  28.                       int regnamelen, char *val, int vallen)
  29. {
  30.   int regno;
  31.   struct gdbarch *gdbarch = get_regcache_arch (regcache);

  32.   if (regnamelen != 2)
  33.     return;

  34.   switch (regname[0])
  35.     {
  36.     case 'S':
  37.       if (regname[1] != 'R')
  38.         return;
  39.       regno = gdbarch_ps_regnum (gdbarch);
  40.       break;
  41.     case 'P':
  42.       if (regname[1] != 'C')
  43.         return;
  44.       regno = gdbarch_pc_regnum (gdbarch);
  45.       break;
  46.     case 'D':
  47.       if (regname[1] < '0' || regname[1] > '7')
  48.         return;
  49.       regno = regname[1] - '0' + M68K_D0_REGNUM;
  50.       break;
  51.     case 'A':
  52.       if (regname[1] < '0' || regname[1] > '7')
  53.         return;
  54.       regno = regname[1] - '0' + M68K_A0_REGNUM;
  55.       break;
  56.     default:
  57.       return;
  58.     }

  59.   monitor_supply_register (regcache, regno, val);
  60. }

  61. /* This array of registers needs to match the indexes used by GDB.
  62.    The whole reason this exists is because the various ROM monitors
  63.    use different names than GDB does, and don't support all the
  64.    registers either.  So, typing "info reg sp" becomes an "A7".  */

  65. static const char *
  66. dbug_regname (int index)
  67. {
  68.   static char *regnames[] =
  69.   {
  70.     "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
  71.     "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
  72.     "SR", "PC"
  73.     /* no float registers */
  74.   };

  75.   if (index >= ARRAY_SIZE (regnames) || index < 0)
  76.     return NULL;
  77.   else
  78.     return regnames[index];

  79. }

  80. static struct target_ops dbug_ops;
  81. static struct monitor_ops dbug_cmds;

  82. static char *dbug_inits[] =
  83. {"\r", NULL};


  84. static void
  85. init_dbug_cmds (void)
  86. {
  87.   dbug_cmds.flags = MO_CLR_BREAK_USES_ADDR
  88.     | MO_GETMEM_NEEDS_RANGE | MO_FILL_USES_ADDR;
  89.   dbug_cmds.init = dbug_inits;        /* Init strings */
  90.   dbug_cmds.cont = "go\r";        /* continue command */
  91.   dbug_cmds.step = "trace\r";        /* single step */
  92.   dbug_cmds.stop = NULL;        /* interrupt command */
  93.   dbug_cmds.set_break = "br %x\r";        /* set a breakpoint */
  94.   dbug_cmds.clr_break = "br -r %x\r";        /* clear a breakpoint */
  95.   dbug_cmds.clr_all_break = "br -r\r";        /* clear all breakpoints */
  96.   dbug_cmds.fill = "bf.b %x %x %x\r";        /* fill (start end val) */
  97.   dbug_cmds.setmem.cmdb = "mm.b %x %x\r";        /* setmem.cmdb (addr, value) */
  98.   dbug_cmds.setmem.cmdw = "mm.w %x %x\r";        /* setmem.cmdw (addr, value) */
  99.   dbug_cmds.setmem.cmdl = "mm.l %x %x\r";        /* setmem.cmdl (addr, value) */
  100.   dbug_cmds.setmem.cmdll = NULL;        /* setmem.cmdll (addr, value) */
  101.   dbug_cmds.setmem.resp_delim = NULL;        /* setmem.resp_delim */
  102.   dbug_cmds.setmem.term = NULL;        /* setmem.term */
  103.   dbug_cmds.setmem.term_cmd = NULL;        /* setmem.term_cmd */
  104.   dbug_cmds.getmem.cmdb = "md.b %x %x\r";        /* getmem.cmdb (addr, addr2) */
  105.   dbug_cmds.getmem.cmdw = "md.w %x %x\r";        /* getmem.cmdw (addr, addr2) */
  106.   dbug_cmds.getmem.cmdl = "md.l %x %x\r";        /* getmem.cmdl (addr, addr2) */
  107.   dbug_cmds.getmem.cmdll = NULL;        /* getmem.cmdll (addr, addr2) */
  108.   dbug_cmds.getmem.resp_delim = ":";        /* getmem.resp_delim */
  109.   dbug_cmds.getmem.term = NULL;        /* getmem.term */
  110.   dbug_cmds.getmem.term_cmd = NULL;        /* getmem.term_cmd */
  111.   dbug_cmds.setreg.cmd = "rm %s %x\r";        /* setreg.cmd (name, value) */
  112.   dbug_cmds.setreg.resp_delim = NULL;        /* setreg.resp_delim */
  113.   dbug_cmds.setreg.term = NULL;        /* setreg.term */
  114.   dbug_cmds.setreg.term_cmd = NULL;        /* setreg.term_cmd */
  115.   dbug_cmds.getreg.cmd = "rd %s\r";        /* getreg.cmd (name) */
  116.   dbug_cmds.getreg.resp_delim = ":";        /* getreg.resp_delim */
  117.   dbug_cmds.getreg.term = NULL;        /* getreg.term */
  118.   dbug_cmds.getreg.term_cmd = NULL;        /* getreg.term_cmd */
  119.   dbug_cmds.dump_registers = "rd\r";        /* dump_registers */
  120.                                         /* register_pattern */
  121.   dbug_cmds.register_pattern = "\\(\\w+\\) +:\\([0-9a-fA-F]+\\b\\)";
  122.   dbug_cmds.supply_register = dbug_supply_register;
  123.   dbug_cmds.load = "dl\r";        /* download command */
  124.   dbug_cmds.loadresp = "\n";        /* load response */
  125.   dbug_cmds.prompt = "dBUG>";        /* monitor command prompt */
  126.   dbug_cmds.line_term = "\r";        /* end-of-line terminator */
  127.   dbug_cmds.cmd_end = NULL;        /* optional command terminator */
  128.   dbug_cmds.target = &dbug_ops;        /* target operations */
  129.   dbug_cmds.stopbits = SERIAL_1_STOPBITS;        /* number of stop bits */
  130.   dbug_cmds.regnames = NULL;        /* registers names */
  131.   dbug_cmds.regname = dbug_regname;
  132.   dbug_cmds.magic = MONITOR_OPS_MAGIC;        /* magic */
  133. }                                /* init_debug_ops */

  134. static void
  135. dbug_open (const char *args, int from_tty)
  136. {
  137.   monitor_open (args, &dbug_cmds, from_tty);
  138. }

  139. extern initialize_file_ftype _initialize_dbug_rom; /* -Wmissing-prototypes */

  140. void
  141. _initialize_dbug_rom (void)
  142. {
  143.   init_dbug_cmds ();
  144.   init_monitor_ops (&dbug_ops);

  145.   dbug_ops.to_shortname = "dbug";
  146.   dbug_ops.to_longname = "dBUG monitor";
  147.   dbug_ops.to_doc = "Debug via the dBUG monitor.\n\
  148. Specify the serial device it is connected to (e.g. /dev/ttya).";
  149.   dbug_ops.to_open = dbug_open;

  150.   add_target (&dbug_ops);
  151. }