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