From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from alt-proxy28.mail.unifiedlayer.com (alt-proxy28.mail.unifiedlayer.com [74.220.216.123]) by sourceware.org (Postfix) with ESMTPS id 953193858D28 for ; Tue, 31 Jan 2023 18:47:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 953193858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw10.mail.unifiedlayer.com (unknown [10.0.90.125]) by progateway1.mail.pro1.eigbox.com (Postfix) with ESMTP id E59F610038969 for ; Tue, 31 Jan 2023 18:47:41 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id MvfRpYs5Vx5dfMvfRpFwnk; Tue, 31 Jan 2023 18:47:41 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=R+nGpfdX c=1 sm=1 tr=0 ts=63d9624d a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=RvmDmJFTN0MA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=13KGAo4DAAAA:8 a=mDV3o1hIAAAA:8 a=YXOVaL2IKl77xQOXuwUA:9 a=34u-kb3MJp4A:10:demote_hacked_domain_1 a=17SRMNvc95cA:10:demote_hacked_domain_7 a=DdAeqqNASC6T8jxox_Jq:22 a=_FVE-zBwftR9WsbkzFJk:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:References :Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0QjMYmWVASshIluoeF7bIaw8TLJ48BwXZs5HfO2dymc=; b=soSUoy//0dNuTVWJm58GAo9adf 6dg887dsdV2TsmQUjnIL6UDltr8P1y8H2bqc0tsjqNAlmPsZn/uK1wTNSCaDwb6C7qeP+gl/o4/pd pV27F0tRiCVGhUUppFnfGJG1C; Received: from 71-211-157-143.hlrn.qwest.net ([71.211.157.143]:35060 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pMvfR-002Ylv-HZ; Tue, 31 Jan 2023 11:47:41 -0700 From: Tom Tromey To: "Maciej W. Rozycki" Cc: gdb-patches@sourceware.org, Andrew Burgess , Tom Tromey , Richard Bunt Subject: Re: [PATCH v3 3/5] GDB: Only make data actually retrieved into value history available References: X-Attribution: Tom Date: Tue, 31 Jan 2023 11:47:38 -0700 In-Reply-To: (Maciej W. Rozycki's message of "Mon, 23 Jan 2023 23:14:06 +0000 (GMT)") Message-ID: <87fsbqlewl.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 71.211.157.143 X-Source-L: No X-Exim-ID: 1pMvfR-002Ylv-HZ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-157-143.hlrn.qwest.net (murgatroyd) [71.211.157.143]:35060 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3020.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,JMQ_SPF_NEUTRAL,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: >>>>> "Maciej" == Maciej W Rozycki writes: Maciej> While it makes sense to allow accessing out-of-bounds elements in the Maciej> debuggee and see whatever there might happen to be there in memory (we Maciej> are a debugger and not a programming rules enforcement facility and we Maciej> want to make people's life easier in chasing bugs), e.g.: Thank you for the patch. Maciej> Index: src/gdb/defs.h Maciej> =================================================================== Maciej> --- src.orig/gdb/defs.h Maciej> +++ src/gdb/defs.h Maciej> @@ -469,6 +469,10 @@ enum val_prettyformat Maciej> #define LONG_MAX ((long)(ULONG_MAX >> 1)) /* 0x7FFFFFFF for 32-bits */ Maciej> #endif Maciej> +#if !defined (LONG_MIN) /* 0x80000000 for 32-bits */ Maciej> +#define LONG_MIN ((long) (~(long) 0 ^ LONG_MAX)) Maciej> +#endif I wasn't aware of this code being here. For LONG_*, I tend to think we don't need it. should provide it, and gnulib seems to think there aren't any systems without this: https://www.gnu.org/software/gnulib/manual/html_node/limits_002eh.html Maciej> +#if !defined (LONGEST_MIN) /* 0x8000000000000000 for 64-bits */ Maciej> +#define LONGEST_MIN ((LONGEST) (~(LONGEST) 0 ^ LONGEST_MAX)) Maciej> +#endif This one probably belongs in gdbsupport/common-types.h. We should clean up this part of defs.h but I can do that. Maciej> @@ -1950,6 +1955,15 @@ record_latest_value (struct value *val) Maciej> a value on the value history never changes. */ Maciej> if (value_lazy (val)) Maciej> value_fetch_lazy (val); Maciej> + Maciej> + /* Don't pretend we have anything available there in the history beyond Maciej> + the boundaries of the value recorded. It's not like inferior memory Maciej> + where there is actual stuff underneath. */ Maciej> + ULONGEST length = value_enclosing_type (val)->length (); Maciej> + mark_value_bits_unavailable (val, LONGEST_MIN, 0 ^ LONGEST_MIN); Maciej> + mark_value_bits_unavailable (val, length * TARGET_CHAR_BIT, Maciej> + LONGEST_MAX - length * TARGET_CHAR_BIT); I'm struggling to understand why this is needed. Like it seems to me that a value should always report that bytes outside of its content range are unavailable. Tom