The only problem is that after adding print statements the program must be recompiled, and after debugging print statements must be removed. But it's possible to make gdb into printing machine using so called "breakpoint commands". Each breakpoint can have a list of commands that will be executed when breakpoint is hit. The commands can include printing and "continue". Here's a simplified example of gdb script I've used recently:
break main.cpp:1353 commands print ('lvk::nm_model::NM'*)this printf "Entering 'run', proc %d\n", $->processor_number continue end run
After putting this to a file "script", gdb can be run as:
producing logs of variable values as certain points of the program.
gdb -batch -x script name_of_program > log
Starting with version 3.3.0, similar functionality is available in KDevelop. Just click on the "Tracing" column in breakpoints window, select variables to print and click OK.