aboutsummaryrefslogtreecommitdiff
path: root/gdb/command.h
diff options
context:
space:
mode:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>2019-04-20 14:02:29 +0200
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>2019-05-31 17:10:08 +0200
commit68bb5386b84af4031175bf186269eb6b54b8611d (patch)
treeb3b9b003d4b9f692f2437a7afb86cd4f7efd1869 /gdb/command.h
parenta0486bac41d6ce47f27795a5abbca5cc53ddba00 (diff)
downloadfsf-binutils-gdb-68bb5386b84af4031175bf186269eb6b54b8611d.zip
fsf-binutils-gdb-68bb5386b84af4031175bf186269eb6b54b8611d.tar.gz
fsf-binutils-gdb-68bb5386b84af4031175bf186269eb6b54b8611d.tar.bz2
Add previous_saved_command_line to allow a command to repeat a previous command.
Currently, a previous command can be repeated when the user types an empty line. This is implemented in handle_line_of_input by returning saved_command_line in case an empty line has been input. If we want a command to repeat the previous command, we need to save the previous saved_command_line, as when a command runs, the saved_command_line already contains the current command line of the command being executed. As suggested by Tom, the previous_saved_command_line is made static. At the same time, saved_command_line is also made static. The support functions/variables for the repeat command logic are now all located inside top.c. gdb/ChangeLog 2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * top.h (saved_command_line): Remove declaration. * top.c (previous_saved_command_line, previous_repeat_arguments): New variables. (saved_command_line): Make static, define together with other 'repeat variables'. (dont_repeat): Clear repeat_arguments. (repeat_previous, get_saved_command_line, save_command_line): New functions. (gdb_init): Initialize saved_command_line and previous_saved_command_line. * main.c (captured_main_1): Remove saved_command_line initialization. * event-top.c (handle_line_of_input): Update to use the new 'repeat' related functions instead of direct access to saved_command_line. * command.h (repeat_previous, get_saved_command_line, save_command_line): New declarations. (dont_repeat): Add comment.
Diffstat (limited to 'gdb/command.h')
-rw-r--r--gdb/command.h36
1 files changed, 35 insertions, 1 deletions
diff --git a/gdb/command.h b/gdb/command.h
index 35006cc..26e4029 100644
--- a/gdb/command.h
+++ b/gdb/command.h
@@ -448,7 +448,29 @@ extern void cmd_show_list (struct cmd_list_element *, int, const char *);
extern void error_no_arg (const char *) ATTRIBUTE_NORETURN;
-extern void dont_repeat (void);
+
+/* Command line saving and repetition.
+ Each input line executed is saved to possibly be repeated either
+ when the user types an empty line, or be repeated by a command
+ that wants to repeat the previously executed command. The below
+ functions control command repetition. */
+
+/* Commands call dont_repeat if they do not want to be repeated by null
+ lines or by repeat_previous (). */
+
+extern void dont_repeat ();
+
+/* Commands call repeat_previous if they want to repeat the previous command.
+ Such commands that repeat the previous command must indicate
+ to not repeat themselves, to avoid recursive repeat.
+ repeat_previous will mark the current command as not repeating,
+ and will ensure get_saved_command_line returns the previous command,
+ so that the currently executing command can repeat it. */
+
+extern void repeat_previous ();
+
+/* Prevent dont_repeat from working, and return a cleanup that
+ restores the previous state. */
extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
@@ -457,6 +479,18 @@ extern scoped_restore_tmpl<int> prevent_dont_repeat (void);
extern void set_repeat_arguments (const char *args);
+/* Returns the saved command line to repeat.
+ When a command is being executed, this is the currently executing
+ command line, unless the currently executing command has called
+ repeat_previous (): in this case, get_saved_command_line returns
+ the previously saved command line. */
+
+extern char *get_saved_command_line ();
+
+/* Takes a copy of CMD, for possible repetition. */
+
+extern void save_command_line (const char *cmd);
+
/* Used to mark commands that don't do anything. If we just leave the
function field NULL, the command is interpreted as a help topic, or
as a class of commands. */