1 /* GDB commands implemented in Scheme.
3 Copyright (C) 2008-2021 Free Software Foundation, Inc.
5 This file is part of GDB.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* See README file in this directory for implementation notes, coding
21 conventions, et.al. */
27 #include "cli/cli-decode.h"
28 #include "completer.h"
29 #include "guile-internal.h"
31 /* The <gdb:command> smob.
33 Note: Commands are added to gdb using a two step process:
34 1) Call make-command to create a <gdb:command> object.
35 2) Call register-command! to add the command to gdb.
36 It is done this way so that the constructor, make-command, doesn't have
37 any side-effects. This means that the smob needs to store everything
38 that was passed to make-command. */
42 /* This always appears first. */
45 /* The name of the command, as passed to make-command. */
48 /* The last word of the command.
49 This is needed because add_cmd requires us to allocate space
53 /* Non-zero if this is a prefix command. */
56 /* One of the COMMAND_* constants. */
57 enum command_class cmd_class
;
59 /* The documentation for the command. */
62 /* The corresponding gdb command object.
63 This is NULL if the command has not been registered yet, or
64 is no longer registered. */
65 struct cmd_list_element
*command
;
67 /* A prefix command requires storage for a list of its sub-commands.
68 A pointer to this is passed to add_prefix_command, and to add_cmd
69 for sub-commands of that prefix.
70 This is NULL if the command has not been registered yet, or
71 is no longer registered. If this command is not a prefix
72 command, then this field is unused. */
73 struct cmd_list_element
*sub_list
;
75 /* The procedure to call to invoke the command.
76 (lambda (self arg from-tty) ...).
77 Its result is unspecified. */
80 /* Either #f, one of the COMPLETE_* constants, or a procedure to call to
81 perform command completion. Called as (lambda (self text word) ...). */
84 /* The <gdb:command> object we are contained in, needed to protect/unprotect
85 the object since a reference to it comes from non-gc-managed space
86 (the command context pointer). */
90 static const char command_smob_name
[] = "gdb:command";
92 /* The tag Guile knows the objfile smob by. */
93 static scm_t_bits command_smob_tag
;
95 /* Keywords used by make-command. */
96 static SCM invoke_keyword
;
97 static SCM command_class_keyword
;
98 static SCM completer_class_keyword
;
99 static SCM prefix_p_keyword
;
100 static SCM doc_keyword
;
102 /* Struct representing built-in completion types. */
103 struct cmdscm_completer
105 /* Scheme symbol name. */
107 /* Completion function. */
108 completer_ftype
*completer
;
111 static const struct cmdscm_completer cmdscm_completers
[] =
113 { "COMPLETE_NONE", noop_completer
},
114 { "COMPLETE_FILENAME", filename_completer
},
115 { "COMPLETE_LOCATION", location_completer
},
116 { "COMPLETE_COMMAND", command_completer
},
117 { "COMPLETE_SYMBOL", symbol_completer
},
118 { "COMPLETE_EXPRESSION", expression_completer
},
121 #define N_COMPLETERS (sizeof (cmdscm_completers) \
122 / sizeof (cmdscm_completers[0]))
124 static int cmdscm_is_valid (command_smob
*);
126 /* Administrivia for command smobs. */
128 /* The smob "print" function for <gdb:command>. */
131 cmdscm_print_command_smob (SCM self
, SCM port
, scm_print_state
*pstate
)
133 command_smob
*c_smob
= (command_smob
*) SCM_SMOB_DATA (self
);
135 gdbscm_printf (port
, "#<%s", command_smob_name
);
137 gdbscm_printf (port
, " %s",
138 c_smob
->name
!= NULL
? c_smob
->name
: "{unnamed}");
140 if (! cmdscm_is_valid (c_smob
))
141 scm_puts (" {invalid}", port
);
143 scm_puts (">", port
);
145 scm_remember_upto_here_1 (self
);
147 /* Non-zero means success. */
151 /* Low level routine to create a <gdb:command> object.
152 It's empty in the sense that a command still needs to be associated
156 cmdscm_make_command_smob (void)
158 command_smob
*c_smob
= (command_smob
*)
159 scm_gc_malloc (sizeof (command_smob
), command_smob_name
);
162 memset (c_smob
, 0, sizeof (*c_smob
));
163 c_smob
->cmd_class
= no_class
;
164 c_smob
->invoke
= SCM_BOOL_F
;
165 c_smob
->complete
= SCM_BOOL_F
;
166 c_scm
= scm_new_smob (command_smob_tag
, (scm_t_bits
) c_smob
);
167 c_smob
->containing_scm
= c_scm
;
168 gdbscm_init_gsmob (&c_smob
->base
);
173 /* Clear the COMMAND pointer in C_SMOB and unprotect the object from GC. */
176 cmdscm_release_command (command_smob
*c_smob
)
178 c_smob
->command
= NULL
;
179 scm_gc_unprotect_object (c_smob
->containing_scm
);
182 /* Return non-zero if SCM is a command smob. */
185 cmdscm_is_command (SCM scm
)
187 return SCM_SMOB_PREDICATE (command_smob_tag
, scm
);
190 /* (command? scm) -> boolean */
193 gdbscm_command_p (SCM scm
)
195 return scm_from_bool (cmdscm_is_command (scm
));
198 /* Returns the <gdb:command> object in SELF.
199 Throws an exception if SELF is not a <gdb:command> object. */
202 cmdscm_get_command_arg_unsafe (SCM self
, int arg_pos
, const char *func_name
)
204 SCM_ASSERT_TYPE (cmdscm_is_command (self
), self
, arg_pos
, func_name
,
210 /* Returns a pointer to the command smob of SELF.
211 Throws an exception if SELF is not a <gdb:command> object. */
213 static command_smob
*
214 cmdscm_get_command_smob_arg_unsafe (SCM self
, int arg_pos
,
215 const char *func_name
)
217 SCM c_scm
= cmdscm_get_command_arg_unsafe (self
, arg_pos
, func_name
);
218 command_smob
*c_smob
= (command_smob
*) SCM_SMOB_DATA (c_scm
);
223 /* Return non-zero if command C_SMOB is valid. */
226 cmdscm_is_valid (command_smob
*c_smob
)
228 return c_smob
->command
!= NULL
;
231 /* Returns a pointer to the command smob of SELF.
232 Throws an exception if SELF is not a valid <gdb:command> object. */
234 static command_smob
*
235 cmdscm_get_valid_command_smob_arg_unsafe (SCM self
, int arg_pos
,
236 const char *func_name
)
239 = cmdscm_get_command_smob_arg_unsafe (self
, arg_pos
, func_name
);
241 if (!cmdscm_is_valid (c_smob
))
243 gdbscm_invalid_object_error (func_name
, arg_pos
, self
,
250 /* Scheme functions for GDB commands. */
252 /* (command-valid? <gdb:command>) -> boolean
253 Returns #t if SELF is still valid. */
256 gdbscm_command_valid_p (SCM self
)
259 = cmdscm_get_command_smob_arg_unsafe (self
, SCM_ARG1
, FUNC_NAME
);
261 return scm_from_bool (cmdscm_is_valid (c_smob
));
264 /* (dont-repeat cmd) -> unspecified
265 Scheme function which wraps dont_repeat. */
268 gdbscm_dont_repeat (SCM self
)
270 /* We currently don't need anything from SELF, but still verify it.
271 Call for side effects. */
272 cmdscm_get_valid_command_smob_arg_unsafe (self
, SCM_ARG1
, FUNC_NAME
);
276 return SCM_UNSPECIFIED
;
279 /* The make-command function. */
281 /* Called if the gdb cmd_list_element is destroyed. */
284 cmdscm_destroyer (struct cmd_list_element
*self
, void *context
)
286 command_smob
*c_smob
= (command_smob
*) context
;
288 cmdscm_release_command (c_smob
);
291 /* Called by gdb to invoke the command. */
294 cmdscm_function (struct cmd_list_element
*command
,
295 const char *args
, int from_tty
)
297 command_smob
*c_smob
/*obj*/ = (command_smob
*) get_cmd_context (command
);
298 SCM arg_scm
, tty_scm
, result
;
300 gdb_assert (c_smob
!= NULL
);
304 arg_scm
= gdbscm_scm_from_string (args
, strlen (args
), host_charset (), 1);
305 if (gdbscm_is_exception (arg_scm
))
306 error (_("Could not convert arguments to Scheme string."));
308 tty_scm
= scm_from_bool (from_tty
);
310 result
= gdbscm_safe_call_3 (c_smob
->invoke
, c_smob
->containing_scm
,
311 arg_scm
, tty_scm
, gdbscm_user_error_p
);
313 if (gdbscm_is_exception (result
))
315 /* Don't print the stack if this was an error signalled by the command
317 if (gdbscm_user_error_p (gdbscm_exception_key (result
)))
319 gdb::unique_xmalloc_ptr
<char> msg
320 = gdbscm_exception_message_to_string (result
);
322 error ("%s", msg
.get ());
326 gdbscm_print_gdb_exception (SCM_BOOL_F
, result
);
327 error (_("Error occurred in Scheme-implemented GDB command."));
332 /* Subroutine of cmdscm_completer to simplify it.
333 Print an error message indicating that COMPLETION is a bad completion
337 cmdscm_bad_completion_result (const char *msg
, SCM completion
)
339 SCM port
= scm_current_error_port ();
341 scm_puts (msg
, port
);
342 scm_display (completion
, port
);
346 /* Subroutine of cmdscm_completer to simplify it.
347 Validate COMPLETION and add to RESULT.
348 If an error occurs print an error message.
349 The result is a boolean indicating success. */
352 cmdscm_add_completion (SCM completion
, completion_tracker
&tracker
)
356 if (!scm_is_string (completion
))
358 /* Inform the user, but otherwise ignore the entire result. */
359 cmdscm_bad_completion_result (_("Bad text from completer: "),
364 gdb::unique_xmalloc_ptr
<char> item
365 = gdbscm_scm_to_string (completion
, NULL
, host_charset (), 1,
369 /* Inform the user, but otherwise ignore the entire result. */
370 gdbscm_print_gdb_exception (SCM_BOOL_F
, except_scm
);
374 tracker
.add_completion (std::move (item
));
379 /* Called by gdb for command completion. */
382 cmdscm_completer (struct cmd_list_element
*command
,
383 completion_tracker
&tracker
,
384 const char *text
, const char *word
)
386 command_smob
*c_smob
/*obj*/ = (command_smob
*) get_cmd_context (command
);
387 SCM completer_result_scm
;
388 SCM text_scm
, word_scm
;
390 gdb_assert (c_smob
!= NULL
);
391 gdb_assert (gdbscm_is_procedure (c_smob
->complete
));
393 text_scm
= gdbscm_scm_from_string (text
, strlen (text
), host_charset (),
395 if (gdbscm_is_exception (text_scm
))
396 error (_("Could not convert \"text\" argument to Scheme string."));
397 word_scm
= gdbscm_scm_from_string (word
, strlen (word
), host_charset (),
399 if (gdbscm_is_exception (word_scm
))
400 error (_("Could not convert \"word\" argument to Scheme string."));
403 = gdbscm_safe_call_3 (c_smob
->complete
, c_smob
->containing_scm
,
404 text_scm
, word_scm
, NULL
);
406 if (gdbscm_is_exception (completer_result_scm
))
408 /* Inform the user, but otherwise ignore. */
409 gdbscm_print_gdb_exception (SCM_BOOL_F
, completer_result_scm
);
413 if (gdbscm_is_true (scm_list_p (completer_result_scm
)))
415 SCM list
= completer_result_scm
;
417 while (!scm_is_eq (list
, SCM_EOL
))
419 SCM next
= scm_car (list
);
421 if (!cmdscm_add_completion (next
, tracker
))
424 list
= scm_cdr (list
);
427 else if (itscm_is_iterator (completer_result_scm
))
429 SCM iter
= completer_result_scm
;
430 SCM next
= itscm_safe_call_next_x (iter
, NULL
);
432 while (gdbscm_is_true (next
))
434 if (gdbscm_is_exception (next
))
436 /* Inform the user. */
437 gdbscm_print_gdb_exception (SCM_BOOL_F
, completer_result_scm
);
441 if (cmdscm_add_completion (next
, tracker
))
444 next
= itscm_safe_call_next_x (iter
, NULL
);
449 /* Inform the user, but otherwise ignore. */
450 cmdscm_bad_completion_result (_("Bad completer result: "),
451 completer_result_scm
);
455 /* Helper for gdbscm_make_command which locates the command list to use and
456 pulls out the command name.
458 NAME is the command name list. The final word in the list is the
459 name of the new command. All earlier words must be existing prefix
462 *BASE_LIST is set to the final prefix command's list of
465 START_LIST is the list in which the search starts.
467 This function returns the xmalloc()d name of the new command.
468 On error a Scheme exception is thrown. */
471 gdbscm_parse_command_name (const char *name
,
472 const char *func_name
, int arg_pos
,
473 struct cmd_list_element
***base_list
,
474 struct cmd_list_element
**start_list
)
476 struct cmd_list_element
*elt
;
477 int len
= strlen (name
);
480 const char *prefix_text2
;
483 /* Skip trailing whitespace. */
484 for (i
= len
- 1; i
>= 0 && (name
[i
] == ' ' || name
[i
] == '\t'); --i
)
488 gdbscm_out_of_range_error (func_name
, arg_pos
,
489 gdbscm_scm_from_c_string (name
),
490 _("no command name found"));
494 /* Find first character of the final word. */
495 for (; i
> 0 && valid_cmd_char_p (name
[i
- 1]); --i
)
497 result
= (char *) xmalloc (lastchar
- i
+ 2);
498 memcpy (result
, &name
[i
], lastchar
- i
+ 1);
499 result
[lastchar
- i
+ 1] = '\0';
501 /* Skip whitespace again. */
502 for (--i
; i
>= 0 && (name
[i
] == ' ' || name
[i
] == '\t'); --i
)
506 *base_list
= start_list
;
510 prefix_text
= (char *) xmalloc (i
+ 2);
511 memcpy (prefix_text
, name
, i
+ 1);
512 prefix_text
[i
+ 1] = '\0';
514 prefix_text2
= prefix_text
;
515 elt
= lookup_cmd_1 (&prefix_text2
, *start_list
, NULL
, NULL
, 1);
516 if (elt
== NULL
|| elt
== CMD_LIST_AMBIGUOUS
)
518 msg
= xstrprintf (_("could not find command prefix '%s'"), prefix_text
);
521 scm_dynwind_begin ((scm_t_dynwind_flags
) 0);
522 gdbscm_dynwind_xfree (msg
);
523 gdbscm_out_of_range_error (func_name
, arg_pos
,
524 gdbscm_scm_from_c_string (name
), msg
);
527 if (elt
->is_prefix ())
530 *base_list
= elt
->subcommands
;
534 msg
= xstrprintf (_("'%s' is not a prefix command"), prefix_text
);
537 scm_dynwind_begin ((scm_t_dynwind_flags
) 0);
538 gdbscm_dynwind_xfree (msg
);
539 gdbscm_out_of_range_error (func_name
, arg_pos
,
540 gdbscm_scm_from_c_string (name
), msg
);
544 static const scheme_integer_constant command_classes
[] =
546 /* Note: alias and user are special; pseudo appears to be unused,
547 and there is no reason to expose tui, I think. */
548 { "COMMAND_NONE", no_class
},
549 { "COMMAND_RUNNING", class_run
},
550 { "COMMAND_DATA", class_vars
},
551 { "COMMAND_STACK", class_stack
},
552 { "COMMAND_FILES", class_files
},
553 { "COMMAND_SUPPORT", class_support
},
554 { "COMMAND_STATUS", class_info
},
555 { "COMMAND_BREAKPOINTS", class_breakpoint
},
556 { "COMMAND_TRACEPOINTS", class_trace
},
557 { "COMMAND_OBSCURE", class_obscure
},
558 { "COMMAND_MAINTENANCE", class_maintenance
},
559 { "COMMAND_USER", class_user
},
561 END_INTEGER_CONSTANTS
564 /* Return non-zero if command_class is a valid command class. */
567 gdbscm_valid_command_class_p (int command_class
)
571 for (i
= 0; command_classes
[i
].name
!= NULL
; ++i
)
573 if (command_classes
[i
].value
== command_class
)
580 /* Return a normalized form of command NAME.
581 That is tabs are replaced with spaces and multiple spaces are replaced
583 If WANT_TRAILING_SPACE is non-zero, add one space at the end. This is for
585 but that is the caller's responsibility.
586 Space for the result is allocated on the GC heap. */
589 gdbscm_canonicalize_command_name (const char *name
, int want_trailing_space
)
591 int i
, out
, seen_word
;
593 = (char *) scm_gc_malloc_pointerless (strlen (name
) + 2, FUNC_NAME
);
595 i
= out
= seen_word
= 0;
598 /* Skip whitespace. */
599 while (name
[i
] == ' ' || name
[i
] == '\t')
601 /* Copy non-whitespace characters. */
606 while (name
[i
] && name
[i
] != ' ' && name
[i
] != '\t')
607 result
[out
++] = name
[i
++];
611 if (want_trailing_space
)
618 /* (make-command name [#:invoke lambda]
619 [#:command-class class] [#:completer-class completer]
620 [#:prefix? <bool>] [#:doc <string>]) -> <gdb:command>
622 NAME is the name of the command. It may consist of multiple words,
623 in which case the final word is the name of the new command, and
624 earlier words must be prefix commands.
626 INVOKE is a procedure of three arguments that performs the command when
627 invoked: (lambda (self arg from-tty) ...).
628 Its result is unspecified.
630 CLASS is the kind of command. It must be one of the COMMAND_*
631 constants defined in the gdb module. If not specified, "no_class" is used.
633 COMPLETER is the kind of completer. It must be either:
634 #f - completion is not supported for this command.
635 One of the COMPLETE_* constants defined in the gdb module.
636 A procedure of three arguments: (lambda (self text word) ...).
637 Its result is one of:
639 A <gdb:iterator> object that returns the set of possible completions,
641 TODO(dje): Once PR 16699 is fixed, add support for returning
642 a COMPLETE_* constant.
643 If not specified, then completion is not supported for this command.
645 If PREFIX is #t, then this command is a prefix command.
647 DOC is the doc string for the command.
649 The result is the <gdb:command> Scheme object.
650 The command is not available to be used yet, however.
651 It must still be added to gdb with register-command!. */
654 gdbscm_make_command (SCM name_scm
, SCM rest
)
656 const SCM keywords
[] = {
657 invoke_keyword
, command_class_keyword
, completer_class_keyword
,
658 prefix_p_keyword
, doc_keyword
, SCM_BOOL_F
660 int invoke_arg_pos
= -1, command_class_arg_pos
= 1;
661 int completer_class_arg_pos
= -1, is_prefix_arg_pos
= -1;
662 int doc_arg_pos
= -1;
665 enum command_class command_class
= no_class
;
666 SCM completer_class
= SCM_BOOL_F
;
669 SCM invoke
= SCM_BOOL_F
;
671 command_smob
*c_smob
;
673 gdbscm_parse_function_args (FUNC_NAME
, SCM_ARG1
, keywords
, "s#OiOts",
674 name_scm
, &name
, rest
,
675 &invoke_arg_pos
, &invoke
,
676 &command_class_arg_pos
, &command_class
,
677 &completer_class_arg_pos
, &completer_class
,
678 &is_prefix_arg_pos
, &is_prefix
,
682 doc
= xstrdup (_("This command is not documented."));
685 name
= gdbscm_canonicalize_command_name (s
, is_prefix
);
688 doc
= gdbscm_gc_xstrdup (s
);
695 gdbscm_out_of_range_error (FUNC_NAME
, SCM_ARG1
, name_scm
,
696 _("no command name found"));
699 if (gdbscm_is_true (invoke
))
701 SCM_ASSERT_TYPE (gdbscm_is_procedure (invoke
), invoke
,
702 invoke_arg_pos
, FUNC_NAME
, _("procedure"));
705 if (!gdbscm_valid_command_class_p (command_class
))
707 gdbscm_out_of_range_error (FUNC_NAME
, command_class_arg_pos
,
708 scm_from_int (command_class
),
709 _("invalid command class argument"));
712 SCM_ASSERT_TYPE (gdbscm_is_false (completer_class
)
713 || scm_is_integer (completer_class
)
714 || gdbscm_is_procedure (completer_class
),
715 completer_class
, completer_class_arg_pos
, FUNC_NAME
,
716 _("integer or procedure"));
717 if (scm_is_integer (completer_class
)
718 && !scm_is_signed_integer (completer_class
, 0, N_COMPLETERS
- 1))
720 gdbscm_out_of_range_error (FUNC_NAME
, completer_class_arg_pos
,
722 _("invalid completion type argument"));
725 c_scm
= cmdscm_make_command_smob ();
726 c_smob
= (command_smob
*) SCM_SMOB_DATA (c_scm
);
728 c_smob
->is_prefix
= is_prefix
;
729 c_smob
->cmd_class
= command_class
;
731 c_smob
->invoke
= invoke
;
732 c_smob
->complete
= completer_class
;
737 /* (register-command! <gdb:command>) -> unspecified
739 It is an error to register a command more than once. */
742 gdbscm_register_command_x (SCM self
)
745 = cmdscm_get_command_smob_arg_unsafe (self
, SCM_ARG1
, FUNC_NAME
);
747 struct cmd_list_element
**cmd_list
;
748 struct cmd_list_element
*cmd
= NULL
;
750 if (cmdscm_is_valid (c_smob
))
751 scm_misc_error (FUNC_NAME
, _("command is already registered"), SCM_EOL
);
753 cmd_name
= gdbscm_parse_command_name (c_smob
->name
, FUNC_NAME
, SCM_ARG1
,
754 &cmd_list
, &cmdlist
);
755 c_smob
->cmd_name
= gdbscm_gc_xstrdup (cmd_name
);
758 gdbscm_gdb_exception exc
{};
761 if (c_smob
->is_prefix
)
763 /* If we have our own "invoke" method, then allow unknown
765 int allow_unknown
= gdbscm_is_true (c_smob
->invoke
);
767 cmd
= add_prefix_cmd (c_smob
->cmd_name
, c_smob
->cmd_class
,
768 NULL
, c_smob
->doc
, &c_smob
->sub_list
,
769 allow_unknown
, cmd_list
);
773 cmd
= add_cmd (c_smob
->cmd_name
, c_smob
->cmd_class
,
774 c_smob
->doc
, cmd_list
);
777 catch (const gdb_exception
&except
)
779 exc
= unpack (except
);
781 GDBSCM_HANDLE_GDB_EXCEPTION (exc
);
783 /* Note: At this point the command exists in gdb.
784 So no more errors after this point. */
786 /* There appears to be no API to set this. */
787 cmd
->func
= cmdscm_function
;
788 cmd
->destroyer
= cmdscm_destroyer
;
790 c_smob
->command
= cmd
;
791 set_cmd_context (cmd
, c_smob
);
793 if (gdbscm_is_true (c_smob
->complete
))
795 set_cmd_completer (cmd
,
796 scm_is_integer (c_smob
->complete
)
797 ? cmdscm_completers
[scm_to_int (c_smob
->complete
)].completer
801 /* The owner of this command is not in GC-controlled memory, so we need
802 to protect it from GC until the command is deleted. */
803 scm_gc_protect_object (c_smob
->containing_scm
);
805 return SCM_UNSPECIFIED
;
808 /* Initialize the Scheme command support. */
810 static const scheme_function command_functions
[] =
812 { "make-command", 1, 0, 1, as_a_scm_t_subr (gdbscm_make_command
),
814 Make a GDB command object.\n\
816 Arguments: name [#:invoke lambda]\n\
817 [#:command-class <class>] [#:completer-class <completer>]\n\
818 [#:prefix? <bool>] [#:doc string]\n\
819 name: The name of the command. It may consist of multiple words,\n\
820 in which case the final word is the name of the new command, and\n\
821 earlier words must be prefix commands.\n\
822 invoke: A procedure of three arguments to perform the command.\n\
823 (lambda (self arg from-tty) ...)\n\
824 Its result is unspecified.\n\
825 class: The class of the command, one of COMMAND_*.\n\
826 The default is COMMAND_NONE.\n\
827 completer: The kind of completer, #f, one of COMPLETE_*, or a procedure\n\
828 to perform the completion: (lambda (self text word) ...).\n\
829 prefix?: If true then the command is a prefix command.\n\
830 doc: The \"doc string\" of the command.\n\
831 Returns: <gdb:command> object" },
833 { "register-command!", 1, 0, 0, as_a_scm_t_subr (gdbscm_register_command_x
),
835 Register a <gdb:command> object with GDB." },
837 { "command?", 1, 0, 0, as_a_scm_t_subr (gdbscm_command_p
),
839 Return #t if the object is a <gdb:command> object." },
841 { "command-valid?", 1, 0, 0, as_a_scm_t_subr (gdbscm_command_valid_p
),
843 Return #t if the <gdb:command> object is valid." },
845 { "dont-repeat", 1, 0, 0, as_a_scm_t_subr (gdbscm_dont_repeat
),
847 Prevent command repetition when user enters an empty line.\n\
849 Arguments: <gdb:command>\n\
850 Returns: unspecified" },
855 /* Initialize the 'commands' code. */
858 gdbscm_initialize_commands (void)
863 = gdbscm_make_smob_type (command_smob_name
, sizeof (command_smob
));
864 scm_set_smob_print (command_smob_tag
, cmdscm_print_command_smob
);
866 gdbscm_define_integer_constants (command_classes
, 1);
867 gdbscm_define_functions (command_functions
, 1);
869 for (i
= 0; i
< N_COMPLETERS
; ++i
)
871 scm_c_define (cmdscm_completers
[i
].name
, scm_from_int (i
));
872 scm_c_export (cmdscm_completers
[i
].name
, NULL
);
875 invoke_keyword
= scm_from_latin1_keyword ("invoke");
876 command_class_keyword
= scm_from_latin1_keyword ("command-class");
877 completer_class_keyword
= scm_from_latin1_keyword ("completer-class");
878 prefix_p_keyword
= scm_from_latin1_keyword ("prefix?");
879 doc_keyword
= scm_from_latin1_keyword ("doc");