printinggdbio-redirection

GDB print to file instead of stdout


I am running GDB and want to examine one of those unfortunate god objects. It takes many pages (and I have a 24" monitor turned sideways!) to see the whole thing.

For ease of use, I'd like GDB to print the object to a file instead of the screen so that I can open it in vi and move around with ease.

With all of GDB's versatility, there must be a way to do this, right?


Solution

  • You need to enable logging:

    (gdb) set logging on
    

    Now GDB will log to ./gdb.txt. You can tell it which file to use:

    (gdb) set logging file my_god_object.log
    

    And you can examine the current logging configuration:

    (gdb) show logging