Re: [RFA] print arrays with indexes

Daniel Jacobowitz
2005-10-03T15:50:27Z

On Sun, Oct 02, 2005 at 11:17:33PM -0700, Joel Brobecker wrote:
> > Should the "return 0;" cases in get_array_low_bound be errors? Or even
> > internal errors (probably not)?
>
> I don't think we should use an internal error in this case, since the
> erroneous situation can also come from incorrect debugging information.
> In this case, it would be misleading to label this as an internal error
> when the problem is outside the debugger.
>
> I wouldn't use an error in this case either, as it allows us to emit
> a warning instead, and recover in a way that at least allows us to
> print the array. Otherwise, it's more complicated to still print the
> array.
>
> So I would leave this unchanged. Or perhaps a little comment addition
> before the function, along with the description, explaining the above?

A comment would be nice. With that change, the patch (and testcase and
docs) are OK.

> > There's already lots of code that uses TYPE_LOW_BOUND (TYPE_INDEX_TYPE
> > (array_type)). If that's not valid, we need to know why not.
>
> The new function does essentially this, except that it adds a bit
> of double-checking, probably to avoid falling in a trap laid by
> incorrect debugging information.

Nick was recently writing some code that needed the bounds of an array.
We found three or four different idioms for finding this used
throughout the GDB source. Figuring out which ones are right and which
ones are obsolete is a royal pain. That's my only concern here.

--
Daniel Jacobowitz
CodeSourcery, LLC