Commit | Line | Data |
---|---|---|
51d6a954 | 1 | /* Remote debugging interface ROM monitors. |
c84e5000 | 2 | * Copyright 1990, 1991, 1992, 1996 Free Software Foundation, Inc. |
054240ec RS |
3 | * Contributed by Cygnus Support. Written by Rob Savoye for Cygnus. |
4 | * | |
5 | * This file is part of GDB. | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
6c9638b4 | 19 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
054240ec RS |
20 | */ |
21 | ||
5de0c648 SG |
22 | #include "serial.h" |
23 | ||
1265e2d8 SG |
24 | /* This structure describes the strings necessary to give small command |
25 | sequences to the monitor, and parse the response. | |
26 | ||
27 | CMD is the actual command typed at the monitor. Usually this has embedded | |
28 | sequences ala printf, which are substituted with the arguments appropriate | |
29 | to that type of command. Ie: to examine a register, we substitute the | |
30 | register name for the first arg. To modify memory, we substitute the memory | |
31 | location and the new contents for the first and second args, etc... | |
32 | ||
33 | RESP_DELIM used to home in on the response string, and is used to | |
34 | disambiguate the answer within the pile of text returned by the monitor. | |
35 | This should be a unique string that immediately precedes the answer. Ie: if | |
36 | your monitor prints out `PC: 00000001= ' in response to asking for the PC, | |
37 | you should use `: ' as the RESP_DELIM. RESP_DELIM may be NULL if the res- | |
38 | ponse is going to be ignored, or has no particular leading text. | |
39 | ||
40 | TERM is the string that the monitor outputs to indicate that it is idle, and | |
41 | waiting for input. This is usually a prompt of some sort. In the previous | |
42 | example, it would be `= '. It is important that TERM really means that the | |
43 | monitor is idle, otherwise GDB may try to type at it when it isn't ready for | |
44 | input. This is a problem because many monitors cannot deal with type-ahead. | |
45 | TERM may be NULL if the normal prompt is output. | |
46 | ||
47 | TERM_CMD is used to quit out of the subcommand mode and get back to the main | |
48 | prompt. TERM_CMD may be NULL if it isn't necessary. It will also be | |
49 | ignored if TERM is NULL. | |
50 | */ | |
51 | ||
a25a9f49 SG |
52 | struct memrw_cmd |
53 | { | |
54 | char *cmdb; /* Command to send for byte read/write */ | |
55 | char *cmdw; /* Command for word (16 bit) read/write */ | |
56 | char *cmdl; /* Command for long (32 bit) read/write */ | |
57 | char *cmdll; /* Command for long long (64 bit) read/write */ | |
1265e2d8 SG |
58 | char *resp_delim; /* String just prior to the desired value */ |
59 | char *term; /* Terminating string to search for */ | |
60 | char *term_cmd; /* String to get out of sub-mode (if necessary) */ | |
61 | }; | |
62 | ||
a25a9f49 SG |
63 | struct regrw_cmd |
64 | { | |
65 | char *cmd; /* Command to send for reg read/write */ | |
fe5cfadd SG |
66 | char *resp_delim; /* String (actually a regexp if getmem) just |
67 | prior to the desired value */ | |
a25a9f49 SG |
68 | char *term; /* Terminating string to search for */ |
69 | char *term_cmd; /* String to get out of sub-mode (if necessary) */ | |
70 | }; | |
71 | ||
72 | struct monitor_ops | |
73 | { | |
74 | int flags; /* See below */ | |
75 | char **init; /* List of init commands. NULL terminated. */ | |
76 | char *cont; /* continue command */ | |
77 | char *step; /* single step */ | |
a706069f | 78 | char *stop; /* Interrupt program string */ |
a25a9f49 SG |
79 | char *set_break; /* set a breakpoint */ |
80 | char *clr_break; /* clear a breakpoint */ | |
81 | char *clr_all_break; /* Clear all breakpoints */ | |
82 | char *fill; /* Memory fill cmd (addr len val) */ | |
83 | struct memrw_cmd setmem; /* set memory to a value */ | |
84 | struct memrw_cmd getmem; /* display memory */ | |
85 | struct regrw_cmd setreg; /* set a register */ | |
86 | struct regrw_cmd getreg; /* get a register */ | |
2081365f SG |
87 | /* Some commands can dump a bunch of registers |
88 | at once. This comes as a set of REG=VAL | |
89 | pairs. This should be called for each pair | |
90 | of registers that we can parse to supply | |
91 | GDB with the value of a register. */ | |
a25a9f49 | 92 | char *dump_registers; /* Command to dump all regs at once */ |
2081365f | 93 | char *register_pattern; /* Pattern that picks out register from reg dump */ |
a25a9f49 | 94 | void (*supply_register) PARAMS ((char *name, int namelen, char *val, int vallen)); |
5de0c648 | 95 | void (*load_routine) PARAMS ((serial_t desc, char *file, int hashmark)); /* Download routine */ |
a25a9f49 SG |
96 | char *load; /* load command */ |
97 | char *loadresp; /* Response to load command */ | |
98 | char *prompt; /* monitor command prompt */ | |
d8afcce9 | 99 | char *line_term; /* end-of-command delimitor */ |
a25a9f49 | 100 | char *cmd_end; /* optional command terminator */ |
51d6a954 | 101 | struct target_ops *target; /* target operations */ |
a25a9f49 SG |
102 | int stopbits; /* number of stop bits */ |
103 | char **regnames; /* array of register names in ascii */ | |
104 | int magic; /* Check value */ | |
054240ec RS |
105 | }; |
106 | ||
a25a9f49 SG |
107 | #define MONITOR_OPS_MAGIC 600925 |
108 | ||
109 | /* Flag defintions */ | |
110 | ||
721ccd80 MM |
111 | #define MO_CLR_BREAK_USES_ADDR 0x1 /* If set, then clear breakpoint command |
112 | uses address, otherwise it uses an index | |
113 | returned by the monitor. */ | |
114 | #define MO_FILL_USES_ADDR 0x2 /* If set, then memory fill command uses | |
115 | STARTADDR, ENDADDR+1, VALUE as args, else it | |
116 | uses STARTADDR, LENGTH, VALUE as args. */ | |
117 | #define MO_NEED_REGDUMP_AFTER_CONT 0x4 /* If set, then monitor doesn't auto- | |
118 | matically supply register dump when | |
119 | coming back after a continue. */ | |
120 | #define MO_GETMEM_NEEDS_RANGE 0x8 /* getmem needs start addr and end addr */ | |
121 | #define MO_GETMEM_READ_SINGLE 0x10 /* getmem can only read one loc at a time */ | |
122 | #define MO_HANDLE_NL 0x20 /* handle \r\n combinations */ | |
a25a9f49 | 123 | |
2e665cd3 DP |
124 | #define MO_NO_ECHO_ON_OPEN 0x40 /* don't expect echos in monitor_open */ |
125 | ||
126 | #define MO_SEND_BREAK_ON_STOP 0x80 /* If set, send break to stop monitor */ | |
127 | ||
054240ec RS |
128 | extern struct monitor_ops *current_monitor; |
129 | ||
51d6a954 | 130 | #define LOADTYPES (current_monitor->loadtypes) |
b3b8d9bf | 131 | #define LOADPROTOS (current_monitor->loadprotos) |
51d6a954 | 132 | #define INIT_CMD (current_monitor->init) |
a25a9f49 | 133 | #define CONT_CMD (current_monitor->cont) |
054240ec RS |
134 | #define STEP_CMD (current_monitor->step) |
135 | #define SET_BREAK_CMD (current_monitor->set_break) | |
136 | #define CLR_BREAK_CMD (current_monitor->clr_break) | |
51d6a954 RS |
137 | #define SET_MEM (current_monitor->setmem) |
138 | #define GET_MEM (current_monitor->getmem) | |
054240ec | 139 | #define LOAD_CMD (current_monitor->load) |
51d6a954 RS |
140 | #define GET_REG (current_monitor->regget) |
141 | #define SET_REG (current_monitor->regset) | |
054240ec RS |
142 | #define CMD_END (current_monitor->cmd_end) |
143 | #define CMD_DELIM (current_monitor->cmd_delim) | |
144 | #define PROMPT (current_monitor->prompt) | |
51d6a954 RS |
145 | #define TARGET_OPS (current_monitor->target) |
146 | #define TARGET_NAME (current_monitor->target->to_shortname) | |
cf51c601 RS |
147 | #define BAUDRATES (current_monitor->baudrates) |
148 | #define STOPBITS (current_monitor->stopbits) | |
51d6a954 RS |
149 | #define REGNAMES(x) (current_monitor->regnames[x]) |
150 | #define ROMCMD(x) (x.cmd) | |
151 | #define ROMDELIM(x) (x.delim) | |
152 | #define ROMRES(x) (x.result) | |
054240ec RS |
153 | |
154 | #define push_monitor(x) current_monitor = x; | |
51d6a954 | 155 | |
df3cf84a RS |
156 | #define SREC_SIZE 160 |
157 | ||
df3cf84a RS |
158 | /* |
159 | * FIXME: These are to temporarily maintain compatability with the | |
160 | * old monitor structure till remote-mon.c is fixed to work | |
161 | * like the *-rom.c files. | |
162 | */ | |
163 | #define MEM_PROMPT (current_monitor->loadtypes) | |
164 | #define MEM_SET_CMD (current_monitor->setmem) | |
165 | #define MEM_DIS_CMD (current_monitor->getmem) | |
166 | #define REG_DELIM (current_monitor->regset.delim) | |
32fa4b59 | 167 | |
5de0c648 | 168 | extern void monitor_open PARAMS ((char *args, struct monitor_ops *ops, int from_tty)); |
c84e5000 | 169 | extern void monitor_close PARAMS ((int quitting)); |
5de0c648 SG |
170 | extern char *monitor_supply_register PARAMS ((int regno, char *valstr)); |
171 | extern int monitor_expect PARAMS ((char *prompt, char *buf, int buflen)); | |
172 | extern int monitor_expect_prompt PARAMS ((char *buf, int buflen)); | |
e3033bb0 C |
173 | extern void monitor_printf PARAMS ((char *, ...)) |
174 | ATTR_FORMAT(printf, 1, 2); | |
175 | extern void monitor_printf_noecho PARAMS ((char *, ...)) | |
176 | ATTR_FORMAT(printf, 1, 2); | |
d108166f | 177 | extern void init_monitor_ops PARAMS ((struct target_ops *)); |