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