Log execution with GDB
Here is a sequence of commands which may be handy when debugging with GDB. It’s a sequence which allows you to go through the execution and log all the output into a file. And it does that automatically.
set logging file output-file.log
set height 0
set logging on
set logging redirectwhile 1
si
end
- with first command we set a output file where we expect our log after the execution
- set height sets our screen size, overriding it to 0, so we don’t get messages like this:
- “—Type <return> to continue, or q <return> to quit—“
- logging on enables logging
- and logging redirect doesn’t show output on the screen (which slightly speeds up the process)
- while loop executes commands inside the loop while the program is running. Instead si, you can use n, ni, s or any other like p or maybe x/i $pc. Just be sure to use at least one command like s or n (which execute), so that you don’t end up with the loop running indefinitely.