From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id VvHvMWio22p6sRAAWB0awg (envelope-from ) for ; Fri, 23 Oct 2026 14:33:12 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=FskanjJS; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id A336A378002; Fri, 23 Oct 2026 14:33:12 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 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 F18B11E007 for ; Fri, 23 Oct 2026 14:33:11 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9D5C14BA2E31 for ; Fri, 23 Oct 2026 18:33:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D5C14BA2E31 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=FskanjJS Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 6240A4BA2E0F for ; Fri, 23 Oct 2026 18:32:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6240A4BA2E0F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6240A4BA2E0F Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792780364; cv=none; b=QiWefAcWKetWxMk6ApHJKZLp8sjmi2jc1Xjm64K6VXxN6Foy9i8Xpf/AGwM9C5qcnytDjrwHYmTmUylE/T7HLf8CPoLGRaO7tHldGM7fDPjUWkfYqUG/APQhsExBzvs662yTDQ2ZQ0p4JgJevivbQ/sDoDH3QXX7NycEzuEmszU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1792780364; c=relaxed/simple; bh=kHYvHccrZWDVvjyBRnyFOeMsKAx1PErA+PB33kl4KHc=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sY06akG/1XWpXAEaklAN7yDBFY5SwnneYu7Q0OZVqaamTcNmCvjq70p+0tNuOW5qHJYdtBLn9j0LXxitc4XgD1Q1J+zuIYDjjyaKUQ4os0uvLA0m/6xH7s3CTmiqEqiUfALcEwYLPmlXFxI+JN9MhEUqmwTWzyeObz5mr/PQzsI= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=FskanjJS reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6240A4BA2E0F Received: from eig-obgw-6003b.ext.cloudfilter.net ([10.0.30.175]) by cmsmtp with ESMTPS id KIWUxbX44aC0UKK4JxDNUp; Fri, 23 Oct 2026 18:32:43 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id KK4Ix32ltzvPGKK4IxOmHI; Fri, 23 Oct 2026 18:32:42 +0000 X-Authority-Analysis: v=2.4 cv=Y5f4sgeN c=1 sm=1 tr=0 ts=6adba84b a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=660iZSQnnn4A:10 a=ItBw4LHWJt0A:10 a=pGLkceISAAAA:8 a=YBdGec4BQl5xC1SaRPoA:9 a=DCx65vhANUyCzuf5D8fC: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:Date:References:In-Reply-To :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-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=R+CW7VsDkSoQbUgi9VMpbCSUhdsMj32WgJ7G5fyYK9Q=; b=FskanjJSA5st1FFie7N3hRKuom N3ExrrXSm3TsgJLRuyO/VzqiqJESa7PsYNLLIpmefXapulFa5rlJLkPSJf1NROq0QqiavgH7Xc06R qt+bc4EdEBU7qZkzAVdLudZuM; Received: from 97-122-110-129.hlrn.qwest.net ([97.122.110.129]:48386 helo=bapiya) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xKK4H-00000003emR-4Bxh; Fri, 23 Oct 2026 12:32:42 -0600 From: Tom Tromey To: Jielun Wu Cc: gdb-patches@sourceware.org Subject: Re: [PATCH] gdb: Reject non-base type operands in typed DWARF expressions In-Reply-To: <20260805075933.3130855-1-firmiana402@gmail.com> (Jielun Wu's message of "Wed, 5 Aug 2026 15:59:33 +0800") References: <20260805075933.3130855-1-firmiana402@gmail.com> X-Attribution: Tom Date: Fri, 23 Oct 2026 12:32:40 -0600 Message-ID: <87h5icqncn.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) 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: 97.122.110.129 X-Source-L: No X-Exim-ID: 1xKK4H-00000003emR-4Bxh X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-110-129.hlrn.qwest.net (bapiya) [97.122.110.129]:48386 X-Source-Auth: tom+tromey.com X-Email-Count: 9 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLdR3RUGNCxpOm2FprdYzhjguiysbxJTiFjvEFfHqwehCZIPm+9CoBsp8D0+kkDO5HxaL2NLFg28/2X9MUCber3P3Wbh8+qqUo1X2BmwCd6UV1Fo+twv W05iZCHswQvpx3+GQWmySSiGNZLopM77BA8Z3SmF0FCQPwavse9c0B9rj/Ijqh/gyZMbKvArxXddFr50B9fwgGdWmOZyIvyUoy8= 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 >>>>> Jielun Wu writes: > DWARF typed expression operators require a type operand that names a > DW_TAG_base_type DIE. This applies to DW_OP_const_type, > DW_OP_regval_type, DW_OP_deref_type, and the nonzero type operands of > DW_OP_convert and DW_OP_reinterpret. Thanks. > dwarf_expr_context::get_base_type documents that contract, but its > implementation accepted any DIE that resolved to a GDB type. As a > result, typed expression operators could accept non-base DIEs such as > DW_TAG_structure_type. > Add dwarf2_get_base_type to resolve the referenced DIE, reject invalid or > non-base DIEs, and return the corresponding base type. Use it from the > DWARF expression evaluator. > Add a DWARF assembler test covering DW_OP_const_type with a > DW_TAG_structure_type type operand. I wonder whether this is truly worth checking; or at least whether it is worth checking in this way. > +/* See read.h. */ > + > +struct type * > +dwarf2_get_base_type (cu_offset die_offset, dwarf2_per_cu *per_cu, > + dwarf2_per_objfile *per_objfile) > +{ > + dwarf2_cu *cu = per_objfile->get_cu (per_cu); > + if (cu == nullptr) > + cu = load_cu (per_cu, per_objfile, false); This re-reads all the DIEs, which may be expensive. But the only reason this would be needed is to check a DWARF constraint. It doesn't really matter, I think, if gdb accepts a "reasonable" expression that isn't technically correct according to DWARF. gdb does similar things in many places already, there are a bunch of supported DWARF extensions. Now, at the same time, we may not want to allow any old type to be returned. But this could be done by looking for "base-like" types -- basically scalars of various kinds -- and rejecting others. Full checking of this kind of thing could be done in a dwarflint tool, should that ever end up being real. > + _op .byte $_constants(DW_OP_const_type) > + _op .uleb128 "$struct_label - $_cu_label" > + _op .byte 4 > + _op .byte 1 > + _op .byte 2 > + _op .byte 3 > + _op .byte 4 See that other patch, a handler should be written for this. Tom