aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli/cli-decode.c
diff options
context:
space:
mode:
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>2019-04-20 14:14:23 +0200
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>2019-05-31 17:12:18 +0200
commit947d39462e26b0edee9b58003ea579552dbf4fa8 (patch)
treeb9852eb9de8f1b0df7dee3f140c239a6f87cfe75 /gdb/cli/cli-decode.c
parentb8fd091888383703f5d708c597c496d7b9e47a21 (diff)
downloadgdb-947d39462e26b0edee9b58003ea579552dbf4fa8.zip
gdb-947d39462e26b0edee9b58003ea579552dbf4fa8.tar.gz
gdb-947d39462e26b0edee9b58003ea579552dbf4fa8.tar.bz2
Implement | (pipe) command.
The pipe command allows to run a GDB command, and pipe its output to a shell command: (gdb) help pipe Send the output of a gdb command to a shell command. Usage: | [COMMAND] | SHELL_COMMAND Usage: | -d DELIM COMMAND DELIM SHELL_COMMAND Usage: pipe [COMMAND] | SHELL_COMMAND Usage: pipe -d DELIM COMMAND DELIM SHELL_COMMAND Executes COMMAND and sends its output to SHELL_COMMAND. The -d option indicates to use the string DELIM to separate COMMAND from SHELL_COMMAND, in alternative to |. This is useful in case COMMAND contains a | character. With no COMMAND, repeat the last executed command and send its output to SHELL_COMMAND. (gdb) For example: (gdb) pipe print some_data_structure | grep -B3 -A3 something The pipe character is defined as an alias for pipe command, so that the above can be typed as: (gdb) | print some_data_structure | grep -B3 -A3 something If no GDB COMMAND is given, then the previous command is relaunched, and its output is sent to the given SHELL_COMMAND. This also defines convenience vars $_shell_exitcode and $_shell_exitsignal to record the exit code and exit signal of the last shell command launched by GDB e.g. by "shell", "pipe", ... gdb/ChangeLog 2019-05-31 Philippe Waroquiers <philippe.waroquiers@skynet.be> * cli/cli-cmds.c (pipe_command): New function. (_initialize_cli_cmds): Call add_com for pipe_command. Define | as an alias for pipe. (exit_status_set_internal_vars): New function. (shell_escape): Call exit_status_set_internal_vars. cli/cli-decode.c (find_command_name_length): Recognize | as a single character command.
Diffstat (limited to 'gdb/cli/cli-decode.c')
-rw-r--r--gdb/cli/cli-decode.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index 72e2a97..e3076f2 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -1311,9 +1311,9 @@ find_command_name_length (const char *text)
Note that this is larger than the character set allowed when
creating user-defined commands. */
- /* Recognize '!' as a single character command so that, e.g., "!ls"
+ /* Recognize the single character commands so that, e.g., "!ls"
works as expected. */
- if (*p == '!')
+ if (*p == '!' || *p == '|')
return 1;
while (isalnum (*p) || *p == '-' || *p == '_'