From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CAf3KDo5hml1kSwAWB0awg (envelope-from ) for ; Fri, 06 Feb 2026 13:55:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1770404154; bh=ci7c7zKgdLNaP8Bhr1KeZoeHPKnC5H1cdygiOpiScG8=; h=Date:Subject:To:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=BKBYgwOFXfJOPzE/ax7NslF9tIBBtOrNfycHnm0BTghgwAMpA+1lC6sIM4ISsATgy d4PZk2S8dQEgS56sRticzCjK5xFli7I9fadpFYItBTGtUmWrve0hkUfGyBcUmrtOju bvhLkEmHZB6QmrVii2U1nH687FjnF/Q4MGL9b62w= Received: by simark.ca (Postfix, from userid 112) id 90CC01E0BA; Fri, 06 Feb 2026 13:55:54 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=tWw+Ys9/; dkim-atps=neutral Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DAF511E08D for ; Fri, 06 Feb 2026 13:55:53 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 507F24BAD15F for ; Fri, 6 Feb 2026 18:55:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 507F24BAD15F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=tWw+Ys9/ Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 53C404B9DB4D for ; Fri, 6 Feb 2026 18:55:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 53C404B9DB4D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 53C404B9DB4D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770404128; cv=none; b=JVogbAaBPnnaNqJQCZlygpVuEPs8W96Y+vtof7vCF0WAvY6qAHFw/5P9PZo8QXkFzyqcy6tFypncQd8v07eYvXcloUBKdoZUKN5Nfxzt1qVOEGSlZjNdq3ZLdIYsN2YKuw/FP4J1yy6pf1MzkCirPjju1x1GQZ5tOATfRCiwUJw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1770404128; c=relaxed/simple; bh=ci7c7zKgdLNaP8Bhr1KeZoeHPKnC5H1cdygiOpiScG8=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=RcGD9cn4r8FhD3PP5Ndmg3IGB8RibNybfnbIzg/u7UUFw/VC2etjJZrQGRmA7tEZ8SaqYZBAPVIRBrzeFMiWDOtZzmfq2CDhESMmdd4/LeyjxAtopNuth8rV4hbqDBo5UgL1cnXGCVDRDCWgPIoBDKOi98PpT1tviGwqe0gdI64= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 53C404B9DB4D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1770404127; bh=ci7c7zKgdLNaP8Bhr1KeZoeHPKnC5H1cdygiOpiScG8=; h=Date:Subject:To:References:From:In-Reply-To:From; b=tWw+Ys9/HJqAF/lVCUc+tCMWUF+7QA4PKVRV3mUNHStnNlrlovKge5eKVu8IRzOLF QGgnufz30evhhZgLEjTletmmEb1vcWbgUqTrFQaEUfv/4JJEDCPoH7RQDPBaox+05t uS+uLu9NJc3kPqhpFe/rUrSkWQk8taNYA9dSR5qE= Received: by simark.ca (Postfix) id A29E71E08D; Fri, 06 Feb 2026 13:55:27 -0500 (EST) Message-ID: <92fa2fb3-f7a2-4bf7-ba6b-9f5fc288ba35@simark.ca> Date: Fri, 6 Feb 2026 13:55:27 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Turn value_field into a method To: Tom Tromey , gdb-patches@sourceware.org References: <20260206184023.1848421-1-tom@tromey.com> Content-Language: en-US From: Simon Marchi In-Reply-To: <20260206184023.1848421-1-tom@tromey.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org On 2026-02-06 13:40, Tom Tromey wrote: > diff --git a/gdb/value.h b/gdb/value.h > index 1ef3acd6054..201db773a84 100644 > --- a/gdb/value.h > +++ b/gdb/value.h > @@ -626,6 +626,14 @@ struct value > struct value *primitive_field (LONGEST offset, int fieldno, > struct type *arg_type); > > + /* Given that this value is of a struct or union type, extract and > + return the value of one of its (non-static) fields. FIELDNO says > + which field. */ For future work: that comment makes me think it would be nice to have an assert (probably in value::primitive_field) to check that the type is indeed a struct or union. If calling with a non-struct/non-union type, this assert in type::field would probably trigger: gdb_assert (idx >= 0 && idx < num_fields ()); But it would be nice to check the precondition in primitive_field too, it would be clearer. Approved-By: Simon Marchi Simon