From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id rPw8Kpgc0V8aGwAAWB0awg (envelope-from ) for ; Wed, 09 Dec 2020 13:51:04 -0500 Received: by simark.ca (Postfix, from userid 112) id A028C1F0A9; Wed, 9 Dec 2020 13:51:04 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 005691E552 for ; Wed, 9 Dec 2020 13:51:01 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 439503854812; Wed, 9 Dec 2020 18:51:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 439503854812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1607539861; bh=DUNzIFH7X49yEfvVhLqeLEnhkhG8ltv0WPLzqoNX4qU=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Aip6GHnH+Ge9nq65b6XavUEUHPGa5Y7a8PSEuC/Zg6hsKtTVRNmgvaTXp7FJn1WEd vVShbGaoHnOFXq4Pq7JVjzZ8wc/9SVHnde2MW/x8FSSZDv9x5HDqxAx/OqC2fc91Xn QDPTXMAvCp94DfSVNaOsgXBhNNZYy0tjTaqTIqZU= Received: from mail.efficios.com (mail.efficios.com [167.114.26.124]) by sourceware.org (Postfix) with ESMTPS id DCB303854812 for ; Wed, 9 Dec 2020 18:50:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DCB303854812 Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 6D6C92FE17D; Wed, 9 Dec 2020 13:50:58 -0500 (EST) Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 1DsF5OIPftSg; Wed, 9 Dec 2020 13:50:58 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.efficios.com (Postfix) with ESMTP id 24EDF2FE17C; Wed, 9 Dec 2020 13:50:58 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 24EDF2FE17C X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([127.0.0.1]) by localhost (mail03.efficios.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Tymh9lAnRPYW; Wed, 9 Dec 2020 13:50:58 -0500 (EST) Received: from [10.0.0.11] (173-246-6-90.qc.cable.ebox.net [173.246.6.90]) by mail.efficios.com (Postfix) with ESMTPSA id 041272FE17B; Wed, 9 Dec 2020 13:50:57 -0500 (EST) Subject: Re: [PATCH 4/4] gdb: fix value_subscript when array upper bound is not known To: Joel Brobecker , Simon Marchi References: <20201123162120.3778679-1-simon.marchi@efficios.com> <20201123162120.3778679-5-simon.marchi@efficios.com> <20201206075437.GC327270@adacore.com> <8a48f527-bd8f-5aa9-f232-7523359515fa@polymtl.ca> <20201208031431.GG3202@adacore.com> Message-ID: Date: Wed, 9 Dec 2020 13:50:57 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <20201208031431.GG3202@adacore.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Cc: Simon Marchi via Gdb-patches Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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