This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Array-of-structures slices


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]