You can use gdb for this. The following gdb commands are useful:
set log file <filename>
set logging on
... do interesting stuff ...
set logging off
This will log the section "do interesting stuff" to  as a text file.
If you want to get really fancy and have a fixed set of commands/variables you want to dump, you can make a function and stick it in $HOME/.gdbinit. Then get to a breakpoint and just issue dumplog (if using the example below) at the gdb prompt.
# Example that just does some random stuff 
define dumplog
    set logging file foo.txt
    b main
    c
    set logging on
    po var1
    po var2
    set logging off
end
Another approach which I just learned is issuing the following from a terminal. It has the benefit of no manual intervention, but I just tried it and you get quite a bit of extra garbage in that file.
defaults write com.apple.Xcode PBXGDBDebuggerLogToFile YES
defaults write com.apple.Xcode PBXGDBDebuggerLogFileName <filename>