tags:

views:

318

answers:

1

When i debug a programmer, I found too many lines useless info which appear in GDB. this kind of infomation may come from iphone framework. it is not logged by my code. the info like this

Node 48 TrialMT(102,102,101,101)

Node 58 TrialMT(102,102,101,101)

Node 69 TrialMT(102,102,101,101)

Node 72 TrialMT(102,102,101,101)

Just too much. so i can not find my log.

I want to known is there a way i can export GDB log to a file, so i can find my log info in the file later on.

thanks

+1  A: 

In Xcode you can type GDB commands in the debugger console. There you can reset the stdout and stderr file descriptors to your preferred log file like this

(gdb) call (void)close(1)
(gdb) call (void)close(2)
(gdb) call (int)open("/tmp/out.log", 0x201, 0644)
$1 = 1
(gdb) call (int)dup(1)
$2 = 2
(gdb) continue
nschmidt
I finally decide use GDB console base on your useful information. i am not familiar with gdb commands .
The "call" command lets you call a function in your running process.You could achieve the same effect by calling these functions directly in your executable, e.g. in your main function. These are just the standard unix file handling functions. The file descriptors are stdin = 0, stdout = 1, stderr = 2. That's why I close 1 and 2 and then open a new file that goes to the first free file descriptor , which is 1, because we just closed it. Then dup duplicates the file descriptor to the next free descriptor: 2.
nschmidt