Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
To: Joel Brobecker <brobecker@adacore.com>,
	Simon Marchi <simon.marchi@polymtl.ca>
Cc: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH 4/4] gdb: fix value_subscript when array upper bound is not known
Date: Wed, 9 Dec 2020 13:50:57 -0500	[thread overview]
Message-ID: <a25b71dd-4425-3bcc-8211-a8e8874c88e3@efficios.com> (raw)
In-Reply-To: <20201208031431.GG3202@adacore.com>

On 2020-12-07 10:14 p.m., Joel Brobecker wrote:
> [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];

Right, but the language doesn't do bound checks, so I don't think the debugger
should either.  What I meant is that there's no need to resolve the upper bound
for c-style arrays, because we don't check the upper bound.

>> 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...

I would imagine that with a language that is more strict and does bound-checks
when accessing arrays, this kind of trick wouldn't exist.  So there probably
wouldn't be legitimate use cases for doing out-of-bounds accesses.

Simon

  reply	other threads:[~2020-12-09 18:51 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-23 16:21 [PATCH 0/4] Fix bug in value_subscript when range's high " Simon Marchi via Gdb-patches
2020-11-23 16:21 ` [PATCH 1/4] gdb: make discrete_position return optional Simon Marchi via Gdb-patches
2020-12-06  5:25   ` Joel Brobecker
2020-12-06  5:38   ` Joel Brobecker
2020-12-07 14:58     ` Simon Marchi via Gdb-patches
2020-12-08  3:06       ` Joel Brobecker
2020-12-08 11:41         ` Maciej W. Rozycki
2020-12-09 19:29           ` Simon Marchi via Gdb-patches
2020-12-09 19:53             ` Maciej W. Rozycki
2020-11-23 16:21 ` [PATCH 2/4] gdb: make get_discrete_bounds return bool Simon Marchi via Gdb-patches
2020-12-06  6:03   ` Joel Brobecker
2020-12-07 15:19     ` Simon Marchi via Gdb-patches
2020-11-23 16:21 ` [PATCH 3/4] gdb: split get_discrete_bounds in two Simon Marchi via Gdb-patches
2020-12-06  7:29   ` Joel Brobecker
2020-12-07 15:49     ` Simon Marchi via Gdb-patches
2020-11-23 16:21 ` [PATCH 4/4] gdb: fix value_subscript when array upper bound is not known Simon Marchi via Gdb-patches
2020-12-06  7:54   ` Joel Brobecker
2020-12-07 16:06     ` Simon Marchi via Gdb-patches
2020-12-08  3:14       ` Joel Brobecker
2020-12-09 18:50         ` Simon Marchi via Gdb-patches [this message]
2020-12-09 19:57     ` Simon Marchi via Gdb-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a25b71dd-4425-3bcc-8211-a8e8874c88e3@efficios.com \
    --to=gdb-patches@sourceware.org \
    --cc=brobecker@adacore.com \
    --cc=simon.marchi@efficios.com \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox