1 |
1181 |
sfurman |
/* MI Command Set.
|
2 |
|
|
Copyright 2000, 2001 Free Software Foundation, Inc.
|
3 |
|
|
Contributed by Cygnus Solutions (a Red Hat company).
|
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
|
19 |
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
20 |
|
|
Boston, MA 02111-1307, USA. */
|
21 |
|
|
|
22 |
|
|
#include "defs.h"
|
23 |
|
|
#include "top.h"
|
24 |
|
|
#include "mi-cmds.h"
|
25 |
|
|
#include "gdb_string.h"
|
26 |
|
|
|
27 |
|
|
extern void _initialize_mi_cmds (void);
|
28 |
|
|
struct mi_cmd;
|
29 |
|
|
static struct mi_cmd **lookup_table (const char *command);
|
30 |
|
|
static void build_table (struct mi_cmd *commands);
|
31 |
|
|
|
32 |
|
|
|
33 |
|
|
struct mi_cmd mi_cmds[] =
|
34 |
|
|
{
|
35 |
|
|
{"break-after", "ignore %s", 0},
|
36 |
|
|
{"break-catch", 0, 0},
|
37 |
|
|
{"break-commands", 0, 0},
|
38 |
|
|
{"break-condition", "cond %s", 0},
|
39 |
|
|
{"break-delete", "delete breakpoint %s", 0},
|
40 |
|
|
{"break-disable", "disable breakpoint %s", 0},
|
41 |
|
|
{"break-enable", "enable breakpoint %s", 0},
|
42 |
|
|
{"break-info", "info break %s", 0},
|
43 |
|
|
{"break-insert", 0, 0, mi_cmd_break_insert},
|
44 |
|
|
{"break-list", "info break", 0},
|
45 |
|
|
{"break-watch", 0, 0, mi_cmd_break_watch},
|
46 |
|
|
{"data-disassemble", 0, 0, mi_cmd_disassemble},
|
47 |
|
|
{"data-evaluate-expression", 0, 0, mi_cmd_data_evaluate_expression},
|
48 |
|
|
{"data-list-changed-registers", 0, 0, mi_cmd_data_list_changed_registers},
|
49 |
|
|
{"data-list-register-names", 0, 0, mi_cmd_data_list_register_names},
|
50 |
|
|
{"data-list-register-values", 0, 0, mi_cmd_data_list_register_values},
|
51 |
|
|
{"data-read-memory", 0, 0, mi_cmd_data_read_memory},
|
52 |
|
|
{"data-write-memory", 0, 0, mi_cmd_data_write_memory},
|
53 |
|
|
{"data-write-register-values", 0, 0, mi_cmd_data_write_register_values},
|
54 |
|
|
{"display-delete", 0, 0},
|
55 |
|
|
{"display-disable", 0, 0},
|
56 |
|
|
{"display-enable", 0, 0},
|
57 |
|
|
{"display-insert", 0, 0},
|
58 |
|
|
{"display-list", 0, 0},
|
59 |
|
|
{"environment-cd", "cd %s", 0},
|
60 |
|
|
{"environment-directory", "dir %s", 0},
|
61 |
|
|
{"environment-path", "path %s", 0},
|
62 |
|
|
{"environment-pwd", "pwd", 0},
|
63 |
|
|
{"exec-abort", 0, 0},
|
64 |
|
|
{"exec-arguments", "set args %s", 0},
|
65 |
|
|
{"exec-continue", 0, mi_cmd_exec_continue},
|
66 |
|
|
{"exec-finish", 0, mi_cmd_exec_finish},
|
67 |
|
|
{"exec-interrupt", 0, mi_cmd_exec_interrupt},
|
68 |
|
|
{"exec-next", 0, mi_cmd_exec_next},
|
69 |
|
|
{"exec-next-instruction", 0, mi_cmd_exec_next_instruction},
|
70 |
|
|
{"exec-return", 0, mi_cmd_exec_return},
|
71 |
|
|
{"exec-run", 0, mi_cmd_exec_run},
|
72 |
|
|
{"exec-show-arguments", 0, 0},
|
73 |
|
|
{"exec-signal", 0, 0},
|
74 |
|
|
{"exec-step", 0, mi_cmd_exec_step},
|
75 |
|
|
{"exec-step-instruction", 0, mi_cmd_exec_step_instruction},
|
76 |
|
|
{"exec-until", 0, mi_cmd_exec_until},
|
77 |
|
|
{"file-clear", 0, 0},
|
78 |
|
|
{"file-exec-and-symbols", "file %s", 0},
|
79 |
|
|
{"file-exec-file", "exec-file %s", 0},
|
80 |
|
|
{"file-list-exec-sections", 0, 0},
|
81 |
|
|
{"file-list-exec-source-files", 0, 0},
|
82 |
|
|
{"file-list-shared-libraries", 0, 0},
|
83 |
|
|
{"file-list-symbol-files", 0, 0},
|
84 |
|
|
{"file-symbol-file", "symbol-file %s", 0},
|
85 |
|
|
{"gdb-complete", 0, 0},
|
86 |
|
|
{"gdb-exit", 0, 0, mi_cmd_gdb_exit},
|
87 |
|
|
{"gdb-set", "set %s", 0},
|
88 |
|
|
{"gdb-show", "show %s", 0},
|
89 |
|
|
{"gdb-source", 0, 0},
|
90 |
|
|
{"gdb-version", "show version", 0},
|
91 |
|
|
{"kod-info", 0, 0},
|
92 |
|
|
{"kod-list", 0, 0},
|
93 |
|
|
{"kod-list-object-types", 0, 0},
|
94 |
|
|
{"kod-show", 0, 0},
|
95 |
|
|
{"overlay-auto", 0, 0},
|
96 |
|
|
{"overlay-list-mapping-state", 0, 0},
|
97 |
|
|
{"overlay-list-overlays", 0, 0},
|
98 |
|
|
{"overlay-map", 0, 0},
|
99 |
|
|
{"overlay-off", 0, 0},
|
100 |
|
|
{"overlay-on", 0, 0},
|
101 |
|
|
{"overlay-unmap", 0, 0},
|
102 |
|
|
{"signal-handle", 0, 0},
|
103 |
|
|
{"signal-list-handle-actions", 0, 0},
|
104 |
|
|
{"signal-list-signal-types", 0, 0},
|
105 |
|
|
{"stack-info-depth", 0, 0, mi_cmd_stack_info_depth},
|
106 |
|
|
{"stack-info-frame", 0, 0},
|
107 |
|
|
{"stack-list-arguments", 0, 0, mi_cmd_stack_list_args},
|
108 |
|
|
{"stack-list-exception-handlers", 0, 0},
|
109 |
|
|
{"stack-list-frames", 0, 0, mi_cmd_stack_list_frames},
|
110 |
|
|
{"stack-list-locals", 0, 0, mi_cmd_stack_list_locals},
|
111 |
|
|
{"stack-select-frame", 0, 0, mi_cmd_stack_select_frame},
|
112 |
|
|
{"symbol-info-address", 0, 0},
|
113 |
|
|
{"symbol-info-file", 0, 0},
|
114 |
|
|
{"symbol-info-function", 0, 0},
|
115 |
|
|
{"symbol-info-line", 0, 0},
|
116 |
|
|
{"symbol-info-symbol", 0, 0},
|
117 |
|
|
{"symbol-list-functions", 0, 0},
|
118 |
|
|
{"symbol-list-types", 0, 0},
|
119 |
|
|
{"symbol-list-variables", 0, 0},
|
120 |
|
|
{"symbol-locate", 0, 0},
|
121 |
|
|
{"symbol-type", 0, 0},
|
122 |
|
|
{"target-attach", 0, 0},
|
123 |
|
|
{"target-compare-sections", 0, 0},
|
124 |
|
|
{"target-detach", "detach", 0},
|
125 |
|
|
{"target-download", 0, mi_cmd_target_download},
|
126 |
|
|
{"target-exec-status", 0, 0},
|
127 |
|
|
{"target-list-available-targets", 0, 0},
|
128 |
|
|
{"target-list-current-targets", 0, 0},
|
129 |
|
|
{"target-list-parameters", 0, 0},
|
130 |
|
|
{"target-select", 0, mi_cmd_target_select},
|
131 |
|
|
{"thread-info", 0, 0},
|
132 |
|
|
{"thread-list-all-threads", 0, 0},
|
133 |
|
|
{"thread-list-ids", 0, 0, mi_cmd_thread_list_ids},
|
134 |
|
|
{"thread-select", 0, 0, mi_cmd_thread_select},
|
135 |
|
|
{"trace-actions", 0, 0},
|
136 |
|
|
{"trace-delete", 0, 0},
|
137 |
|
|
{"trace-disable", 0, 0},
|
138 |
|
|
{"trace-dump", 0, 0},
|
139 |
|
|
{"trace-enable", 0, 0},
|
140 |
|
|
{"trace-exists", 0, 0},
|
141 |
|
|
{"trace-find", 0, 0},
|
142 |
|
|
{"trace-frame-number", 0, 0},
|
143 |
|
|
{"trace-info", 0, 0},
|
144 |
|
|
{"trace-insert", 0, 0},
|
145 |
|
|
{"trace-list", 0, 0},
|
146 |
|
|
{"trace-pass-count", 0, 0},
|
147 |
|
|
{"trace-save", 0, 0},
|
148 |
|
|
{"trace-start", 0, 0},
|
149 |
|
|
{"trace-stop", 0, 0},
|
150 |
|
|
{"var-assign", 0, 0, mi_cmd_var_assign},
|
151 |
|
|
{"var-create", 0, 0, mi_cmd_var_create},
|
152 |
|
|
{"var-delete", 0, 0, mi_cmd_var_delete},
|
153 |
|
|
{"var-evaluate-expression", 0, 0, mi_cmd_var_evaluate_expression},
|
154 |
|
|
{"var-info-expression", 0, 0, mi_cmd_var_info_expression},
|
155 |
|
|
{"var-info-num-children", 0, 0, mi_cmd_var_info_num_children},
|
156 |
|
|
{"var-info-type", 0, 0, mi_cmd_var_info_type},
|
157 |
|
|
{"var-list-children", 0, 0, mi_cmd_var_list_children},
|
158 |
|
|
{"var-set-format", 0, 0, mi_cmd_var_set_format},
|
159 |
|
|
{"var-show-attributes", 0, 0, mi_cmd_var_show_attributes},
|
160 |
|
|
{"var-show-format", 0, 0, mi_cmd_var_show_format},
|
161 |
|
|
{"var-update", 0, 0, mi_cmd_var_update},
|
162 |
|
|
{0,}
|
163 |
|
|
};
|
164 |
|
|
|
165 |
|
|
/* Pointer to the mi command table (built at run time) */
|
166 |
|
|
|
167 |
|
|
static struct mi_cmd **mi_table;
|
168 |
|
|
|
169 |
|
|
/* A prime large enough to accomodate the entire command table */
|
170 |
|
|
enum
|
171 |
|
|
{
|
172 |
|
|
MI_TABLE_SIZE = 227
|
173 |
|
|
};
|
174 |
|
|
|
175 |
|
|
/* Exported function used to obtain info from the table */
|
176 |
|
|
struct mi_cmd *
|
177 |
|
|
mi_lookup (const char *command)
|
178 |
|
|
{
|
179 |
|
|
return *lookup_table (command);
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
/* stat collecting */
|
183 |
|
|
struct mi_cmd_stats
|
184 |
|
|
{
|
185 |
|
|
int hit;
|
186 |
|
|
int miss;
|
187 |
|
|
int rehash;
|
188 |
|
|
};
|
189 |
|
|
struct mi_cmd_stats stats;
|
190 |
|
|
|
191 |
|
|
/* our lookup function */
|
192 |
|
|
static struct mi_cmd **
|
193 |
|
|
lookup_table (const char *command)
|
194 |
|
|
{
|
195 |
|
|
const char *chp;
|
196 |
|
|
unsigned int index = 0;
|
197 |
|
|
/* compute our hash */
|
198 |
|
|
for (chp = command; *chp; chp++)
|
199 |
|
|
{
|
200 |
|
|
/* some what arbitrary */
|
201 |
|
|
index = ((index << 6) + (unsigned int) *chp) % MI_TABLE_SIZE;
|
202 |
|
|
}
|
203 |
|
|
/* look it up */
|
204 |
|
|
while (1)
|
205 |
|
|
{
|
206 |
|
|
struct mi_cmd **entry = &mi_table[index];
|
207 |
|
|
if ((*entry) == 0)
|
208 |
|
|
{
|
209 |
|
|
/* not found, return pointer to next free. */
|
210 |
|
|
stats.miss++;
|
211 |
|
|
return entry;
|
212 |
|
|
}
|
213 |
|
|
if (strcmp (command, (*entry)->name) == 0)
|
214 |
|
|
{
|
215 |
|
|
stats.hit++;
|
216 |
|
|
return entry; /* found */
|
217 |
|
|
}
|
218 |
|
|
index = (index + 1) % MI_TABLE_SIZE;
|
219 |
|
|
stats.rehash++;
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
static void
|
224 |
|
|
build_table (struct mi_cmd *commands)
|
225 |
|
|
{
|
226 |
|
|
int nr_rehash = 0;
|
227 |
|
|
int nr_entries = 0;
|
228 |
|
|
struct mi_cmd *command;
|
229 |
|
|
int sizeof_table = sizeof (struct mi_cmd **) * MI_TABLE_SIZE;
|
230 |
|
|
|
231 |
|
|
mi_table = xmalloc (sizeof_table);
|
232 |
|
|
memset (mi_table, 0, sizeof_table);
|
233 |
|
|
for (command = commands; command->name != 0; command++)
|
234 |
|
|
{
|
235 |
|
|
struct mi_cmd **entry = lookup_table (command->name);
|
236 |
|
|
if (*entry)
|
237 |
|
|
internal_error (__FILE__, __LINE__,
|
238 |
|
|
"command `%s' appears to be duplicated",
|
239 |
|
|
command->name);
|
240 |
|
|
*entry = command;
|
241 |
|
|
if (0)
|
242 |
|
|
{
|
243 |
|
|
fprintf_unfiltered (gdb_stdlog, "%-30s %2d\n",
|
244 |
|
|
command->name, stats.rehash - nr_rehash);
|
245 |
|
|
}
|
246 |
|
|
nr_entries++;
|
247 |
|
|
nr_rehash = stats.rehash;
|
248 |
|
|
}
|
249 |
|
|
if (0)
|
250 |
|
|
{
|
251 |
|
|
fprintf_filtered (gdb_stdlog, "Average %3.1f\n",
|
252 |
|
|
(double) nr_rehash / (double) nr_entries);
|
253 |
|
|
}
|
254 |
|
|
}
|
255 |
|
|
|
256 |
|
|
void
|
257 |
|
|
_initialize_mi_cmds (void)
|
258 |
|
|
{
|
259 |
|
|
build_table (mi_cmds);
|
260 |
|
|
memset (&stats, 0, sizeof (stats));
|
261 |
|
|
}
|