]>
Commit | Line | Data |
---|---|---|
50aeff07 | 1 | /* Header file for command creation. |
18a642a1 | 2 | |
d01e8234 | 3 | Copyright (C) 1986-2025 Free Software Foundation, Inc. |
c906108c | 4 | |
c5aa993b JM |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 7 | the Free Software Foundation; either version 3 of the License, or |
c5aa993b | 8 | (at your option) any later version. |
c906108c | 9 | |
c5aa993b JM |
10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU General Public License for more details. | |
c906108c | 14 | |
c5aa993b | 15 | You should have received a copy of the GNU General Public License |
a9762ec7 | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
c906108c | 17 | |
cc709640 TT |
18 | #ifndef GDB_COMMAND_H |
19 | #define GDB_COMMAND_H | |
c906108c | 20 | |
268a13a5 | 21 | #include "gdbsupport/scoped_restore.h" |
49c4e619 | 22 | |
eb3ff9a5 PA |
23 | struct completion_tracker; |
24 | ||
50aeff07 PA |
25 | /* This file defines the public interface for any code wanting to |
26 | create commands. */ | |
27 | ||
aff410f1 MS |
28 | /* Command classes are top-level categories into which commands are |
29 | broken down for "help" purposes. | |
30 | ||
57b4f16e PW |
31 | The class_alias is used for the user-defined aliases, defined |
32 | using the "alias" command. | |
33 | ||
34 | Aliases pre-defined by GDB (e.g. the alias "bt" of the "backtrace" command) | |
35 | are not using the class_alias. | |
36 | Different pre-defined aliases of the same command do not necessarily | |
37 | have the same classes. For example, class_stack is used for the | |
38 | "backtrace" and its "bt" alias", while "info stack" (also an alias | |
39 | of "backtrace" uses class_info. */ | |
6426a772 JM |
40 | |
41 | enum command_class | |
42 | { | |
57b4f16e PW |
43 | /* Classes of commands followed by a comment giving the name |
44 | to use in "help <classname>". | |
45 | Note that help accepts unambiguous abbreviated class names. */ | |
46 | ||
47 | /* Special classes to help_list */ | |
57b4f16e PW |
48 | all_classes = -2, /* help without <classname> */ |
49 | all_commands = -1, /* all */ | |
50 | ||
6426a772 | 51 | /* Classes of commands */ |
57b4f16e PW |
52 | no_class = -1, |
53 | class_run = 0, /* running */ | |
54 | class_vars, /* data */ | |
55 | class_stack, /* stack */ | |
56 | class_files, /* files */ | |
57 | class_support, /* support */ | |
58 | class_info, /* status */ | |
59 | class_breakpoint, /* breakpoints */ | |
60 | class_trace, /* tracepoints */ | |
61 | class_alias, /* aliases */ | |
62 | class_bookmark, | |
63 | class_obscure, /* obscure */ | |
64 | class_maintenance, /* internals */ | |
e98d2e6d | 65 | class_tui, /* text-user-interface */ |
57b4f16e PW |
66 | class_user, /* user-defined */ |
67 | ||
68 | /* Used for "show" commands that have no corresponding "set" command. */ | |
69 | no_set_class | |
6426a772 JM |
70 | }; |
71 | ||
c906108c | 72 | /* Types of "set" or "show" command. */ |
0d1703b8 | 73 | enum var_types |
c5aa993b | 74 | { |
491144b5 CB |
75 | /* "on" or "off". *VAR is a bool which is true for on, |
76 | false for off. */ | |
c5aa993b | 77 | var_boolean, |
97c3646f AC |
78 | |
79 | /* "on" / "true" / "enable" or "off" / "false" / "disable" or | |
7f19b9a2 AC |
80 | "auto. *VAR is an ``enum auto_boolean''. NOTE: In general a |
81 | custom show command will need to be implemented - one that for | |
82 | "auto" prints both the "auto" and the current auto-selected | |
ebcd3b23 | 83 | value. */ |
97c3646f AC |
84 | var_auto_boolean, |
85 | ||
7aeb03e2 MR |
86 | /* Unsigned Integer. *VAR is an unsigned int. In the Guile and Python |
87 | APIs 0 means unlimited, which is stored in *VAR as UINT_MAX. */ | |
c5aa993b JM |
88 | var_uinteger, |
89 | ||
7aeb03e2 MR |
90 | /* Like var_uinteger but signed. *VAR is an int. In the Guile and |
91 | Python APIs 0 means unlimited, which is stored in *VAR as INT_MAX. */ | |
c5aa993b JM |
92 | var_integer, |
93 | ||
7aeb03e2 MR |
94 | /* Like var_integer but negative numbers are not allowed, |
95 | except for special values. *VAR is an int. */ | |
96 | var_pinteger, | |
97 | ||
aff410f1 MS |
98 | /* String which the user enters with escapes (e.g. the user types |
99 | \n and it is a real newline in the stored string). | |
e0700ba4 | 100 | *VAR is a std::string, "" if the string is empty. */ |
c5aa993b JM |
101 | var_string, |
102 | /* String which stores what the user types verbatim. | |
e0700ba4 | 103 | *VAR is std::string, "" if the string is empty. */ |
c5aa993b | 104 | var_string_noescape, |
e0700ba4 SM |
105 | /* String which stores a filename. (*VAR) is a std::string, |
106 | "" if the string was empty. */ | |
b4b4ac0b | 107 | var_optional_filename, |
e0700ba4 | 108 | /* String which stores a filename. (*VAR) is a std::string. */ |
c5aa993b | 109 | var_filename, |
aff410f1 MS |
110 | /* Enumerated type. Can only have one of the specified values. |
111 | *VAR is a char pointer to the name of the element that we | |
112 | find. */ | |
6447969d AP |
113 | var_enum, |
114 | /* Color type. *VAR is a ui_file_style::color structure. */ | |
115 | var_color | |
0d1703b8 | 116 | }; |
c906108c | 117 | |
7aeb03e2 MR |
118 | /* A structure describing an extra literal accepted and shown in place |
119 | of a number. */ | |
120 | struct literal_def | |
121 | { | |
122 | /* The literal to define, e.g. "unlimited". */ | |
123 | const char *literal; | |
124 | ||
125 | /* The number to substitute internally for LITERAL or VAL; | |
126 | the use of this number is not allowed (unless the same as VAL). */ | |
127 | LONGEST use; | |
128 | ||
129 | /* An optional number accepted that stands for the literal. */ | |
6b09f134 | 130 | std::optional<LONGEST> val; |
7aeb03e2 MR |
131 | }; |
132 | ||
1d7fe7f0 LS |
133 | /* Return true if a setting of type VAR_TYPE is backed with type T. |
134 | ||
135 | This function is left without definition intentionally. This template is | |
136 | specialized for all valid types that are used to back var_types. Therefore | |
137 | if one tries to instantiate this un-specialized template it means the T | |
138 | parameter is not a type used to back a var_type and it is most likely a | |
139 | programming error. */ | |
140 | template<typename T> | |
141 | bool var_type_uses (var_types var_type) = delete; | |
142 | ||
143 | /* Return true if a setting of type T is backed by a bool variable. */ | |
144 | template<> | |
145 | inline bool var_type_uses<bool> (var_types t) | |
146 | { | |
147 | return t == var_boolean; | |
148 | }; | |
149 | ||
150 | /* Return true if a setting of type T is backed by a auto_boolean variable. | |
151 | */ | |
152 | template<> | |
153 | inline bool var_type_uses<enum auto_boolean> (var_types t) | |
154 | { | |
155 | return t == var_auto_boolean; | |
156 | } | |
157 | ||
158 | /* Return true if a setting of type T is backed by an unsigned int variable. | |
159 | */ | |
160 | template<> | |
161 | inline bool var_type_uses<unsigned int> (var_types t) | |
162 | { | |
7aeb03e2 | 163 | return t == var_uinteger; |
1d7fe7f0 LS |
164 | } |
165 | ||
166 | /* Return true if a setting of type T is backed by an int variable. */ | |
167 | template<> | |
168 | inline bool var_type_uses<int> (var_types t) | |
169 | { | |
7aeb03e2 | 170 | return t == var_integer || t == var_pinteger; |
1d7fe7f0 LS |
171 | } |
172 | ||
e0700ba4 | 173 | /* Return true if a setting of type T is backed by a std::string variable. */ |
1d7fe7f0 | 174 | template<> |
e0700ba4 | 175 | inline bool var_type_uses<std::string> (var_types t) |
1d7fe7f0 LS |
176 | { |
177 | return (t == var_string || t == var_string_noescape | |
178 | || t == var_optional_filename || t == var_filename); | |
179 | } | |
180 | ||
181 | /* Return true if a setting of type T is backed by a const char * variable. | |
182 | */ | |
183 | template<> | |
184 | inline bool var_type_uses<const char *> (var_types t) | |
185 | { | |
186 | return t == var_enum; | |
187 | } | |
188 | ||
6447969d AP |
189 | /* Return true if a setting of type T is backed by an ui_file_style::color |
190 | variable. */ | |
191 | template<> | |
192 | inline bool var_type_uses<ui_file_style::color> (var_types t) | |
193 | { | |
194 | return t == var_color; | |
195 | } | |
196 | ||
fcef6471 | 197 | template<bool is_scalar, typename T> struct setting_func_types_1; |
70299171 LS |
198 | |
199 | template<typename T> | |
fcef6471 SM |
200 | struct setting_func_types_1<true, T> |
201 | { | |
202 | using type = T; | |
203 | using set = void (*) (type); | |
204 | using get = type (*) (); | |
205 | }; | |
70299171 | 206 | |
fcef6471 SM |
207 | template<typename T> |
208 | struct setting_func_types_1<false, T> | |
209 | { | |
210 | using type = const T &; | |
211 | using set = void (*) (type); | |
212 | using get = type (*) (); | |
213 | }; | |
70299171 LS |
214 | |
215 | template<typename T> | |
fcef6471 SM |
216 | struct setting_func_types |
217 | { | |
218 | using type = typename setting_func_types_1<std::is_scalar<T>::value, T>::type; | |
219 | using set = typename setting_func_types_1<std::is_scalar<T>::value, T>::set; | |
220 | using get = typename setting_func_types_1<std::is_scalar<T>::value, T>::get; | |
221 | }; | |
70299171 LS |
222 | |
223 | /* Generic/type-erased function pointer. */ | |
224 | ||
225 | using erased_func = void (*) (); | |
226 | ||
1d7fe7f0 LS |
227 | /* Interface for getting and setting a setting's value. |
228 | ||
229 | The underlying data can be of any VAR_TYPES type. */ | |
230 | struct setting | |
231 | { | |
232 | /* Create a setting backed by a variable of type T. | |
233 | ||
234 | Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */ | |
235 | template<typename T> | |
7aeb03e2 MR |
236 | setting (var_types var_type, T *var, |
237 | const literal_def *extra_literals = nullptr) | |
238 | : m_var_type (var_type), m_var (var), m_extra_literals (extra_literals) | |
1d7fe7f0 LS |
239 | { |
240 | gdb_assert (var != nullptr); | |
241 | gdb_assert (var_type_uses<T> (var_type)); | |
242 | } | |
243 | ||
244 | /* A setting can also be constructed with a pre-validated | |
245 | type-erased variable. Use the following function to | |
246 | validate & type-erase said variable/function pointers. */ | |
247 | ||
248 | struct erased_args | |
249 | { | |
250 | void *var; | |
70299171 LS |
251 | erased_func setter; |
252 | erased_func getter; | |
1d7fe7f0 LS |
253 | }; |
254 | ||
255 | template<typename T> | |
70299171 LS |
256 | static erased_args erase_args (var_types var_type, |
257 | T *var, | |
fcef6471 SM |
258 | typename setting_func_types<T>::set set_setting_func, |
259 | typename setting_func_types<T>::get get_setting_func) | |
1d7fe7f0 LS |
260 | { |
261 | gdb_assert (var_type_uses<T> (var_type)); | |
70299171 LS |
262 | /* The getter and the setter must be both provided or both omitted. */ |
263 | gdb_assert | |
264 | ((set_setting_func == nullptr) == (get_setting_func == nullptr)); | |
265 | ||
266 | /* The caller must provide a pointer to a variable or get/set functions, but | |
267 | not both. */ | |
268 | gdb_assert ((set_setting_func == nullptr) != (var == nullptr)); | |
269 | ||
270 | return { | |
271 | var, | |
272 | reinterpret_cast<erased_func> (set_setting_func), | |
273 | reinterpret_cast<erased_func> (get_setting_func) | |
274 | }; | |
1d7fe7f0 LS |
275 | } |
276 | ||
7aeb03e2 MR |
277 | /* Create a setting backed by pre-validated type-erased args and using |
278 | EXTRA_LITERALS. ERASED_VAR's fields' real types must match the var | |
279 | type VAR_TYPE (see VAR_TYPE_USES). */ | |
280 | setting (var_types var_type, const literal_def *extra_literals, | |
281 | const erased_args &args) | |
1d7fe7f0 | 282 | : m_var_type (var_type), |
70299171 | 283 | m_var (args.var), |
7aeb03e2 | 284 | m_extra_literals (extra_literals), |
70299171 LS |
285 | m_getter (args.getter), |
286 | m_setter (args.setter) | |
1d7fe7f0 LS |
287 | { |
288 | } | |
289 | ||
70299171 LS |
290 | /* Create a setting backed by setter and getter functions. |
291 | ||
292 | Type T must match the var type VAR_TYPE (see VAR_TYPE_USES). */ | |
293 | template<typename T> | |
294 | setting (var_types var_type, | |
fcef6471 SM |
295 | typename setting_func_types<T>::set setter, |
296 | typename setting_func_types<T>::get getter) | |
70299171 | 297 | : m_var_type (var_type) |
1d7fe7f0 | 298 | { |
70299171 LS |
299 | gdb_assert (var_type_uses<T> (var_type)); |
300 | ||
301 | /* Getters and setters are cast to and from the arbitrary `void (*) ()` | |
302 | function pointer type. Make sure that the two types are really of the | |
303 | same size. */ | |
69f6730d TT |
304 | static_assert (sizeof (m_getter) == sizeof (getter)); |
305 | static_assert (sizeof (m_setter) == sizeof (setter)); | |
70299171 LS |
306 | |
307 | m_getter = reinterpret_cast<erased_func> (getter); | |
308 | m_setter = reinterpret_cast<erased_func> (setter); | |
1d7fe7f0 LS |
309 | } |
310 | ||
70299171 LS |
311 | /* Access the type of the current setting. */ |
312 | var_types type () const | |
313 | { return m_var_type; } | |
314 | ||
7aeb03e2 MR |
315 | /* Access any extra literals accepted. */ |
316 | const literal_def *extra_literals () const | |
317 | { return m_extra_literals; } | |
318 | ||
1d7fe7f0 LS |
319 | /* Return the current value. |
320 | ||
321 | The template parameter T is the type of the variable used to store the | |
322 | setting. */ | |
323 | template<typename T> | |
fcef6471 | 324 | typename setting_func_types<T>::type get () const |
1d7fe7f0 LS |
325 | { |
326 | gdb_assert (var_type_uses<T> (m_var_type)); | |
1d7fe7f0 | 327 | |
70299171 LS |
328 | if (m_var == nullptr) |
329 | { | |
330 | gdb_assert (m_getter != nullptr); | |
fcef6471 | 331 | auto getter = reinterpret_cast<typename setting_func_types<T>::get> (m_getter); |
70299171 LS |
332 | return getter (); |
333 | } | |
334 | else | |
335 | return *static_cast<const T *> (m_var); | |
1d7fe7f0 LS |
336 | } |
337 | ||
1a98bb55 LS |
338 | /* Sets the value of the setting to V. Returns true if the setting was |
339 | effectively changed, false if the update failed and the setting is left | |
340 | unchanged. | |
1d7fe7f0 | 341 | |
70299171 LS |
342 | If we have a user-provided setter, use it to set the setting. Otherwise |
343 | copy the value V to the internally referenced buffer. | |
344 | ||
345 | The template parameter T indicates the type of the variable used to store | |
346 | the setting. | |
1d7fe7f0 LS |
347 | |
348 | The var_type of the setting must match T. */ | |
349 | template<typename T> | |
1a98bb55 | 350 | bool set (const T &v) |
1d7fe7f0 LS |
351 | { |
352 | /* Check that the current instance is of one of the supported types for | |
353 | this instantiation. */ | |
354 | gdb_assert (var_type_uses<T> (m_var_type)); | |
355 | ||
1a98bb55 LS |
356 | const T old_value = this->get<T> (); |
357 | ||
70299171 LS |
358 | if (m_var == nullptr) |
359 | { | |
360 | gdb_assert (m_setter != nullptr); | |
fcef6471 | 361 | auto setter = reinterpret_cast<typename setting_func_types<T>::set> (m_setter); |
70299171 LS |
362 | setter (v); |
363 | } | |
364 | else | |
365 | *static_cast<T *> (m_var) = v; | |
1a98bb55 LS |
366 | |
367 | return old_value != this->get<T> (); | |
1d7fe7f0 LS |
368 | } |
369 | ||
370 | private: | |
70299171 LS |
371 | /* The type of the variable M_VAR is pointing to, or that M_GETTER / M_SETTER |
372 | get or set. */ | |
1d7fe7f0 LS |
373 | var_types m_var_type; |
374 | ||
70299171 LS |
375 | /* Pointer to the enclosed variable |
376 | ||
377 | Either M_VAR is non-nullptr, or both M_GETTER and M_SETTER are | |
378 | non-nullptr. */ | |
379 | void *m_var = nullptr; | |
380 | ||
7aeb03e2 MR |
381 | /* Any extra literals accepted. */ |
382 | const literal_def *m_extra_literals = nullptr; | |
383 | ||
70299171 LS |
384 | /* Pointer to a user provided getter. */ |
385 | erased_func m_getter = nullptr; | |
386 | ||
387 | /* Pointer to a user provided setter. */ | |
388 | erased_func m_setter = nullptr; | |
1d7fe7f0 LS |
389 | }; |
390 | ||
c906108c | 391 | /* This structure records one command'd definition. */ |
18a642a1 | 392 | struct cmd_list_element; |
c906108c | 393 | |
3a553c80 SM |
394 | /* The "simple" signature of command callbacks, which doesn't include a |
395 | cmd_list_element parameter. */ | |
396 | ||
397 | typedef void cmd_simple_func_ftype (const char *args, int from_tty); | |
82ae6c8d | 398 | |
4034d0ff AT |
399 | /* This structure specifies notifications to be suppressed by a cli |
400 | command interpreter. */ | |
401 | ||
402 | struct cli_suppress_notification | |
403 | { | |
404 | /* Inferior, thread, frame selected notification suppressed? */ | |
f36c8918 | 405 | bool user_selected_context = false; |
2b826f75 TBA |
406 | |
407 | /* Normal stop event suppressed? */ | |
408 | bool normal_stop = false; | |
4034d0ff AT |
409 | }; |
410 | ||
411 | extern struct cli_suppress_notification cli_suppress_notification; | |
412 | ||
18d5d590 | 413 | /* Forward-declarations of the entry-points of cli/cli-decode.c. */ |
c906108c | 414 | |
50aeff07 PA |
415 | /* API to the manipulation of command lists. */ |
416 | ||
be09caf1 PW |
417 | /* Return TRUE if NAME is a valid user-defined command name. |
418 | This is a stricter subset of all gdb commands, | |
419 | see find_command_name_length. */ | |
420 | ||
7f008c9e | 421 | extern bool valid_user_defined_cmd_name_p (const char *name); |
5a56e9c5 | 422 | |
be09caf1 PW |
423 | /* Return TRUE if C is a valid command character. */ |
424 | ||
425 | extern bool valid_cmd_char_p (int c); | |
426 | ||
f54bdb6d SM |
427 | /* Return value type for the add_setshow_* functions. */ |
428 | ||
429 | struct set_show_commands | |
430 | { | |
431 | cmd_list_element *set, *show; | |
432 | }; | |
433 | ||
0450cc4c TT |
434 | /* Const-correct variant of the above. */ |
435 | ||
436 | extern struct cmd_list_element *add_cmd (const char *, enum command_class, | |
3a553c80 | 437 | cmd_simple_func_ftype *fun, |
0450cc4c TT |
438 | const char *, |
439 | struct cmd_list_element **); | |
440 | ||
441 | /* Like add_cmd, but no command function is specified. */ | |
442 | ||
443 | extern struct cmd_list_element *add_cmd (const char *, enum command_class, | |
444 | const char *, | |
445 | struct cmd_list_element **); | |
446 | ||
f67ffa6a AB |
447 | extern struct cmd_list_element *add_cmd_suppress_notification |
448 | (const char *name, enum command_class theclass, | |
3a553c80 | 449 | cmd_simple_func_ftype *fun, const char *doc, |
f67ffa6a | 450 | struct cmd_list_element **list, |
f36c8918 | 451 | bool *suppress_notification); |
f67ffa6a | 452 | |
21873064 YQ |
453 | extern struct cmd_list_element *add_alias_cmd (const char *, |
454 | cmd_list_element *, | |
455 | enum command_class, int, | |
456 | struct cmd_list_element **); | |
457 | ||
458 | ||
6f937416 | 459 | extern struct cmd_list_element *add_prefix_cmd (const char *, enum command_class, |
3a553c80 | 460 | cmd_simple_func_ftype *fun, |
1947513d | 461 | const char *, |
a14ed312 | 462 | struct cmd_list_element **, |
2f822da5 | 463 | int, |
a14ed312 KB |
464 | struct cmd_list_element **); |
465 | ||
0743fc83 TT |
466 | /* Like add_prefix_cmd, but sets the callback to a function that |
467 | simply calls help_list. */ | |
468 | ||
469 | extern struct cmd_list_element *add_basic_prefix_cmd | |
470 | (const char *, enum command_class, const char *, struct cmd_list_element **, | |
2f822da5 | 471 | int, struct cmd_list_element **); |
0743fc83 TT |
472 | |
473 | /* Like add_prefix_cmd, but useful for "show" prefixes. This sets the | |
474 | callback to a function that simply calls cmd_show_list. */ | |
475 | ||
476 | extern struct cmd_list_element *add_show_prefix_cmd | |
477 | (const char *, enum command_class, const char *, struct cmd_list_element **, | |
2f822da5 | 478 | int, struct cmd_list_element **); |
0743fc83 | 479 | |
f54bdb6d SM |
480 | /* Add matching set and show commands using add_basic_prefix_cmd and |
481 | add_show_prefix_cmd. */ | |
482 | ||
483 | extern set_show_commands add_setshow_prefix_cmd | |
484 | (const char *name, command_class theclass, const char *set_doc, | |
485 | const char *show_doc, | |
486 | cmd_list_element **set_subcommands_list, | |
487 | cmd_list_element **show_subcommands_list, | |
488 | cmd_list_element **set_list, | |
489 | cmd_list_element **show_list); | |
490 | ||
f67ffa6a AB |
491 | extern struct cmd_list_element *add_prefix_cmd_suppress_notification |
492 | (const char *name, enum command_class theclass, | |
3a553c80 | 493 | cmd_simple_func_ftype *fun, |
14b42fc4 | 494 | const char *doc, struct cmd_list_element **subcommands, |
2f822da5 | 495 | int allow_unknown, |
f67ffa6a | 496 | struct cmd_list_element **list, |
f36c8918 | 497 | bool *suppress_notification); |
f67ffa6a | 498 | |
6f937416 | 499 | extern struct cmd_list_element *add_abbrev_prefix_cmd (const char *, |
a14ed312 | 500 | enum command_class, |
3a553c80 | 501 | cmd_simple_func_ftype *fun, |
1947513d | 502 | const char *, |
a14ed312 | 503 | struct cmd_list_element |
2f822da5 | 504 | **, int, |
a14ed312 KB |
505 | struct cmd_list_element |
506 | **); | |
507 | ||
5538b03c SM |
508 | typedef void cmd_func_ftype (const char *args, int from_tty, |
509 | cmd_list_element *c); | |
9f60d481 | 510 | |
eb3ff9a5 | 511 | /* A completion routine. Add possible completions to tracker. |
6e1dbf8c PA |
512 | |
513 | TEXT is the text beyond what was matched for the command itself | |
514 | (leading whitespace is skipped). It stops where we are supposed to | |
515 | stop completing (rl_point) and is '\0' terminated. WORD points in | |
516 | the same buffer as TEXT, and completions should be returned | |
517 | relative to this position. For example, suppose TEXT is "foo" and | |
518 | we want to complete to "foobar". If WORD is "oo", return "oobar"; | |
519 | if WORD is "baz/foo", return "baz/foobar". */ | |
eb3ff9a5 PA |
520 | typedef void completer_ftype (struct cmd_list_element *, |
521 | completion_tracker &tracker, | |
522 | const char *text, const char *word); | |
625e8578 | 523 | |
6e1dbf8c PA |
524 | /* Same, but for set_cmd_completer_handle_brkchars. */ |
525 | typedef void completer_handle_brkchars_ftype (struct cmd_list_element *, | |
eb3ff9a5 | 526 | completion_tracker &tracker, |
6e1dbf8c | 527 | const char *text, const char *word); |
7d793aa9 | 528 | |
625e8578 | 529 | extern void set_cmd_completer (struct cmd_list_element *, completer_ftype *); |
5ba2abeb | 530 | |
7d793aa9 SDJ |
531 | /* Set the completer_handle_brkchars callback. */ |
532 | ||
533 | extern void set_cmd_completer_handle_brkchars (struct cmd_list_element *, | |
6e1dbf8c | 534 | completer_handle_brkchars_ftype *); |
7d793aa9 | 535 | |
bbaca940 AC |
536 | /* HACK: cagney/2002-02-23: Code, mostly in tracepoints.c, grubs |
537 | around in cmd objects to test the value of the commands sfunc(). */ | |
3a553c80 SM |
538 | extern int cmd_simple_func_eq (struct cmd_list_element *cmd, |
539 | cmd_simple_func_ftype *cfun); | |
9f60d481 | 540 | |
5913bcb0 AC |
541 | /* Execute CMD's pre/post hook. Throw an error if the command fails. |
542 | If already executing this pre/post hook, or there is no pre/post | |
543 | hook, the call is silently ignored. */ | |
544 | extern void execute_cmd_pre_hook (struct cmd_list_element *cmd); | |
545 | extern void execute_cmd_post_hook (struct cmd_list_element *cmd); | |
546 | ||
50aeff07 PA |
547 | /* Flag for an ambiguous cmd_list result. */ |
548 | #define CMD_LIST_AMBIGUOUS ((struct cmd_list_element *) -1) | |
1868c04e | 549 | |
6f937416 | 550 | extern struct cmd_list_element *lookup_cmd (const char **, |
a121b7c1 PA |
551 | struct cmd_list_element *, |
552 | const char *, | |
cf00cd6f | 553 | std::string *, |
a14ed312 KB |
554 | int, int); |
555 | ||
1536146f AB |
556 | /* This routine takes a line of TEXT and a CLIST in which to start the |
557 | lookup. When it returns it will have incremented the text pointer past | |
558 | the section of text it matched, set *RESULT_LIST to point to the list in | |
559 | which the last word was matched, and will return a pointer to the cmd | |
560 | list element which the text matches. It will return NULL if no match at | |
973c5759 | 561 | all was possible. It will return -1 (cast appropriately, ick) if ambiguous |
1536146f AB |
562 | matches are possible; in this case *RESULT_LIST will be set to point to |
563 | the list in which there are ambiguous choices (and *TEXT will be set to | |
564 | the ambiguous text string). | |
565 | ||
566 | if DEFAULT_ARGS is not null, *DEFAULT_ARGS is set to the found command | |
567 | default args (possibly empty). | |
568 | ||
569 | If the located command was an abbreviation, this routine returns the base | |
570 | command of the abbreviation. Note that *DEFAULT_ARGS will contain the | |
571 | default args defined for the alias. | |
572 | ||
573 | It does no error reporting whatsoever; control will always return | |
574 | to the superior routine. | |
575 | ||
576 | In the case of an ambiguous return (-1), *RESULT_LIST will be set to point | |
577 | at the prefix_command (ie. the best match) *or* (special case) will be NULL | |
578 | if no prefix command was ever found. For example, in the case of "info a", | |
579 | "info" matches without ambiguity, but "a" could be "args" or "address", so | |
580 | *RESULT_LIST is set to the cmd_list_element for "info". So in this case | |
581 | RESULT_LIST should not be interpreted as a pointer to the beginning of a | |
582 | list; it simply points to a specific command. In the case of an ambiguous | |
583 | return *TEXT is advanced past the last non-ambiguous prefix (e.g. | |
584 | "info t" can be "info types" or "info target"; upon return *TEXT has been | |
585 | advanced past "info "). | |
586 | ||
587 | If RESULT_LIST is NULL, don't set *RESULT_LIST (but don't otherwise | |
588 | affect the operation). | |
589 | ||
590 | This routine does *not* modify the text pointed to by TEXT. | |
591 | ||
592 | If IGNORE_HELP_CLASSES is nonzero, ignore any command list elements which | |
593 | are actually help classes rather than commands (i.e. the function field of | |
594 | the struct cmd_list_element is NULL). | |
595 | ||
596 | When LOOKUP_FOR_COMPLETION_P is true the completion is being requested | |
597 | for the completion engine, no warnings should be printed. */ | |
598 | ||
599 | extern struct cmd_list_element *lookup_cmd_1 | |
600 | (const char **text, struct cmd_list_element *clist, | |
601 | struct cmd_list_element **result_list, std::string *default_args, | |
602 | int ignore_help_classes, bool lookup_for_completion_p = false); | |
c906108c | 603 | |
a9b49cbc MB |
604 | /* Look up the command called NAME in the command list LIST. |
605 | ||
606 | Unlike LOOKUP_CMD, partial matches are ignored and only exact matches | |
607 | on NAME are considered. | |
608 | ||
609 | LIST is a chain of struct cmd_list_element's. | |
610 | ||
611 | If IGNORE_HELP_CLASSES is true (the default), ignore any command list | |
612 | elements which are actually help classes rather than commands (i.e. | |
613 | the function field of the struct cmd_list_element is null). | |
614 | ||
615 | If found, return the struct cmd_list_element for that command, | |
616 | otherwise return NULLPTR. */ | |
617 | ||
618 | extern struct cmd_list_element *lookup_cmd_exact | |
619 | (const char *name, | |
620 | struct cmd_list_element *list, | |
621 | bool ignore_help_classes = true); | |
622 | ||
aff410f1 | 623 | extern struct cmd_list_element *deprecate_cmd (struct cmd_list_element *, |
429e55ea | 624 | const char * ); |
56382845 | 625 | |
9ef6d4a1 | 626 | extern void deprecated_cmd_warning (const char *, struct cmd_list_element *); |
56382845 | 627 | |
6f937416 | 628 | extern int lookup_cmd_composition (const char *text, |
aff410f1 MS |
629 | struct cmd_list_element **alias, |
630 | struct cmd_list_element **prefix_cmd, | |
631 | struct cmd_list_element **cmd); | |
56382845 | 632 | |
6f937416 | 633 | extern struct cmd_list_element *add_com (const char *, enum command_class, |
3a553c80 | 634 | cmd_simple_func_ftype *fun, |
1947513d | 635 | const char *); |
c906108c | 636 | |
3947f654 SM |
637 | extern cmd_list_element *add_com_alias (const char *name, |
638 | cmd_list_element *target, | |
639 | command_class theclass, | |
640 | int abbrev_flag); | |
c906108c | 641 | |
4034d0ff AT |
642 | extern struct cmd_list_element *add_com_suppress_notification |
643 | (const char *name, enum command_class theclass, | |
3a553c80 | 644 | cmd_simple_func_ftype *fun, const char *doc, |
33b5899f | 645 | bool *suppress_notification); |
4034d0ff | 646 | |
6f937416 | 647 | extern struct cmd_list_element *add_info (const char *, |
3a553c80 | 648 | cmd_simple_func_ftype *fun, |
1947513d | 649 | const char *); |
c906108c | 650 | |
e0f25bd9 SM |
651 | extern cmd_list_element *add_info_alias (const char *name, |
652 | cmd_list_element *target, | |
653 | int abbrev_flag); | |
c906108c | 654 | |
eb3ff9a5 PA |
655 | extern void complete_on_cmdlist (struct cmd_list_element *, |
656 | completion_tracker &tracker, | |
657 | const char *, const char *, int); | |
c906108c | 658 | |
eb3ff9a5 PA |
659 | extern void complete_on_enum (completion_tracker &tracker, |
660 | const char *const *enumlist, | |
661 | const char *, const char *); | |
c906108c | 662 | |
50aeff07 | 663 | /* Functions that implement commands about CLI commands. */ |
c906108c | 664 | |
64e61d29 | 665 | extern void help_list (struct cmd_list_element *, const char *, |
d9fcf2fb | 666 | enum command_class, struct ui_file *); |
c906108c | 667 | |
b63c50f9 | 668 | /* Method for show a set/show variable's VALUE on FILE. */ |
08546159 AC |
669 | typedef void (show_value_ftype) (struct ui_file *file, |
670 | int from_tty, | |
671 | struct cmd_list_element *cmd, | |
672 | const char *value); | |
08546159 | 673 | |
7aeb03e2 MR |
674 | /* Various sets of extra literals accepted. */ |
675 | extern const literal_def integer_unlimited_literals[]; | |
676 | extern const literal_def uinteger_unlimited_literals[]; | |
677 | extern const literal_def pinteger_unlimited_literals[]; | |
678 | ||
af7f8f52 SM |
679 | extern set_show_commands add_setshow_enum_cmd |
680 | (const char *name, command_class theclass, const char *const *enumlist, | |
681 | const char **var, const char *set_doc, const char *show_doc, | |
5538b03c | 682 | const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 | 683 | show_value_ftype *show_func, cmd_list_element **set_list, |
4c0ba02a | 684 | cmd_list_element **show_list); |
af7f8f52 | 685 | |
70299171 LS |
686 | extern set_show_commands add_setshow_enum_cmd |
687 | (const char *name, command_class theclass, const char *const *enumlist, | |
688 | const char *set_doc, const char *show_doc, | |
fcef6471 SM |
689 | const char *help_doc, setting_func_types<const char *>::set set_func, |
690 | setting_func_types<const char *>::get get_func, show_value_ftype *show_func, | |
70299171 LS |
691 | cmd_list_element **set_list, cmd_list_element **show_list); |
692 | ||
6447969d AP |
693 | extern set_show_commands add_setshow_color_cmd |
694 | (const char *name, command_class theclass, ui_file_style::color *var, | |
695 | const char *set_doc, const char *show_doc, const char *help_doc, | |
696 | cmd_func_ftype *set_func, show_value_ftype *show_func, | |
697 | cmd_list_element **set_list, cmd_list_element **show_list); | |
698 | ||
699 | extern set_show_commands add_setshow_color_cmd | |
700 | (const char *name, command_class theclass, | |
701 | const char *set_doc, const char *show_doc, const char *help_doc, | |
702 | setting_func_types<ui_file_style::color>::set set_func, | |
703 | setting_func_types<ui_file_style::color>::get get_func, | |
704 | show_value_ftype *show_func, cmd_list_element **set_list, | |
705 | cmd_list_element **show_list); | |
706 | ||
af7f8f52 SM |
707 | extern set_show_commands add_setshow_auto_boolean_cmd |
708 | (const char *name, command_class theclass, auto_boolean *var, | |
709 | const char *set_doc, const char *show_doc, const char *help_doc, | |
5538b03c | 710 | cmd_func_ftype *set_func, show_value_ftype *show_func, |
af7f8f52 SM |
711 | cmd_list_element **set_list, cmd_list_element **show_list); |
712 | ||
70299171 LS |
713 | extern set_show_commands add_setshow_auto_boolean_cmd |
714 | (const char *name, command_class theclass, const char *set_doc, | |
715 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
716 | setting_func_types<enum auto_boolean>::set set_func, |
717 | setting_func_types<enum auto_boolean>::get get_func, | |
70299171 LS |
718 | show_value_ftype *show_func, cmd_list_element **set_list, |
719 | cmd_list_element **show_list); | |
720 | ||
af7f8f52 SM |
721 | extern set_show_commands add_setshow_boolean_cmd |
722 | (const char *name, command_class theclass, bool *var, const char *set_doc, | |
5538b03c | 723 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 SM |
724 | show_value_ftype *show_func, cmd_list_element **set_list, |
725 | cmd_list_element **show_list); | |
726 | ||
70299171 LS |
727 | extern set_show_commands add_setshow_boolean_cmd |
728 | (const char *name, command_class theclass, const char *set_doc, | |
729 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
730 | setting_func_types<bool>::set set_func, |
731 | setting_func_types<bool>::get get_func, show_value_ftype *show_func, | |
70299171 LS |
732 | cmd_list_element **set_list, cmd_list_element **show_list); |
733 | ||
af7f8f52 | 734 | extern set_show_commands add_setshow_filename_cmd |
e0700ba4 | 735 | (const char *name, command_class theclass, std::string *var, const char *set_doc, |
5538b03c | 736 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 SM |
737 | show_value_ftype *show_func, cmd_list_element **set_list, |
738 | cmd_list_element **show_list); | |
739 | ||
70299171 LS |
740 | extern set_show_commands add_setshow_filename_cmd |
741 | (const char *name, command_class theclass, const char *set_doc, | |
742 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
743 | setting_func_types<std::string>::set set_func, |
744 | setting_func_types<std::string>::get get_func, show_value_ftype *show_func, | |
70299171 LS |
745 | cmd_list_element **set_list, cmd_list_element **show_list); |
746 | ||
af7f8f52 | 747 | extern set_show_commands add_setshow_string_cmd |
e0700ba4 | 748 | (const char *name, command_class theclass, std::string *var, const char *set_doc, |
5538b03c | 749 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 SM |
750 | show_value_ftype *show_func, cmd_list_element **set_list, |
751 | cmd_list_element **show_list); | |
752 | ||
70299171 LS |
753 | extern set_show_commands add_setshow_string_cmd |
754 | (const char *name, command_class theclass, const char *set_doc, | |
755 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
756 | setting_func_types<std::string>::set set_func, |
757 | setting_func_types<std::string>::get get_func, | |
70299171 LS |
758 | show_value_ftype *show_func, cmd_list_element **set_list, |
759 | cmd_list_element **show_list); | |
760 | ||
af7f8f52 | 761 | extern set_show_commands add_setshow_string_noescape_cmd |
e0700ba4 | 762 | (const char *name, command_class theclass, std::string *var, const char *set_doc, |
5538b03c | 763 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 SM |
764 | show_value_ftype *show_func, cmd_list_element **set_list, |
765 | cmd_list_element **show_list); | |
766 | ||
70299171 LS |
767 | extern set_show_commands add_setshow_string_noescape_cmd |
768 | (const char *name, command_class theclass, const char *set_doc, | |
769 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
770 | setting_func_types<std::string>::set set_func, |
771 | setting_func_types<std::string>::get get_func, show_value_ftype *show_func, | |
70299171 LS |
772 | cmd_list_element **set_list, cmd_list_element **show_list); |
773 | ||
af7f8f52 | 774 | extern set_show_commands add_setshow_optional_filename_cmd |
e0700ba4 | 775 | (const char *name, command_class theclass, std::string *var, const char *set_doc, |
5538b03c | 776 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 SM |
777 | show_value_ftype *show_func, cmd_list_element **set_list, |
778 | cmd_list_element **show_list); | |
779 | ||
70299171 LS |
780 | extern set_show_commands add_setshow_optional_filename_cmd |
781 | (const char *name, command_class theclass, const char *set_doc, | |
782 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
783 | setting_func_types<std::string>::set set_func, |
784 | setting_func_types<std::string>::get get_func, | |
70299171 LS |
785 | show_value_ftype *show_func, cmd_list_element **set_list, |
786 | cmd_list_element **show_list); | |
787 | ||
7aeb03e2 MR |
788 | extern set_show_commands add_setshow_integer_cmd |
789 | (const char *name, command_class theclass, int *var, | |
790 | const literal_def *extra_literals, const char *set_doc, | |
791 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, | |
792 | show_value_ftype *show_func, cmd_list_element **set_list, | |
793 | cmd_list_element **show_list); | |
794 | ||
795 | extern set_show_commands add_setshow_integer_cmd | |
796 | (const char *name, command_class theclass, const literal_def *extra_literals, | |
797 | const char *set_doc, const char *show_doc, const char *help_doc, | |
798 | setting_func_types<int>::set set_func, | |
799 | setting_func_types<int>::get get_func, show_value_ftype *show_func, | |
800 | cmd_list_element **set_list, cmd_list_element **show_list); | |
801 | ||
af7f8f52 SM |
802 | extern set_show_commands add_setshow_integer_cmd |
803 | (const char *name, command_class theclass, int *var, const char *set_doc, | |
5538b03c | 804 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 SM |
805 | show_value_ftype *show_func, cmd_list_element **set_list, |
806 | cmd_list_element **show_list); | |
807 | ||
70299171 LS |
808 | extern set_show_commands add_setshow_integer_cmd |
809 | (const char *name, command_class theclass, const char *set_doc, | |
810 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
811 | setting_func_types<int>::set set_func, |
812 | setting_func_types<int>::get get_func, show_value_ftype *show_func, | |
70299171 | 813 | cmd_list_element **set_list, cmd_list_element **show_list); |
7aeb03e2 MR |
814 | |
815 | extern set_show_commands add_setshow_pinteger_cmd | |
816 | (const char *name, command_class theclass, int *var, | |
817 | const literal_def *extra_literals, const char *set_doc, | |
818 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, | |
819 | show_value_ftype *show_func, cmd_list_element **set_list, | |
820 | cmd_list_element **show_list); | |
821 | ||
822 | extern set_show_commands add_setshow_pinteger_cmd | |
823 | (const char *name, command_class theclass, const literal_def *extra_literals, | |
824 | const char *set_doc, const char *show_doc, const char *help_doc, | |
825 | setting_func_types<int>::set set_func, | |
826 | setting_func_types<int>::get get_func, show_value_ftype *show_func, | |
827 | cmd_list_element **set_list, cmd_list_element **show_list); | |
828 | ||
829 | extern set_show_commands add_setshow_uinteger_cmd | |
830 | (const char *name, command_class theclass, unsigned int *var, | |
831 | const literal_def *extra_literals, | |
832 | const char *set_doc, const char *show_doc, const char *help_doc, | |
833 | cmd_func_ftype *set_func, show_value_ftype *show_func, | |
834 | cmd_list_element **set_list, cmd_list_element **show_list); | |
835 | ||
836 | extern set_show_commands add_setshow_uinteger_cmd | |
837 | (const char *name, command_class theclass, const literal_def *extra_literals, | |
838 | const char *set_doc, const char *show_doc, const char *help_doc, | |
839 | setting_func_types<unsigned int>::set set_func, | |
840 | setting_func_types<unsigned int>::get get_func, show_value_ftype *show_func, | |
841 | cmd_list_element **set_list, cmd_list_element **show_list); | |
70299171 | 842 | |
af7f8f52 SM |
843 | extern set_show_commands add_setshow_uinteger_cmd |
844 | (const char *name, command_class theclass, unsigned int *var, | |
845 | const char *set_doc, const char *show_doc, const char *help_doc, | |
5538b03c | 846 | cmd_func_ftype *set_func, show_value_ftype *show_func, |
af7f8f52 SM |
847 | cmd_list_element **set_list, cmd_list_element **show_list); |
848 | ||
70299171 LS |
849 | extern set_show_commands add_setshow_uinteger_cmd |
850 | (const char *name, command_class theclass, const char *set_doc, | |
851 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
852 | setting_func_types<unsigned int>::set set_func, |
853 | setting_func_types<unsigned int>::get get_func, show_value_ftype *show_func, | |
70299171 LS |
854 | cmd_list_element **set_list, cmd_list_element **show_list); |
855 | ||
af7f8f52 SM |
856 | extern set_show_commands add_setshow_zinteger_cmd |
857 | (const char *name, command_class theclass, int *var, const char *set_doc, | |
5538b03c | 858 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 SM |
859 | show_value_ftype *show_func, cmd_list_element **set_list, |
860 | cmd_list_element **show_list); | |
861 | ||
70299171 LS |
862 | extern set_show_commands add_setshow_zinteger_cmd |
863 | (const char *name, command_class theclass, const char *set_doc, | |
864 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
865 | setting_func_types<int>::set set_func, |
866 | setting_func_types<int>::get get_func, show_value_ftype *show_func, | |
70299171 LS |
867 | cmd_list_element **set_list, cmd_list_element **show_list); |
868 | ||
af7f8f52 SM |
869 | extern set_show_commands add_setshow_zuinteger_cmd |
870 | (const char *name, command_class theclass, unsigned int *var, | |
871 | const char *set_doc, const char *show_doc, const char *help_doc, | |
5538b03c | 872 | cmd_func_ftype *set_func, show_value_ftype *show_func, |
af7f8f52 SM |
873 | cmd_list_element **set_list, cmd_list_element **show_list); |
874 | ||
70299171 LS |
875 | extern set_show_commands add_setshow_zuinteger_cmd |
876 | (const char *name, command_class theclass, const char *set_doc, | |
877 | const char *show_doc, const char *help_doc, | |
fcef6471 SM |
878 | setting_func_types<unsigned int>::set set_func, |
879 | setting_func_types<unsigned int>::get get_func, show_value_ftype *show_func, | |
70299171 LS |
880 | cmd_list_element **set_list, cmd_list_element **show_list); |
881 | ||
af7f8f52 SM |
882 | extern set_show_commands add_setshow_zuinteger_unlimited_cmd |
883 | (const char *name, command_class theclass, int *var, const char *set_doc, | |
5538b03c | 884 | const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, |
af7f8f52 SM |
885 | show_value_ftype *show_func, cmd_list_element **set_list, |
886 | cmd_list_element **show_list); | |
1e8fb976 | 887 | |
70299171 LS |
888 | extern set_show_commands add_setshow_zuinteger_unlimited_cmd |
889 | (const char *name, command_class theclass, const char *set_doc, | |
890 | const char *show_doc, const char *help_doc, | |
fcef6471 | 891 | setting_func_types<int>::set set_func, setting_func_types<int>::get get_func, |
70299171 LS |
892 | show_value_ftype *show_func, cmd_list_element **set_list, |
893 | cmd_list_element **show_list); | |
894 | ||
c906108c SS |
895 | /* Do a "show" command for each thing on a command list. */ |
896 | ||
7aa1b46f | 897 | extern void cmd_show_list (struct cmd_list_element *, int); |
c906108c | 898 | |
c25c4a8b | 899 | /* Used everywhere whenever at least one parameter is required and |
ebcd3b23 | 900 | none is specified. */ |
c25c4a8b | 901 | |
d9deb60b | 902 | [[noreturn]] extern void error_no_arg (const char *); |
c906108c | 903 | |
68bb5386 PW |
904 | |
905 | /* Command line saving and repetition. | |
906 | Each input line executed is saved to possibly be repeated either | |
907 | when the user types an empty line, or be repeated by a command | |
908 | that wants to repeat the previously executed command. The below | |
909 | functions control command repetition. */ | |
910 | ||
911 | /* Commands call dont_repeat if they do not want to be repeated by null | |
912 | lines or by repeat_previous (). */ | |
913 | ||
914 | extern void dont_repeat (); | |
915 | ||
fdbc9870 PA |
916 | /* Commands call repeat_previous if they want to repeat the previous |
917 | command. Such commands that repeat the previous command must | |
918 | indicate to not repeat themselves, to avoid recursive repeat. | |
919 | repeat_previous marks the current command as not repeating, and | |
920 | ensures get_saved_command_line returns the previous command, so | |
921 | that the currently executing command can repeat it. If there's no | |
922 | previous command, throws an error. Otherwise, returns the result | |
923 | of get_saved_command_line, which now points at the command to | |
924 | repeat. */ | |
925 | ||
926 | extern const char *repeat_previous (); | |
68bb5386 PW |
927 | |
928 | /* Prevent dont_repeat from working, and return a cleanup that | |
929 | restores the previous state. */ | |
c906108c | 930 | |
1ac32117 | 931 | extern scoped_restore_tmpl<int> prevent_dont_repeat (void); |
47a80e90 | 932 | |
85c4be7c TT |
933 | /* Set the arguments that will be passed if the current command is |
934 | repeated. Note that the passed-in string must be a constant. */ | |
935 | ||
936 | extern void set_repeat_arguments (const char *args); | |
937 | ||
68bb5386 PW |
938 | /* Returns the saved command line to repeat. |
939 | When a command is being executed, this is the currently executing | |
940 | command line, unless the currently executing command has called | |
941 | repeat_previous (): in this case, get_saved_command_line returns | |
942 | the previously saved command line. */ | |
943 | ||
944 | extern char *get_saved_command_line (); | |
945 | ||
946 | /* Takes a copy of CMD, for possible repetition. */ | |
947 | ||
948 | extern void save_command_line (const char *cmd); | |
949 | ||
c906108c SS |
950 | /* Used to mark commands that don't do anything. If we just leave the |
951 | function field NULL, the command is interpreted as a help topic, or | |
952 | as a class of commands. */ | |
953 | ||
eb7c454d | 954 | extern void not_just_help_class_command (const char *, int); |
c906108c | 955 | |
aff410f1 MS |
956 | /* Call the command function. */ |
957 | extern void cmd_func (struct cmd_list_element *cmd, | |
95a6b0a1 | 958 | const char *args, int from_tty); |
f436dd25 | 959 | |
cc709640 | 960 | #endif /* GDB_COMMAND_H */ |