This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFAv2 6/6] NEWS and documentation for | (pipe) command.
- From: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- To: gdb-patches at sourceware dot org
- Cc: Philippe Waroquiers <philippe dot waroquiers at skynet dot be>
- Date: Fri, 26 Apr 2019 22:11:08 +0200
- Subject: [RFAv2 6/6] NEWS and documentation for | (pipe) command.
- References: <20190426201108.7489-1-philippe.waroquiers@skynet.be>
gdb/ChangeLog
* NEWS: Mention new pipe command.
gdb/doc/ChangeLog
* gdb.texinfo (Shell Commands): Document pipe command.
(Logging Output): Add a reference to pipe command.
---
gdb/NEWS | 8 ++++++++
gdb/doc/gdb.texinfo | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/gdb/NEWS b/gdb/NEWS
index 5309a8f923..8744659e7b 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -27,6 +27,14 @@
'array_indexes', 'symbols', 'unions', 'deref_refs', 'actual_objects',
'static_members', 'max_elements', 'repeat_threshold', and 'format'.
+* New commands
+
+pipe [COMMAND] | SHELL_COMMAND
+| [COMMAND] | SHELL_COMMAND
+ Executes COMMAND and sends its output to SHELL_COMMAND.
+ With no COMMAND, repeat the last executed command
+ and send its output to SHELL_COMMAND.
+
*** Changes in GDB 8.3
* GDB and GDBserver now support access to additional registers on
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 0733e1acfd..9467b8c4ec 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -1454,6 +1454,43 @@ Execute the @code{make} program with the specified
arguments. This is equivalent to @samp{shell make @var{make-args}}.
@end table
+@table @code
+@kindex pipe
+@kindex |
+@cindex send the output of a gdb command to a shell command
+@anchor{pipe}
+@item pipe [@var{command}] | @var{shell_command}
+@itemx | [@var{command}] | @var{shell_command}
+@item pipe -d@var{X} @var{command} @var{X} @var{shell_command}
+@itemx | -d@var{X} @var{command} @var{X} @var{shell_command}
+Executes @var{command} and sends its output to @var{shell_command}.
+Note that no space is needed around @code{|}.
+If no @var{command} is provided, the last command executed is repeated.
+
+If the @var{command} contains a @code{|}, then the option @code{-d@var{X}}
+can be used to specify an alternate character that separates
+the @var{command} from the @var{shell_command}.
+
+Example:
+@smallexample
+(gdb) pipe p full|wc
+ 5 17 81
+(gdb) |p full|wc -l
+5
+(gdb) p full
+$4 = (black => 144,
+ red => 233,
+ green => 377,
+ blue => 610,
+ white => 987)
+(gdb) ||grep red
+ red => 233,
+(gdb) | -d! echo this contains a | char\n ! sed -e 's/|/PIPE/'
+this contains a PIPE char
+(gdb)
+@end smallexample
+@end table
+
@node Logging Output
@section Logging Output
@cindex logging @value{GDBN} output
@@ -1482,6 +1519,8 @@ Set @code{redirect} if you want output to go only to the log file.
Show the current values of the logging settings.
@end table
+You can also redirect the output of a @value{GDBN} command to a
+shell command. @xref{pipe}.
@node Commands
@chapter @value{GDBN} Commands
--
2.20.1