Search code examples
gdb

gdb - pipe output of internal command to the shell command


Is there any way how to pipe output of internal gdb command to some shell command like grep - the variant of [cmd] ! grep in mdb?

To be more clear: in solaris mdb you can e.g. write

main::dis ! grep call

to detect which functions are called from the main (or grep some register names to see how it is changed). I am interested if there is such possibility to do so just in gdb without necessarity to switching from gdb.


Solution

  • A new GDB command has been introduced, namely pipe. If you want to process the output of a GDB command using some shell command or some script, that can be done using this new command.

    https://sourceware.org/gdb/onlinedocs/gdb/Shell-Commands.html

    pipe [command] | shell_command