diff -rup src/gdb/doc/ChangeLog dst/gdb/doc/ChangeLog --- src/gdb/doc/ChangeLog 2011-08-27 20:35:38.459934029 +0530 +++ dst/gdb/doc/ChangeLog 2011-08-31 13:33:59.188118016 +0530 @@ -1,3 +1,7 @@ +2011-08-29 Abhijit Halder + + * gdb.texinfo (Shell Commands): Add pipe command. + 2011-08-25 Andrew Oakley * gdb.texinfo (Types In Python): Document 'bitpos' for enums. diff -rup src/gdb/doc/gdb.texinfo dst/gdb/doc/gdb.texinfo --- src/gdb/doc/gdb.texinfo 2011-08-26 21:11:39.938354007 +0530 +++ dst/gdb/doc/gdb.texinfo 2011-08-31 13:43:45.836117888 +0530 @@ -1367,6 +1367,48 @@ Execute the @code{make} program with the arguments. This is equivalent to @samp{shell make @var{make-args}}. @end table +If you want to process the output of a @value{GDBN} command using some shell +command or some script, that can be done by using the command @code{pipe}. + +@table @code +@kindex pipe +@item pipe @var{dlim} @var{gdbcmd} @var{dlim} @var{shellcmd} +@var{dlim} is a string of arbitrary length, containing no whitespace and no +leading @samp{-}, acts as a separator between a @value{GDBN} command +@var{gdbcmd} and a shell command @var{shellcmd}. The shell command should be +in compliance with the syntax of the default shell. +@end table + +@smallexample +(@value{GDBP}) @b{ptype dd_tbl} +type = struct dd @{ + int dd_handle; + const char *dd_name; + int dd_major; + int dd_minor; + void *dd_code; + void *dd_data; +@} [1024] +(@value{GDBP}) @b{pipe
print dd_tbl
sed 's/@}/\n/g' | grep @ +"\.test_dd" | tr ',' '\n'} + + @{dd_handle = 10 + dd_name = 0x8048538 ".test_dd" + dd_major = 100 + dd_minor = 0 + dd_code = 0xcc + dd_data = 0x80 +@end smallexample + +In the above example @samp{
} acts as a delimiter. The output of +@samp{print dd_tbl} is passed to the shell command @samp{sed 's/@}/\n/g' | @ +grep ".test_dd" | tr ',' '\n'} for processing. + +In the given example the output of @value{GDBN} command @samp{print dd_tbl} is +huge and not well formated. The use of shell commands like @command{sed}, +@command{tr} and @command{grep} ease the searching of desired pattern and hence +ease debugging. + @node Logging Output @section Logging Output @cindex logging @value{GDBN} output