1 /* MI Command Set for GDB, the GNU debugger.
3 Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc.
5 Contributed by Cygnus Solutions (a Red Hat company).
7 This file is part of GDB.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 2 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA. */
27 #include "gdb_string.h"
29 extern void _initialize_mi_cmds (void);
31 static struct mi_cmd
**lookup_table (const char *command
);
32 static void build_table (struct mi_cmd
*commands
);
35 struct mi_cmd mi_cmds
[] =
37 { "break-after", { "ignore", 1 }, NULL
, NULL
},
38 { "break-catch", { NULL
, 0 }, NULL
, NULL
},
39 { "break-commands", { NULL
, 0 }, NULL
, NULL
},
40 { "break-condition", { "cond", 1 }, NULL
, NULL
},
41 { "break-delete", { "delete breakpoint", 1 }, NULL
, NULL
},
42 { "break-disable", { "disable breakpoint", 1 }, NULL
, NULL
},
43 { "break-enable", { "enable breakpoint", 1 }, NULL
, NULL
},
44 { "break-info", { "info break", 1 }, NULL
, NULL
},
45 { "break-insert", { NULL
, 0 }, 0, mi_cmd_break_insert
},
46 { "break-list", { "info break", }, NULL
, NULL
},
47 { "break-watch", { NULL
, 0 }, 0, mi_cmd_break_watch
},
48 { "data-disassemble", { NULL
, 0 }, 0, mi_cmd_disassemble
},
49 { "data-evaluate-expression", { NULL
, 0 }, 0, mi_cmd_data_evaluate_expression
},
50 { "data-list-changed-registers", { NULL
, 0 }, 0, mi_cmd_data_list_changed_registers
},
51 { "data-list-register-names", { NULL
, 0 }, 0, mi_cmd_data_list_register_names
},
52 { "data-list-register-values", { NULL
, 0 }, 0, mi_cmd_data_list_register_values
},
53 { "data-read-memory", { NULL
, 0 }, 0, mi_cmd_data_read_memory
},
54 { "data-write-memory", { NULL
, 0 }, 0, mi_cmd_data_write_memory
},
55 { "data-write-register-values", { NULL
, 0 }, 0, mi_cmd_data_write_register_values
},
56 { "display-delete", { NULL
, 0 }, NULL
, NULL
},
57 { "display-disable", { NULL
, 0 }, NULL
, NULL
},
58 { "display-enable", { NULL
, 0 }, NULL
, NULL
},
59 { "display-insert", { NULL
, 0 }, NULL
, NULL
},
60 { "display-list", { NULL
, 0 }, NULL
, NULL
},
61 { "environment-cd", { NULL
, 0 }, 0, mi_cmd_env_cd
},
62 { "environment-directory", { NULL
, 0 }, 0, mi_cmd_env_dir
},
63 { "environment-path", { NULL
, 0 }, 0, mi_cmd_env_path
},
64 { "environment-pwd", { NULL
, 0 }, 0, mi_cmd_env_pwd
},
65 { "exec-abort", { NULL
, 0 }, NULL
, NULL
},
66 { "exec-arguments", { "set args", 1 }, NULL
, NULL
},
67 { "exec-continue", { NULL
, 0 }, mi_cmd_exec_continue
},
68 { "exec-finish", { NULL
, 0 }, mi_cmd_exec_finish
},
69 { "exec-interrupt", { NULL
, 0 }, mi_cmd_exec_interrupt
},
70 { "exec-next", { NULL
, 0 }, mi_cmd_exec_next
},
71 { "exec-next-instruction", { NULL
, 0 }, mi_cmd_exec_next_instruction
},
72 { "exec-return", { NULL
, 0 }, mi_cmd_exec_return
},
73 { "exec-run", { NULL
, 0 }, mi_cmd_exec_run
},
74 { "exec-show-arguments", { NULL
, 0 }, NULL
, NULL
},
75 { "exec-signal", { NULL
, 0 }, NULL
, NULL
},
76 { "exec-step", { NULL
, 0 }, mi_cmd_exec_step
},
77 { "exec-step-instruction", { NULL
, 0 }, mi_cmd_exec_step_instruction
},
78 { "exec-until", { NULL
, 0 }, mi_cmd_exec_until
},
79 { "file-clear", { NULL
, 0 }, NULL
, NULL
},
80 { "file-exec-and-symbols", { "file", 1 }, NULL
, NULL
},
81 { "file-exec-file", { "exec-file", 1 }, NULL
, NULL
},
82 { "file-list-exec-sections", { NULL
, 0 }, NULL
, NULL
},
83 { "file-list-exec-source-file", { NULL
, 0 }, 0, mi_cmd_file_list_exec_source_file
},
84 { "file-list-exec-source-files", { NULL
, 0 }, NULL
, mi_cmd_file_list_exec_source_files
},
85 { "file-list-shared-libraries", { NULL
, 0 }, NULL
, NULL
},
86 { "file-list-symbol-files", { NULL
, 0 }, NULL
, NULL
},
87 { "file-symbol-file", { "symbol-file", 1 }, NULL
, NULL
},
88 { "gdb-complete", { NULL
, 0 }, NULL
, NULL
},
89 { "gdb-exit", { NULL
, 0 }, 0, mi_cmd_gdb_exit
},
90 { "gdb-set", { "set", 1 }, NULL
, NULL
},
91 { "gdb-show", { "show", 1 }, NULL
, NULL
},
92 { "gdb-source", { NULL
, 0 }, NULL
, NULL
},
93 { "gdb-version", { "show version", 0 }, 0 },
94 { "inferior-tty-set", { NULL
, 0 }, NULL
, mi_cmd_inferior_tty_set
},
95 { "inferior-tty-show", { NULL
, 0 }, NULL
, mi_cmd_inferior_tty_show
},
96 { "interpreter-exec", { NULL
, 0 }, 0, mi_cmd_interpreter_exec
},
97 { "kod-info", { NULL
, 0 }, NULL
, NULL
},
98 { "kod-list", { NULL
, 0 }, NULL
, NULL
},
99 { "kod-list-object-types", { NULL
, 0 }, NULL
, NULL
},
100 { "kod-show", { NULL
, 0 }, NULL
, NULL
},
101 { "overlay-auto", { NULL
, 0 }, NULL
, NULL
},
102 { "overlay-list-mapping-state", { NULL
, 0 }, NULL
, NULL
},
103 { "overlay-list-overlays", { NULL
, 0 }, NULL
, NULL
},
104 { "overlay-map", { NULL
, 0 }, NULL
, NULL
},
105 { "overlay-off", { NULL
, 0 }, NULL
, NULL
},
106 { "overlay-on", { NULL
, 0 }, NULL
, NULL
},
107 { "overlay-unmap", { NULL
, 0 }, NULL
, NULL
},
108 { "signal-handle", { NULL
, 0 }, NULL
, NULL
},
109 { "signal-list-handle-actions", { NULL
, 0 }, NULL
, NULL
},
110 { "signal-list-signal-types", { NULL
, 0 }, NULL
, NULL
},
111 { "stack-info-depth", { NULL
, 0 }, 0, mi_cmd_stack_info_depth
},
112 { "stack-info-frame", { NULL
, 0 }, 0, mi_cmd_stack_info_frame
},
113 { "stack-list-arguments", { NULL
, 0 }, 0, mi_cmd_stack_list_args
},
114 { "stack-list-exception-handlers", { NULL
, 0 }, NULL
, NULL
},
115 { "stack-list-frames", { NULL
, 0 }, 0, mi_cmd_stack_list_frames
},
116 { "stack-list-locals", { NULL
, 0 }, 0, mi_cmd_stack_list_locals
},
117 { "stack-select-frame", { NULL
, 0 }, 0, mi_cmd_stack_select_frame
},
118 { "symbol-info-address", { NULL
, 0 }, NULL
, NULL
},
119 { "symbol-info-file", { NULL
, 0 }, NULL
, NULL
},
120 { "symbol-info-function", { NULL
, 0 }, NULL
, NULL
},
121 { "symbol-info-line", { NULL
, 0 }, NULL
, NULL
},
122 { "symbol-info-symbol", { NULL
, 0 }, NULL
, NULL
},
123 { "symbol-list-functions", { NULL
, 0 }, NULL
, NULL
},
124 { "symbol-list-lines", { NULL
, 0 }, 0, mi_cmd_symbol_list_lines
},
125 { "symbol-list-types", { NULL
, 0 }, NULL
, NULL
},
126 { "symbol-list-variables", { NULL
, 0 }, NULL
, NULL
},
127 { "symbol-locate", { NULL
, 0 }, NULL
, NULL
},
128 { "symbol-type", { NULL
, 0 }, NULL
, NULL
},
129 { "target-attach", { NULL
, 0 }, NULL
, NULL
},
130 { "target-compare-sections", { NULL
, 0 }, NULL
, NULL
},
131 { "target-detach", { "detach", 0 }, 0 },
132 { "target-disconnect", { "disconnect", 0 }, 0 },
133 { "target-download", { NULL
, 0 }, mi_cmd_target_download
},
134 { "target-exec-status", { NULL
, 0 }, NULL
, NULL
},
135 { "target-list-available-targets", { NULL
, 0 }, NULL
, NULL
},
136 { "target-list-current-targets", { NULL
, 0 }, NULL
, NULL
},
137 { "target-list-parameters", { NULL
, 0 }, NULL
, NULL
},
138 { "target-select", { NULL
, 0 }, mi_cmd_target_select
},
139 { "thread-info", { NULL
, 0 }, NULL
, NULL
},
140 { "thread-list-all-threads", { NULL
, 0 }, NULL
, NULL
},
141 { "thread-list-ids", { NULL
, 0 }, 0, mi_cmd_thread_list_ids
},
142 { "thread-select", { NULL
, 0 }, 0, mi_cmd_thread_select
},
143 { "trace-actions", { NULL
, 0 }, NULL
, NULL
},
144 { "trace-delete", { NULL
, 0 }, NULL
, NULL
},
145 { "trace-disable", { NULL
, 0 }, NULL
, NULL
},
146 { "trace-dump", { NULL
, 0 }, NULL
, NULL
},
147 { "trace-enable", { NULL
, 0 }, NULL
, NULL
},
148 { "trace-exists", { NULL
, 0 }, NULL
, NULL
},
149 { "trace-find", { NULL
, 0 }, NULL
, NULL
},
150 { "trace-frame-number", { NULL
, 0 }, NULL
, NULL
},
151 { "trace-info", { NULL
, 0 }, NULL
, NULL
},
152 { "trace-insert", { NULL
, 0 }, NULL
, NULL
},
153 { "trace-list", { NULL
, 0 }, NULL
, NULL
},
154 { "trace-pass-count", { NULL
, 0 }, NULL
, NULL
},
155 { "trace-save", { NULL
, 0 }, NULL
, NULL
},
156 { "trace-start", { NULL
, 0 }, NULL
, NULL
},
157 { "trace-stop", { NULL
, 0 }, NULL
, NULL
},
158 { "var-assign", { NULL
, 0 }, 0, mi_cmd_var_assign
},
159 { "var-create", { NULL
, 0 }, 0, mi_cmd_var_create
},
160 { "var-delete", { NULL
, 0 }, 0, mi_cmd_var_delete
},
161 { "var-evaluate-expression", { NULL
, 0 }, 0, mi_cmd_var_evaluate_expression
},
162 { "var-info-expression", { NULL
, 0 }, 0, mi_cmd_var_info_expression
},
163 { "var-info-num-children", { NULL
, 0 }, 0, mi_cmd_var_info_num_children
},
164 { "var-info-type", { NULL
, 0 }, 0, mi_cmd_var_info_type
},
165 { "var-list-children", { NULL
, 0 }, 0, mi_cmd_var_list_children
},
166 { "var-set-format", { NULL
, 0 }, 0, mi_cmd_var_set_format
},
167 { "var-show-attributes", { NULL
, 0 }, 0, mi_cmd_var_show_attributes
},
168 { "var-show-format", { NULL
, 0 }, 0, mi_cmd_var_show_format
},
169 { "var-update", { NULL
, 0 }, 0, mi_cmd_var_update
},
173 /* Pointer to the mi command table (built at run time) */
175 static struct mi_cmd
**mi_table
;
177 /* A prime large enough to accomodate the entire command table */
183 /* Exported function used to obtain info from the table */
185 mi_lookup (const char *command
)
187 return *lookup_table (command
);
190 /* stat collecting */
197 struct mi_cmd_stats stats
;
199 /* our lookup function */
200 static struct mi_cmd
**
201 lookup_table (const char *command
)
204 unsigned int index
= 0;
205 /* compute our hash */
206 for (chp
= command
; *chp
; chp
++)
208 /* some what arbitrary */
209 index
= ((index
<< 6) + (unsigned int) *chp
) % MI_TABLE_SIZE
;
214 struct mi_cmd
**entry
= &mi_table
[index
];
217 /* not found, return pointer to next free. */
221 if (strcmp (command
, (*entry
)->name
) == 0)
224 return entry
; /* found */
226 index
= (index
+ 1) % MI_TABLE_SIZE
;
232 build_table (struct mi_cmd
*commands
)
236 struct mi_cmd
*command
;
237 int sizeof_table
= sizeof (struct mi_cmd
**) * MI_TABLE_SIZE
;
239 mi_table
= xmalloc (sizeof_table
);
240 memset (mi_table
, 0, sizeof_table
);
241 for (command
= commands
; command
->name
!= 0; command
++)
243 struct mi_cmd
**entry
= lookup_table (command
->name
);
245 internal_error (__FILE__
, __LINE__
,
246 _("command `%s' appears to be duplicated"),
251 fprintf_unfiltered (gdb_stdlog
, "%-30s %2d\n",
252 command
->name
, stats
.rehash
- nr_rehash
);
255 nr_rehash
= stats
.rehash
;
259 fprintf_filtered (gdb_stdlog
, "Average %3.1f\n",
260 (double) nr_rehash
/ (double) nr_entries
);
265 _initialize_mi_cmds (void)
267 build_table (mi_cmds
);
268 memset (&stats
, 0, sizeof (stats
));