Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Array-of-structures slices
@ 2003-12-02 20:55 Mihai Basa
  2003-12-02 20:57 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: Mihai Basa @ 2003-12-02 20:55 UTC (permalink / raw)
  To: gdb

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.


Regards,
Mihai Basa


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Array-of-structures slices
  2003-12-02 20:55 Array-of-structures slices Mihai Basa
@ 2003-12-02 20:57 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2003-12-02 20:57 UTC (permalink / raw)
  To: Mihai Basa; +Cc: gdb

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-12-02 20:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-02 20:55 Array-of-structures slices Mihai Basa
2003-12-02 20:57 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox