Alex Rivera | Logout

How to dump the entire GDB session to a file, including commands I type and their output?

Asked 2009-11-10T11:05:19.747
21

In bash, I can use the script command, which dumps everything that shows on the shell to a file, including:

  • commands typed
  • PS1 line
  • stdout and stderr of commands

What is the equivalent in gdb?

I tried to run shell script from inside GDB, but after I hit return, I was in the shell and lost the shell prompt and could not run command any more. Moreover I could not use ctrl+c or ctrl+\ to exit. I needed to force kill the /bin/login tty2 to exit.

gdb
Edit
Report

1 Answer

35

If you want to log GDB's output, you can use the GDB logging output commands, eg.

set logging file mylog.txt
set logging on

If you want to redirect your program's output to a file, you can use a redirect, eg.

run myprog > mylog.txt

see the chapter on program IO in the GDB manual for more information

answered 2009-11-10T11:23:47.883

Your Answer