aboutsummaryrefslogtreecommitdiff
path: root/gdb/command.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/command.c')
-rw-r--r--gdb/command.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gdb/command.c b/gdb/command.c
index 0b541a7..dc9d5fc 100644
--- a/gdb/command.c
+++ b/gdb/command.c
@@ -1138,6 +1138,51 @@ make_command (arg, from_tty)
shell_escape (p, from_tty);
}
+static void
+user_info_1 (c, stream)
+ struct cmd_list_element *c;
+ FILE *stream;
+{
+ register struct command_line *cmdlines;
+
+ cmdlines = c->user_commands;
+ if (!cmdlines)
+ return;
+ fprintf_filtered (stream, "User command %s:\n", c->name);
+ while (cmdlines)
+ {
+ fprintf_filtered (stream, "%s\n", cmdlines->line);
+ cmdlines = cmdlines->next;
+ }
+ fputs_filtered ("\n", stream);
+}
+
+/* ARGSUSED */
+static void
+user_info (args, from_tty)
+ char *args;
+ int from_tty;
+{
+ struct cmd_list_element *c;
+ extern struct cmd_list_element *cmdlist;
+
+ if (args)
+ {
+ c = lookup_cmd (&args, cmdlist, "", 0, 1);
+ if (c->class != class_user)
+ error ("Not a user command.");
+ user_info_1 (c, stdout);
+ }
+ else
+ {
+ for (c = cmdlist; c; c = c->next)
+ {
+ if (c->class == class_user)
+ user_info_1 (c, stdout);
+ }
+ }
+}
+
void
_initialize_command ()
{
@@ -1147,4 +1192,8 @@ With no arguments, run an inferior shell.");
add_com ("make", class_support, make_command,
"Run the ``make'' program using the rest of the line as arguments.");
+
+ add_info ("user", user_info, "Show definitions of user defined commands.\n\
+Argument is the name of the user defined command.\n\
+With no argument, show definitions of all user defined commands.");
}