From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 7+2tCGPsImCeaAAAWB0awg (envelope-from ) for ; Tue, 09 Feb 2021 15:11:15 -0500 Received: by simark.ca (Postfix, from userid 112) id 13EC41EF4F; Tue, 9 Feb 2021 15:11:15 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=DKIM_SIGNED,MAILING_LIST_MULTI, RCVD_IN_BL_SPAMCOP_NET,T_DKIM_INVALID,URIBL_BLOCKED autolearn=no 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 98E3F1E590 for ; Tue, 9 Feb 2021 15:11:14 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1D6413939C1D; Tue, 9 Feb 2021 20:11:14 +0000 (GMT) Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.130]) by sourceware.org (Postfix) with ESMTPS id 5C0BA3835402 for ; Tue, 9 Feb 2021 20:11:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5C0BA3835402 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway33.websitewelcome.com (Postfix) with ESMTP id D07FD1EBC6C2 for ; Tue, 9 Feb 2021 14:11:10 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 9ZLqlAL2ZiQiZ9ZLqlXqxW; Tue, 09 Feb 2021 14:11:10 -0600 X-Authority-Reason: nr=8 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=Jw0dlL2RQb2IPBm4WZDVv3O8MFWFd9/DMHi3Xo+vusU=; b=AeVXa6+0NTKo1E1RjSv+ssehB9 lf2+JXsEpyKBguYfSA3g991ZTicD77hBGjgG4/sneM0zSEczIp2cW40Yxt2XD1WAold0g2LTkvSOy waY26Iyu7bXHO9FCVzshORcHg; Received: from 97-122-91-54.hlrn.qwest.net ([97.122.91.54]:42954 helo=murgatroyd) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1l9ZLp-001gXt-Ra; Tue, 09 Feb 2021 13:11:09 -0700 From: Tom Tromey To: Zoran Zaric via Gdb-patches Subject: Re: [PATCH 21/30] Change DWARF stack to use new dwarf_entry classes References: <20201207190031.13341-1-Zoran.Zaric@amd.com> <20201207190031.13341-22-Zoran.Zaric@amd.com> X-Attribution: Tom Date: Tue, 09 Feb 2021 13:11:08 -0700 In-Reply-To: <20201207190031.13341-22-Zoran.Zaric@amd.com> (Zoran Zaric via Gdb-patches's message of "Mon, 7 Dec 2020 19:00:22 +0000") Message-ID: <87sg65atnn.fsf@tromey.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.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: 97.122.91.54 X-Source-L: No X-Exim-ID: 1l9ZLp-001gXt-Ra X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-91-54.hlrn.qwest.net (murgatroyd) [97.122.91.54]:42954 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" >>>>> "Zoran" == Zoran Zaric via Gdb-patches writes: Zoran> To replace existing DWARF stack element (dwarf_stack_value) with Zoran> dwarf_entry class based objects, a support for conversion between Zoran> struct value and the new classes is needed. The reason for this is Zoran> that dwarf_entry based classes are not designed to be visible outside Zoran> the expr.c file. This makes the DWARF expression evaluator more self Zoran> contained. This can be beneficial if there is ever a need to have a Zoran> DWARF support in gdbserver. Zoran> Once the conversion support is added, the current DWARF stack element Zoran> can easily be swapped out. Thank you. This is a rather large patch, but a lot of it seems to be pretty routine. I had some minor notes, basically the same kind of thing as in other patches. Zoran> - /* The pieces describing this variable. */ Zoran> - std::vector pieces; Zoran> + /* Location description of this variable. */ Zoran> + dwarf_location *location; This sort of change replaces automatic management by manual management, which ought to be avoided. Zoran> + /* Only expect implicit pointer and composite location Zoran> + description here. */ Zoran> + if (entry == nullptr Zoran> + || (dynamic_cast (entry) == nullptr Zoran> + && dynamic_cast (entry) == nullptr)) Zoran> + internal_error (__FILE__, __LINE__, _("invalid location type")); I wonder about virtual methods here, though this is a borderline case for me. Probably instead of internal_error this should use gdb_assert though. Zoran> + /* Reading from and writing to an implicit pointer is not meaningful, Zoran> + so we just skip them here. */ Zoran> + if (dynamic_cast (entry) != nullptr) dynamic_cast should generally be avoided if reasonably possible. I realize it isn't always, I suspect I'm the #1 adder of dynamic_cast to the code. But still it's worth a try. Zoran> +static void Zoran> +read_pieced_value (struct value *v) Zoran> +{ Zoran> + rw_pieced_value (v, NULL); Zoran> +} Zoran> +static void Zoran> +write_pieced_value (struct value *to, struct value *from) Zoran> +{ Zoran> + rw_pieced_value (to, from); Zoran> +} These both seems like perhaps some other function could just be renamed. Zoran> { Zoran> + entry_factory = new dwarf_entry_factory (); Zoran> } See the previous patch; but if the factory must have state, why not just make it a member? Zoran> +/* Check that the current operator is either at the end of an Zoran> + expression, or that it is followed by a composition operator or by Zoran> + DW_OP_GNU_uninit (which should terminate the expression). */ Zoran> void dwarf_expr_require_composition (const gdb_byte *, const gdb_byte *, Zoran> const char *); I like these comment additions but they seem unrelated. They could just be a separate patch. Tom