This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Array-of-structures slices
- From: Daniel Jacobowitz <drow at mvista dot com>
- To: Mihai Basa <Mihai dot Basa at NUIGALWAY dot IE>
- Cc: gdb at sources dot redhat dot com
- Date: Tue, 2 Dec 2003 15:57:55 -0500
- Subject: Re: Array-of-structures slices
- References: <3FCC10B6@bodkin.nuigalway.ie>
On Tue, Dec 02, 2003 at 08:57:19PM +0000, Mihai Basa wrote:
> Hello,
>
>
> GDB can "display" values from a slice of an array (using the @ operator) - IF
> that array is made up of base datatypes. It cannot plot slices if the array is
> made of structures, and I believe it would be really useful if it could...
>
> As an example, assume we have an array A[100] made up of structures like this:
> typedef struct {
> int x;
> int y;
> };
>
> I think it would be good if GDB could print/display the string of 100 A.x 'es.
> The syntax describing this might be something like:
>
> display (A[0]@100).x
>
> which currently just displays A[0].x. This means reading an array of 100
> elements, starting from A[0] with a stride equal to sizeof(A[0]). Currently
> GDB can only read with a stride of sizeof(x), if we were to say (A[0].x)@100,
> which reads alternating x'es and y'es.
>
> If this were possible quick visual comparison of a string of related variables
> stored in structures could be made. Another reason why I see this as useful is
> because if this were possible one could use the DDD front-end to plot
> in-program results, even from structures.
Yes, I've often wanted the same thing. However, it's quite tricky to
implement.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer