Re: [PATCH 4/4] gdb: fix value_subscript when array upper bound is not known

Joel Brobecker
2020-12-08T03:14:40Z

[just for the sake of discussing generalities, rather than suggesting
modifications to your patch]

> > Now, the bigger question is: Why are we even getting to this point?
> > Shouldn't the bounds simply be resolved before we do the subscripting?
>
> If the array is c-style, there's no concept of high bound, so I don't think
> there's a point resolving the high bound then.

I believe you sometimes do, for intance in...

char something[5];

> Again, I've never really been a user of such a language. Intuitively, I'd
> like the debugger to work as close to the source language as possible, so
> I'd like it to validate the bounds in my expression. But it might be that
> people who use these languages sometimes need to side-step the language's
> protections.

Speaking for myself, sometimes I indeed want to go beyond.

Even in C, when we have structures looking like this (don't know if we
have any of those in our code anymore):

struct something
{
size_t n_elems;
int buf[0];
};

You'd know that you need to go beyond the first element of the array
to get to the rest of the data...

--
Joel