Re: [RFC/RFA] print arrays with indexes

Daniel Jacobowitz
2005-09-06T20:57:25Z

On Tue, Sep 06, 2005 at 01:20:18PM -0700, Joel Brobecker wrote:
> So, the idea would be for GDB to print the above array as:
>
> (gdb) p array
> $2 = {0 => 1, 1 => 2, 2 => 3, 3 => 4}

> For the moment, the patch I am submitting here is using the Ada notation,
> because C/C++/ObjC don't provide this way of "qualifying" each element.
> Not sure about Fortran or Pascal. We can certainly make this a language
> method, with a default method.

In fact, C99 allows:
int A[3] = { [1] = 2 };

GNU C has supported it for a while, I think. I don't think it works
for C++.

So, yes, a language method would be good.

> (gdb) set/show print array-indexes
>
> With a default of "off", to preserve the current behavior.

I suppose we've got to :-) I'd turn it on, that's for sure.

Afraid I haven't time to look at the patch just now. I'll be back.

--
Daniel Jacobowitz
CodeSourcery, LLC