Thursday, October 29, 2009

print array,structure,union in gdb

gdb is a very strong tool. It can even print structure,union and array the way you want.
- To print array :
int *arr
gdb> print *arr@5 // will print 5 elements of the array

Following variables can be set to print them in one per line :
set print array on
set print pretty on // for printing structure in nice form
set print union on
...

And there are lot more. Just need to do
info gcc on linux box (if info is installed)
or
gcc> help is very helpful.

No comments:

Post a Comment