views:

147

answers:

2

Running the debugger in xcode when you set a break point you get a view a variable and can see all of the fantastically interesting values associated with it.

Is there anyway to save/export this data to a file?

I am of course having an issue where something is wrong but there is a ton of variables and I want to just compare one run of the program to the next easily.

+1  A: 

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>
nall
A: 
cdespinosa