tags:

views:

30

answers:

2

Hi all

is there an easy way to visualize non linear(non contiguous) data structures like linked list or binary trees of a program in gnu debugger(gdb)....

to visualize an array of structures we can simply use....

print *array@len

if more indirection is needed we can also use

print **array@len

but above works for only linear data structures like arrays...

Please let me know if non linear(non contiguous) data structures likes linked list or binary trees can be visualized in a similar way... Thanks in advance...

A: 

You might give ddd a try. It'll even create fancy maps of your data structure.

Myles
thanks for the info. But we will be connecting to the remote terminal so no GUI is allowed. Are there any commands in gdb to facilitate this...
Vineel Kumar Reddy
If you setup gdb server on the remote side and attach that way, you can still use the GUI, but you're right, there are GDB functions to facilitate what you want, it just involves successfully printing each memory location.
Myles
A: 

GDB 7.x contains embedded Python interpreter (if so configured) and can be used to examine arbitrarily complicated data structures.

In particular, it can print contents of std::map and std::set, which are much more complicated "inside" than binary trees.

More info here and here.

Employed Russian