Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb - pipe output of internal command to the shell command

Tags:

gdb

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.

like image 765
Michy Avatar asked Feb 23 '23 05:02

Michy


1 Answers

I am not sure if I have understood your question correctly. If you want to a log results of your GDB commands that you ran during a debug session, then Yes there is support for this from GDB.

show logging                    # displays weather logging is on / off
set logging on                  # enable logging
set logging off                 # disable logging
set logging file log-file.txt   # set name for log file, default is gdb.txt

the log file will be generated in your current directory.

Further you can append logs of debug sessions or create new on every debug session using

set logging overwrite <on/off>
like image 183
Kamath Avatar answered Mar 05 '23 06:03

Kamath