This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: gdb - Printing multiple arrays or arrays of arrays
- From: Andreas Schwab <schwab at suse dot de>
- To: Dedeco <dedeco at ufmg dot br>
- Cc: gdb at sourceware dot org
- Date: Fri, 30 Jun 2006 21:29:21 +0200
- Subject: Re: gdb - Printing multiple arrays or arrays of arrays
- References: <44A57082.3090703@ufmg.br>
Dedeco <dedeco@ufmg.br> writes:
> But what if I have:
>
> int **vec = malloc( 9 * sizeof(int*));
> for (i=0; i<10; i++)
> vec[i] = malloc(10 *sizeof(int*));
>
> How to print the 90 values I have?
set $i = 0
while $i < 9
p vec[$i++]@10
end
> Further, how would I print other such complex things? Like arrays of
> structures with an array inside the last.
You can define your own commands and use print, output and echo to format
the output in pretty much any way you want. Or you could add some
functions to your program that output the structure and call them from
gdb. The GCC sources have examples of both.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."