Commit | Line | Data |
---|---|---|
c906108c | 1 | /* Remote debugging interface to dBUG ROM monitor for GDB, the GNU debugger. |
28e7fd62 | 2 | Copyright (C) 1996-2013 Free Software Foundation, Inc. |
c906108c SS |
3 | |
4 | Written by Stan Shebs of Cygnus Support. | |
5 | ||
c5aa993b | 6 | This file is part of GDB. |
c906108c | 7 | |
c5aa993b JM |
8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 10 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 11 | (at your option) any later version. |
c906108c | 12 | |
c5aa993b JM |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
c906108c | 17 | |
c5aa993b | 18 | You should have received a copy of the GNU General Public License |
a9762ec7 | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c SS |
20 | |
21 | /* dBUG is a monitor supplied on various Motorola boards, including | |
22 | m68k, ColdFire, and PowerPC-based designs. The code here assumes | |
23 | the ColdFire, and (as of 9/25/96) has only been tested with a | |
24 | ColdFire IDP board. */ | |
25 | ||
26 | #include "defs.h" | |
27 | #include "gdbcore.h" | |
28 | #include "target.h" | |
29 | #include "monitor.h" | |
30 | #include "serial.h" | |
4e052eda | 31 | #include "regcache.h" |
c906108c | 32 | |
32eeb91a AS |
33 | #include "m68k-tdep.h" |
34 | ||
a14ed312 | 35 | static void dbug_open (char *args, int from_tty); |
c906108c SS |
36 | |
37 | static void | |
c410a84c UW |
38 | dbug_supply_register (struct regcache *regcache, char *regname, |
39 | int regnamelen, char *val, int vallen) | |
c906108c SS |
40 | { |
41 | int regno; | |
e76e7474 | 42 | struct gdbarch *gdbarch = get_regcache_arch (regcache); |
c906108c SS |
43 | |
44 | if (regnamelen != 2) | |
45 | return; | |
46 | ||
47 | switch (regname[0]) | |
48 | { | |
49 | case 'S': | |
50 | if (regname[1] != 'R') | |
51 | return; | |
e76e7474 | 52 | regno = gdbarch_ps_regnum (gdbarch); |
c906108c SS |
53 | break; |
54 | case 'P': | |
55 | if (regname[1] != 'C') | |
56 | return; | |
e76e7474 | 57 | regno = gdbarch_pc_regnum (gdbarch); |
c906108c SS |
58 | break; |
59 | case 'D': | |
60 | if (regname[1] < '0' || regname[1] > '7') | |
61 | return; | |
32eeb91a | 62 | regno = regname[1] - '0' + M68K_D0_REGNUM; |
c906108c SS |
63 | break; |
64 | case 'A': | |
65 | if (regname[1] < '0' || regname[1] > '7') | |
66 | return; | |
32eeb91a | 67 | regno = regname[1] - '0' + M68K_A0_REGNUM; |
c906108c SS |
68 | break; |
69 | default: | |
70 | return; | |
71 | } | |
72 | ||
c410a84c | 73 | monitor_supply_register (regcache, regno, val); |
c906108c SS |
74 | } |
75 | ||
0963b4bd MS |
76 | /* This array of registers needs to match the indexes used by GDB. |
77 | The whole reason this exists is because the various ROM monitors | |
78 | use different names than GDB does, and don't support all the | |
79 | registers either. So, typing "info reg sp" becomes an "A7". */ | |
c906108c | 80 | |
1c617db8 GS |
81 | static const char * |
82 | dbug_regname (int index) | |
c906108c | 83 | { |
1c617db8 GS |
84 | static char *regnames[] = |
85 | { | |
86 | "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7", | |
87 | "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", | |
88 | "SR", "PC" | |
89 | /* no float registers */ | |
90 | }; | |
91 | ||
a97b0ac8 | 92 | if (index >= ARRAY_SIZE (regnames) || index < 0) |
1c617db8 GS |
93 | return NULL; |
94 | else | |
95 | return regnames[index]; | |
96 | ||
97 | } | |
98 | ||
c906108c | 99 | static struct target_ops dbug_ops; |
c5aa993b | 100 | static struct monitor_ops dbug_cmds; |
c906108c | 101 | |
c5aa993b JM |
102 | static char *dbug_inits[] = |
103 | {"\r", NULL}; | |
c906108c SS |
104 | |
105 | ||
c5aa993b JM |
106 | static void |
107 | init_dbug_cmds (void) | |
c906108c | 108 | { |
3e43a32a MS |
109 | dbug_cmds.flags = MO_CLR_BREAK_USES_ADDR |
110 | | MO_GETMEM_NEEDS_RANGE | MO_FILL_USES_ADDR; | |
c5aa993b JM |
111 | dbug_cmds.init = dbug_inits; /* Init strings */ |
112 | dbug_cmds.cont = "go\r"; /* continue command */ | |
113 | dbug_cmds.step = "trace\r"; /* single step */ | |
114 | dbug_cmds.stop = NULL; /* interrupt command */ | |
115 | dbug_cmds.set_break = "br %x\r"; /* set a breakpoint */ | |
116 | dbug_cmds.clr_break = "br -r %x\r"; /* clear a breakpoint */ | |
117 | dbug_cmds.clr_all_break = "br -r\r"; /* clear all breakpoints */ | |
118 | dbug_cmds.fill = "bf.b %x %x %x\r"; /* fill (start end val) */ | |
119 | dbug_cmds.setmem.cmdb = "mm.b %x %x\r"; /* setmem.cmdb (addr, value) */ | |
120 | dbug_cmds.setmem.cmdw = "mm.w %x %x\r"; /* setmem.cmdw (addr, value) */ | |
121 | dbug_cmds.setmem.cmdl = "mm.l %x %x\r"; /* setmem.cmdl (addr, value) */ | |
122 | dbug_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */ | |
123 | dbug_cmds.setmem.resp_delim = NULL; /* setmem.resp_delim */ | |
124 | dbug_cmds.setmem.term = NULL; /* setmem.term */ | |
125 | dbug_cmds.setmem.term_cmd = NULL; /* setmem.term_cmd */ | |
126 | dbug_cmds.getmem.cmdb = "md.b %x %x\r"; /* getmem.cmdb (addr, addr2) */ | |
127 | dbug_cmds.getmem.cmdw = "md.w %x %x\r"; /* getmem.cmdw (addr, addr2) */ | |
128 | dbug_cmds.getmem.cmdl = "md.l %x %x\r"; /* getmem.cmdl (addr, addr2) */ | |
129 | dbug_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, addr2) */ | |
130 | dbug_cmds.getmem.resp_delim = ":"; /* getmem.resp_delim */ | |
131 | dbug_cmds.getmem.term = NULL; /* getmem.term */ | |
132 | dbug_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */ | |
133 | dbug_cmds.setreg.cmd = "rm %s %x\r"; /* setreg.cmd (name, value) */ | |
134 | dbug_cmds.setreg.resp_delim = NULL; /* setreg.resp_delim */ | |
135 | dbug_cmds.setreg.term = NULL; /* setreg.term */ | |
136 | dbug_cmds.setreg.term_cmd = NULL; /* setreg.term_cmd */ | |
137 | dbug_cmds.getreg.cmd = "rd %s\r"; /* getreg.cmd (name) */ | |
138 | dbug_cmds.getreg.resp_delim = ":"; /* getreg.resp_delim */ | |
139 | dbug_cmds.getreg.term = NULL; /* getreg.term */ | |
140 | dbug_cmds.getreg.term_cmd = NULL; /* getreg.term_cmd */ | |
141 | dbug_cmds.dump_registers = "rd\r"; /* dump_registers */ | |
3e43a32a MS |
142 | /* register_pattern */ |
143 | dbug_cmds.register_pattern = "\\(\\w+\\) +:\\([0-9a-fA-F]+\\b\\)"; | |
23a6d369 | 144 | dbug_cmds.supply_register = dbug_supply_register; |
c5aa993b JM |
145 | dbug_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */ |
146 | dbug_cmds.load = "dl\r"; /* download command */ | |
147 | dbug_cmds.loadresp = "\n"; /* load response */ | |
148 | dbug_cmds.prompt = "dBUG>"; /* monitor command prompt */ | |
149 | dbug_cmds.line_term = "\r"; /* end-of-line terminator */ | |
150 | dbug_cmds.cmd_end = NULL; /* optional command terminator */ | |
151 | dbug_cmds.target = &dbug_ops; /* target operations */ | |
152 | dbug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ | |
1c617db8 GS |
153 | dbug_cmds.regnames = NULL; /* registers names */ |
154 | dbug_cmds.regname = dbug_regname; | |
c5aa993b JM |
155 | dbug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */ |
156 | } /* init_debug_ops */ | |
c906108c SS |
157 | |
158 | static void | |
fba45db2 | 159 | dbug_open (char *args, int from_tty) |
c906108c SS |
160 | { |
161 | monitor_open (args, &dbug_cmds, from_tty); | |
162 | } | |
163 | ||
a78f21af AC |
164 | extern initialize_file_ftype _initialize_dbug_rom; /* -Wmissing-prototypes */ |
165 | ||
c906108c | 166 | void |
fba45db2 | 167 | _initialize_dbug_rom (void) |
c906108c | 168 | { |
c5aa993b | 169 | init_dbug_cmds (); |
c906108c SS |
170 | init_monitor_ops (&dbug_ops); |
171 | ||
172 | dbug_ops.to_shortname = "dbug"; | |
173 | dbug_ops.to_longname = "dBUG monitor"; | |
174 | dbug_ops.to_doc = "Debug via the dBUG monitor.\n\ | |
175 | Specify the serial device it is connected to (e.g. /dev/ttya)."; | |
176 | dbug_ops.to_open = dbug_open; | |
177 | ||
178 | add_target (&dbug_ops); | |
179 | } |