command.h revision 1.6 1 1.1 christos /* Header file for command creation.
2 1.1 christos
3 1.6 christos Copyright (C) 1986-2016 Free Software Foundation, Inc.
4 1.1 christos
5 1.1 christos This program is free software; you can redistribute it and/or modify
6 1.1 christos it under the terms of the GNU General Public License as published by
7 1.1 christos the Free Software Foundation; either version 3 of the License, or
8 1.1 christos (at your option) any later version.
9 1.1 christos
10 1.1 christos This program is distributed in the hope that it will be useful,
11 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 1.1 christos GNU General Public License for more details.
14 1.1 christos
15 1.1 christos You should have received a copy of the GNU General Public License
16 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 1.1 christos
18 1.1 christos #if !defined (COMMAND_H)
19 1.1 christos #define COMMAND_H 1
20 1.1 christos
21 1.1 christos #include "gdb_vecs.h"
22 1.1 christos
23 1.1 christos /* This file defines the public interface for any code wanting to
24 1.1 christos create commands. */
25 1.1 christos
26 1.1 christos /* Command classes are top-level categories into which commands are
27 1.1 christos broken down for "help" purposes.
28 1.1 christos
29 1.1 christos Notes on classes: class_alias is for alias commands which are not
30 1.1 christos abbreviations of the original command. class-pseudo is for
31 1.1 christos commands which are not really commands nor help topics ("stop"). */
32 1.1 christos
33 1.1 christos enum command_class
34 1.1 christos {
35 1.1 christos /* Special args to help_list */
36 1.1 christos class_deprecated = -3, all_classes = -2, all_commands = -1,
37 1.1 christos /* Classes of commands */
38 1.1 christos no_class = -1, class_run = 0, class_vars, class_stack, class_files,
39 1.1 christos class_support, class_info, class_breakpoint, class_trace,
40 1.1 christos class_alias, class_bookmark, class_obscure, class_maintenance,
41 1.1 christos class_pseudo, class_tui, class_user, class_xdb,
42 1.1 christos no_set_class /* Used for "show" commands that have no corresponding
43 1.1 christos "set" command. */
44 1.1 christos };
45 1.1 christos
46 1.1 christos /* FIXME: cagney/2002-03-17: Once cmd_type() has been removed, ``enum
47 1.1 christos cmd_types'' can be moved from "command.h" to "cli-decode.h". */
48 1.1 christos /* Not a set/show command. Note that some commands which begin with
49 1.1 christos "set" or "show" might be in this category, if their syntax does
50 1.1 christos not fall into one of the following categories. */
51 1.1 christos typedef enum cmd_types
52 1.1 christos {
53 1.1 christos not_set_cmd,
54 1.1 christos set_cmd,
55 1.1 christos show_cmd
56 1.1 christos }
57 1.1 christos cmd_types;
58 1.1 christos
59 1.1 christos /* Types of "set" or "show" command. */
60 1.1 christos typedef enum var_types
61 1.1 christos {
62 1.1 christos /* "on" or "off". *VAR is an integer which is nonzero for on,
63 1.1 christos zero for off. */
64 1.1 christos var_boolean,
65 1.1 christos
66 1.1 christos /* "on" / "true" / "enable" or "off" / "false" / "disable" or
67 1.1 christos "auto. *VAR is an ``enum auto_boolean''. NOTE: In general a
68 1.1 christos custom show command will need to be implemented - one that for
69 1.1 christos "auto" prints both the "auto" and the current auto-selected
70 1.1 christos value. */
71 1.1 christos var_auto_boolean,
72 1.1 christos
73 1.1 christos /* Unsigned Integer. *VAR is an unsigned int. The user can type
74 1.1 christos 0 to mean "unlimited", which is stored in *VAR as UINT_MAX. */
75 1.1 christos var_uinteger,
76 1.1 christos
77 1.1 christos /* Like var_uinteger but signed. *VAR is an int. The user can
78 1.1 christos type 0 to mean "unlimited", which is stored in *VAR as
79 1.1 christos INT_MAX. The only remaining use of it is the Python API.
80 1.1 christos Don't use it elsewhere. */
81 1.1 christos var_integer,
82 1.1 christos
83 1.1 christos /* String which the user enters with escapes (e.g. the user types
84 1.1 christos \n and it is a real newline in the stored string).
85 1.1 christos *VAR is a malloc'd string, or NULL if the string is empty. */
86 1.1 christos var_string,
87 1.1 christos /* String which stores what the user types verbatim.
88 1.1 christos *VAR is a malloc'd string, or NULL if the string is empty. */
89 1.1 christos var_string_noescape,
90 1.1 christos /* String which stores a filename. (*VAR) is a malloc'd string,
91 1.1 christos or "" if the string was empty. */
92 1.1 christos var_optional_filename,
93 1.1 christos /* String which stores a filename. (*VAR) is a malloc'd
94 1.1 christos string. */
95 1.1 christos var_filename,
96 1.1 christos /* ZeroableInteger. *VAR is an int. Like var_integer except
97 1.1 christos that zero really means zero. */
98 1.1 christos var_zinteger,
99 1.1 christos /* ZeroableUnsignedInteger. *VAR is an unsigned int. Zero really
100 1.1 christos means zero. */
101 1.1 christos var_zuinteger,
102 1.1 christos /* ZeroableUnsignedInteger with unlimited value. *VAR is an int,
103 1.1 christos but its range is [0, INT_MAX]. -1 stands for unlimited and
104 1.1 christos other negative numbers are not allowed. */
105 1.1 christos var_zuinteger_unlimited,
106 1.1 christos /* Enumerated type. Can only have one of the specified values.
107 1.1 christos *VAR is a char pointer to the name of the element that we
108 1.1 christos find. */
109 1.1 christos var_enum
110 1.1 christos }
111 1.1 christos var_types;
112 1.1 christos
113 1.1 christos /* This structure records one command'd definition. */
114 1.1 christos struct cmd_list_element;
115 1.1 christos
116 1.3 christos typedef void cmd_cfunc_ftype (char *args, int from_tty);
117 1.3 christos
118 1.6 christos /* This structure specifies notifications to be suppressed by a cli
119 1.6 christos command interpreter. */
120 1.6 christos
121 1.6 christos struct cli_suppress_notification
122 1.6 christos {
123 1.6 christos /* Inferior, thread, frame selected notification suppressed? */
124 1.6 christos int user_selected_context;
125 1.6 christos };
126 1.6 christos
127 1.6 christos extern struct cli_suppress_notification cli_suppress_notification;
128 1.6 christos
129 1.1 christos /* Forward-declarations of the entry-points of cli/cli-decode.c. */
130 1.1 christos
131 1.1 christos /* API to the manipulation of command lists. */
132 1.1 christos
133 1.1 christos extern int valid_user_defined_cmd_name_p (const char *name);
134 1.1 christos
135 1.1 christos extern struct cmd_list_element *add_cmd (const char *, enum command_class,
136 1.3 christos cmd_cfunc_ftype *fun,
137 1.3 christos const char *,
138 1.1 christos struct cmd_list_element **);
139 1.1 christos
140 1.1 christos extern struct cmd_list_element *add_alias_cmd (const char *, const char *,
141 1.1 christos enum command_class, int,
142 1.1 christos struct cmd_list_element **);
143 1.1 christos
144 1.1 christos extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class,
145 1.3 christos cmd_cfunc_ftype *fun,
146 1.3 christos const char *,
147 1.1 christos struct cmd_list_element **,
148 1.3 christos const char *, int,
149 1.1 christos struct cmd_list_element **);
150 1.1 christos
151 1.1 christos extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *,
152 1.1 christos enum command_class,
153 1.3 christos cmd_cfunc_ftype *fun,
154 1.3 christos const char *,
155 1.1 christos struct cmd_list_element
156 1.3 christos **, const char *, int,
157 1.1 christos struct cmd_list_element
158 1.1 christos **);
159 1.1 christos
160 1.1 christos /* Set the commands corresponding callback. */
161 1.1 christos
162 1.1 christos extern void set_cmd_cfunc (struct cmd_list_element *cmd,
163 1.1 christos cmd_cfunc_ftype *cfunc);
164 1.1 christos
165 1.1 christos typedef void cmd_sfunc_ftype (char *args, int from_tty,
166 1.1 christos struct cmd_list_element *c);
167 1.1 christos extern void set_cmd_sfunc (struct cmd_list_element *cmd,
168 1.1 christos cmd_sfunc_ftype *sfunc);
169 1.1 christos
170 1.1 christos typedef VEC (char_ptr) *completer_ftype (struct cmd_list_element *,
171 1.1 christos const char *, const char *);
172 1.1 christos
173 1.3 christos typedef void completer_ftype_void (struct cmd_list_element *,
174 1.3 christos const char *, const char *);
175 1.3 christos
176 1.1 christos extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *);
177 1.1 christos
178 1.3 christos /* Set the completer_handle_brkchars callback. */
179 1.3 christos
180 1.3 christos extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *,
181 1.3 christos completer_ftype_void *);
182 1.3 christos
183 1.1 christos /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs
184 1.1 christos around in cmd objects to test the value of the commands sfunc(). */
185 1.1 christos extern int cmd_cfunc_eq (struct cmd_list_element *cmd,
186 1.3 christos cmd_cfunc_ftype *cfun);
187 1.1 christos
188 1.1 christos /* Each command object has a local context attached to it. */
189 1.1 christos extern void set_cmd_context (struct cmd_list_element *cmd,
190 1.1 christos void *context);
191 1.1 christos extern void *get_cmd_context (struct cmd_list_element *cmd);
192 1.1 christos
193 1.1 christos
194 1.1 christos /* Execute CMD's pre/post hook. Throw an error if the command fails.
195 1.1 christos If already executing this pre/post hook, or there is no pre/post
196 1.1 christos hook, the call is silently ignored. */
197 1.1 christos extern void execute_cmd_pre_hook (struct cmd_list_element *cmd);
198 1.1 christos extern void execute_cmd_post_hook (struct cmd_list_element *cmd);
199 1.1 christos
200 1.1 christos /* Return the type of the command. */
201 1.1 christos extern enum cmd_types cmd_type (struct cmd_list_element *cmd);
202 1.1 christos
203 1.1 christos /* Flag for an ambiguous cmd_list result. */
204 1.1 christos #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1)
205 1.1 christos
206 1.1 christos extern struct cmd_list_element *lookup_cmd (const char **,
207 1.1 christos struct cmd_list_element *, char *,
208 1.1 christos int, int);
209 1.1 christos
210 1.1 christos extern struct cmd_list_element *lookup_cmd_1 (const char **,
211 1.1 christos struct cmd_list_element *,
212 1.1 christos struct cmd_list_element **,
213 1.1 christos int);
214 1.1 christos
215 1.1 christos extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *,
216 1.3 christos const char * );
217 1.1 christos
218 1.1 christos extern void deprecated_cmd_warning (const char *);
219 1.1 christos
220 1.1 christos extern int lookup_cmd_composition (const char *text,
221 1.1 christos struct cmd_list_element **alias,
222 1.1 christos struct cmd_list_element **prefix_cmd,
223 1.1 christos struct cmd_list_element **cmd);
224 1.1 christos
225 1.1 christos extern struct cmd_list_element *add_com (const char *, enum command_class,
226 1.3 christos cmd_cfunc_ftype *fun,
227 1.3 christos const char *);
228 1.1 christos
229 1.1 christos extern struct cmd_list_element *add_com_alias (const char *, const char *,
230 1.1 christos enum command_class, int);
231 1.1 christos
232 1.6 christos extern struct cmd_list_element *add_com_suppress_notification
233 1.6 christos (const char *name, enum command_class theclass,
234 1.6 christos cmd_cfunc_ftype *fun, const char *doc,
235 1.6 christos int *supress_notification);
236 1.6 christos
237 1.1 christos extern struct cmd_list_element *add_info (const char *,
238 1.3 christos cmd_cfunc_ftype *fun,
239 1.3 christos const char *);
240 1.1 christos
241 1.3 christos extern struct cmd_list_element *add_info_alias (const char *, const char *,
242 1.3 christos int);
243 1.1 christos
244 1.1 christos extern VEC (char_ptr) *complete_on_cmdlist (struct cmd_list_element *,
245 1.1 christos const char *, const char *, int);
246 1.1 christos
247 1.1 christos extern VEC (char_ptr) *complete_on_enum (const char *const *enumlist,
248 1.1 christos const char *, const char *);
249 1.1 christos
250 1.1 christos /* Functions that implement commands about CLI commands. */
251 1.1 christos
252 1.3 christos extern void help_list (struct cmd_list_element *, const char *,
253 1.1 christos enum command_class, struct ui_file *);
254 1.1 christos
255 1.1 christos /* Method for show a set/show variable's VALUE on FILE. If this
256 1.1 christos method isn't supplied deprecated_show_value_hack() is called (which
257 1.1 christos is not good). */
258 1.1 christos typedef void (show_value_ftype) (struct ui_file *file,
259 1.1 christos int from_tty,
260 1.1 christos struct cmd_list_element *cmd,
261 1.1 christos const char *value);
262 1.1 christos /* NOTE: i18n: This function is not i18n friendly. Callers should
263 1.1 christos instead print the value out directly. */
264 1.1 christos extern show_value_ftype deprecated_show_value_hack;
265 1.1 christos
266 1.1 christos extern void add_setshow_enum_cmd (const char *name,
267 1.5 christos enum command_class theclass,
268 1.1 christos const char *const *enumlist,
269 1.1 christos const char **var,
270 1.1 christos const char *set_doc,
271 1.1 christos const char *show_doc,
272 1.1 christos const char *help_doc,
273 1.1 christos cmd_sfunc_ftype *set_func,
274 1.1 christos show_value_ftype *show_func,
275 1.1 christos struct cmd_list_element **set_list,
276 1.1 christos struct cmd_list_element **show_list);
277 1.1 christos
278 1.1 christos extern void add_setshow_auto_boolean_cmd (const char *name,
279 1.5 christos enum command_class theclass,
280 1.1 christos enum auto_boolean *var,
281 1.1 christos const char *set_doc,
282 1.1 christos const char *show_doc,
283 1.1 christos const char *help_doc,
284 1.1 christos cmd_sfunc_ftype *set_func,
285 1.1 christos show_value_ftype *show_func,
286 1.1 christos struct cmd_list_element **set_list,
287 1.1 christos struct cmd_list_element **show_list);
288 1.1 christos
289 1.1 christos extern void add_setshow_boolean_cmd (const char *name,
290 1.5 christos enum command_class theclass,
291 1.1 christos int *var,
292 1.1 christos const char *set_doc, const char *show_doc,
293 1.1 christos const char *help_doc,
294 1.1 christos cmd_sfunc_ftype *set_func,
295 1.1 christos show_value_ftype *show_func,
296 1.1 christos struct cmd_list_element **set_list,
297 1.1 christos struct cmd_list_element **show_list);
298 1.1 christos
299 1.1 christos extern void add_setshow_filename_cmd (const char *name,
300 1.5 christos enum command_class theclass,
301 1.1 christos char **var,
302 1.1 christos const char *set_doc,
303 1.1 christos const char *show_doc,
304 1.1 christos const char *help_doc,
305 1.1 christos cmd_sfunc_ftype *set_func,
306 1.1 christos show_value_ftype *show_func,
307 1.1 christos struct cmd_list_element **set_list,
308 1.1 christos struct cmd_list_element **show_list);
309 1.1 christos
310 1.1 christos extern void add_setshow_string_cmd (const char *name,
311 1.5 christos enum command_class theclass,
312 1.1 christos char **var,
313 1.1 christos const char *set_doc,
314 1.1 christos const char *show_doc,
315 1.1 christos const char *help_doc,
316 1.1 christos cmd_sfunc_ftype *set_func,
317 1.1 christos show_value_ftype *show_func,
318 1.1 christos struct cmd_list_element **set_list,
319 1.1 christos struct cmd_list_element **show_list);
320 1.1 christos
321 1.1 christos extern struct cmd_list_element *add_setshow_string_noescape_cmd
322 1.1 christos (const char *name,
323 1.5 christos enum command_class theclass,
324 1.1 christos char **var,
325 1.1 christos const char *set_doc,
326 1.1 christos const char *show_doc,
327 1.1 christos const char *help_doc,
328 1.1 christos cmd_sfunc_ftype *set_func,
329 1.1 christos show_value_ftype *show_func,
330 1.1 christos struct cmd_list_element **set_list,
331 1.1 christos struct cmd_list_element **show_list);
332 1.1 christos
333 1.1 christos extern void add_setshow_optional_filename_cmd (const char *name,
334 1.5 christos enum command_class theclass,
335 1.1 christos char **var,
336 1.1 christos const char *set_doc,
337 1.1 christos const char *show_doc,
338 1.1 christos const char *help_doc,
339 1.1 christos cmd_sfunc_ftype *set_func,
340 1.1 christos show_value_ftype *show_func,
341 1.1 christos struct cmd_list_element **set_list,
342 1.1 christos struct cmd_list_element **show_list);
343 1.1 christos
344 1.1 christos extern void add_setshow_integer_cmd (const char *name,
345 1.5 christos enum command_class theclass,
346 1.1 christos int *var,
347 1.1 christos const char *set_doc,
348 1.1 christos const char *show_doc,
349 1.1 christos const char *help_doc,
350 1.1 christos cmd_sfunc_ftype *set_func,
351 1.1 christos show_value_ftype *show_func,
352 1.1 christos struct cmd_list_element **set_list,
353 1.1 christos struct cmd_list_element **show_list);
354 1.1 christos
355 1.1 christos extern void add_setshow_uinteger_cmd (const char *name,
356 1.5 christos enum command_class theclass,
357 1.1 christos unsigned int *var,
358 1.1 christos const char *set_doc,
359 1.1 christos const char *show_doc,
360 1.1 christos const char *help_doc,
361 1.1 christos cmd_sfunc_ftype *set_func,
362 1.1 christos show_value_ftype *show_func,
363 1.1 christos struct cmd_list_element **set_list,
364 1.1 christos struct cmd_list_element **show_list);
365 1.1 christos
366 1.1 christos extern void add_setshow_zinteger_cmd (const char *name,
367 1.5 christos enum command_class theclass,
368 1.1 christos int *var,
369 1.1 christos const char *set_doc,
370 1.1 christos const char *show_doc,
371 1.1 christos const char *help_doc,
372 1.1 christos cmd_sfunc_ftype *set_func,
373 1.1 christos show_value_ftype *show_func,
374 1.1 christos struct cmd_list_element **set_list,
375 1.1 christos struct cmd_list_element **show_list);
376 1.1 christos
377 1.1 christos extern void add_setshow_zuinteger_cmd (const char *name,
378 1.5 christos enum command_class theclass,
379 1.1 christos unsigned int *var,
380 1.1 christos const char *set_doc,
381 1.1 christos const char *show_doc,
382 1.1 christos const char *help_doc,
383 1.1 christos cmd_sfunc_ftype *set_func,
384 1.1 christos show_value_ftype *show_func,
385 1.1 christos struct cmd_list_element **set_list,
386 1.1 christos struct cmd_list_element **show_list);
387 1.1 christos
388 1.1 christos extern void
389 1.1 christos add_setshow_zuinteger_unlimited_cmd (const char *name,
390 1.5 christos enum command_class theclass,
391 1.1 christos int *var,
392 1.1 christos const char *set_doc,
393 1.1 christos const char *show_doc,
394 1.1 christos const char *help_doc,
395 1.1 christos cmd_sfunc_ftype *set_func,
396 1.1 christos show_value_ftype *show_func,
397 1.1 christos struct cmd_list_element **set_list,
398 1.1 christos struct cmd_list_element **show_list);
399 1.1 christos
400 1.1 christos /* Do a "show" command for each thing on a command list. */
401 1.1 christos
402 1.3 christos extern void cmd_show_list (struct cmd_list_element *, int, const char *);
403 1.1 christos
404 1.1 christos /* Used everywhere whenever at least one parameter is required and
405 1.1 christos none is specified. */
406 1.1 christos
407 1.3 christos extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
408 1.1 christos
409 1.1 christos extern void dont_repeat (void);
410 1.1 christos
411 1.1 christos extern struct cleanup *prevent_dont_repeat (void);
412 1.1 christos
413 1.1 christos /* Used to mark commands that don't do anything. If we just leave the
414 1.1 christos function field NULL, the command is interpreted as a help topic, or
415 1.1 christos as a class of commands. */
416 1.1 christos
417 1.1 christos extern void not_just_help_class_command (char *, int);
418 1.1 christos
419 1.1 christos /* Check function pointer. */
420 1.1 christos extern int cmd_func_p (struct cmd_list_element *cmd);
421 1.1 christos
422 1.1 christos /* Call the command function. */
423 1.1 christos extern void cmd_func (struct cmd_list_element *cmd,
424 1.1 christos char *args, int from_tty);
425 1.1 christos
426 1.1 christos #endif /* !defined (COMMAND_H) */
427