From patchwork Tue Feb 27 03:12:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 86412 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D3963858420 for ; Tue, 27 Feb 2024 03:13:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id BAF1A3858C50 for ; Tue, 27 Feb 2024 03:13:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BAF1A3858C50 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 BAF1A3858C50 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709003585; cv=none; b=HProJJdQGvhSJ2pHTXrA9UMEAOqSFEk74XV/pYhHrRhT8h2KsPz4Zrh0/L9UcdM6kVTyVEbjyAx5CbwmfvN2I9xxudNJMbCdn5jHWnioAyEGoMdoF86vaCyegJFmSaKLfVPJiEl6lnE7hWNifTUSoBvmp9IeTUDngqR10GcPRng= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709003585; c=relaxed/simple; bh=22kj/qdLwf+zUiZCEKeD1LqhoCtiPVJCD/p1w2g3IvY=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=cxt30HrzHlPcyidJqo/8JFXyEZyYaFYTEB5uaEZgBb2BkGlgVrmDlT9BoKPC1ePzhw4iERyRs3vMeYNVBwBH4hPG4jgsnjf1xpwfrmjwjVi6KOvBF8aLnXoTwk0qVTG4Y7et0QpGZWIAGottm26GXHe9EyM4gwg3M1qt6uA3Azs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id en7krYldquh6sentur6yGU; Tue, 27 Feb 2024 03:13:02 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id enttr8E7Kk4fsenttrq2p7; Tue, 27 Feb 2024 03:13:02 +0000 X-Authority-Analysis: v=2.4 cv=eZw7faEH c=1 sm=1 tr=0 ts=65dd533e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=zstS-IiYAAAA:8 a=20KFwNOVAAAA:8 a=aafxSZypWaQ67KQJpqUA:9 a=QEXdDO2ut3YA:10 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=HJP6g1mfg2FLkKj6IQSXqOzbN5iLPCRrxXDWcqBQvVg=; b=r7OySzonsCIaR7ZzMFdwAdnN8V mXodrS6Rf75/CRLuPU3nMncoCwR6yQUb9dJhli79bXhycA9dagsanZcpjk/QkX7rhtIVkGAH8OX5r DYw5M/CcUUvBKKc0zM3GkSXAF; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:51654 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rentt-004JgU-12 for gcc-patches@gcc.gnu.org; Mon, 26 Feb 2024 20:13:01 -0700 From: Tom Tromey Date: Mon, 26 Feb 2024 20:12:54 -0700 Subject: [PATCH 1/3] Change 'v1' float and int code to fall back to v0 MIME-Version: 1.0 Message-Id: <20240226-gdb-compile-align-v1-1-0f95d6435299@tromey.com> References: <20240226-gdb-compile-align-v1-0-0f95d6435299@tromey.com> In-Reply-To: <20240226-gdb-compile-align-v1-0-0f95d6435299@tromey.com> To: gcc-patches@gcc.gnu.org X-Mailer: b4 0.12.4 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 - gcc.gnu.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.170.195 X-Source-L: No X-Exim-ID: 1rentt-004JgU-12 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:51654 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfHEhSEEPMJQIKAbhNu2AlY3S2szMue1AhozhcV9NOSydgphTENY4yDYI3McC7sCzRzPOaNZsm1vJ8jxyVu6OaZ3wOBrw3OAVqt7WMWvGIP+wq9TB3Ig/ kBZPBCY5RIPOSsGHdcP6jHiaAZtqGGoU3Vcrq8Ku2CfR8dPjjlMx3/kFaEnGhSaxTPvtQKx/pNoXl6o0cPwBnNlYgbJ0nzyRFes= X-Spam-Status: No, score=-3022.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org While working on another patch, I discovered that the libcc1 plugin code never did version negotiation correctly. So, the patches to introduce v1 never did anything -- the new code, as far as I know, has never been run. Making version negotiation work shows that the existing code causes crashes. For example, safe_lookup_builtin_type might return error_mark_node in some cases, which the callers aren't prepared to accept. Looking into it some more, I couldn't find any justification for this v1 code for the C compiler plugin. Since it's not run at all, it's also clear that removing it doesn't cause any regressions in gdb. However, rather than remove it, this patch changes it to handle ERROR_MARK better, and then to fall back to the v0 code if the new code fails to find the type it's looking for. 2024-02-26 Tom Tromey * libcc1plugin.cc (safe_lookup_builtin_type): Handle ERROR_MARK. (plugin_int_type): Fall back to plugin_int_type_v0. (plugin_float_type): Fall back to plugin_float_type_v0. --- libcc1/ChangeLog | 6 ++++++ libcc1/libcc1plugin.cc | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libcc1/ChangeLog b/libcc1/ChangeLog index f81fe389e71..b0b31ee6586 100644 --- a/libcc1/ChangeLog +++ b/libcc1/ChangeLog @@ -1,3 +1,9 @@ +2024-02-26 Tom Tromey + + * libcc1plugin.cc (safe_lookup_builtin_type): Handle ERROR_MARK. + (plugin_int_type): Fall back to plugin_int_type_v0. + (plugin_float_type): Fall back to plugin_float_type_v0. + 2024-02-09 Marek Polacek PR c++/98388 diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc index 00d3963029d..f1082d8e9d3 100644 --- a/libcc1/libcc1plugin.cc +++ b/libcc1/libcc1plugin.cc @@ -555,7 +555,7 @@ safe_lookup_builtin_type (const char *builtin_name) gcc_assert (TREE_CODE (result) == TYPE_DECL); result = TREE_TYPE (result); - return result; + return TREE_CODE (result) == ERROR_MARK ? nullptr : result; } static gcc_type @@ -592,13 +592,14 @@ plugin_int_type (cc1_plugin::connection *self, int is_unsigned, unsigned long size_in_bytes, const char *builtin_name) { - if (!builtin_name) - return plugin_int_type_v0 (self, is_unsigned, size_in_bytes); - - tree result = safe_lookup_builtin_type (builtin_name); - gcc_assert (!result || TREE_CODE (result) == INTEGER_TYPE); - - return plugin_int_check (self, is_unsigned, size_in_bytes, result); + if (builtin_name != nullptr) + { + tree result = safe_lookup_builtin_type (builtin_name); + gcc_assert (!result || TREE_CODE (result) == INTEGER_TYPE); + if (result != nullptr) + return plugin_int_check (self, is_unsigned, size_in_bytes, result); + } + return plugin_int_type_v0 (self, is_unsigned, size_in_bytes); } gcc_type @@ -631,7 +632,7 @@ plugin_float_type (cc1_plugin::connection *self, tree result = safe_lookup_builtin_type (builtin_name); if (!result) - return convert_out (error_mark_node); + return plugin_float_type_v0 (self, size_in_bytes); gcc_assert (SCALAR_FLOAT_TYPE_P (result)); gcc_assert (BITS_PER_UNIT * size_in_bytes == TYPE_PRECISION (result)); From patchwork Tue Feb 27 03:12:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 86413 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B7EBB3858297 for ; Tue, 27 Feb 2024 03:13:44 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omta38.uswest2.a.cloudfilter.net (omta38.uswest2.a.cloudfilter.net [35.89.44.37]) by sourceware.org (Postfix) with ESMTPS id 2D5213858C54 for ; Tue, 27 Feb 2024 03:13:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2D5213858C54 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 2D5213858C54 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709003586; cv=none; b=MyLfj8THUtVDgVWSP2LWnS3neaFCKqXX07NaG2Fo1BPPqH99sbdz+N8LbHMGJe0XcsKXU2a4jqcRFo8XS56fsi1RnDwyLs382zvNH2UCxBB0iHzZxR9AXYfu+ajqBxEdUSL1qrPUDWb6NWM+MKZL4MeIuiD0k0GBxPiv3Q5rFnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709003586; c=relaxed/simple; bh=zzW5pD3sLo/cHm7/gSSJ628UshXp4FvlMVaY+0qZM2g=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=uFJZysdJ4xHRV+UK2sUYjmylLUucik1XtwmQRQuVZGrHjC+qFPcJHuXsfqM/6W/E5sbPdFDVIujBb7scbpuXnnEmYS5t03vCGNEF+WhqwSJHWIPU6t0uFtpYYbOJ9Db1XXIdMqWLOePTb8FP26eEGbSCpsNGyfX9G00zTGFsPBU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5004a.ext.cloudfilter.net ([10.0.29.221]) by cmsmtp with ESMTPS id ek2yrvo6zDI6fenturMGNw; Tue, 27 Feb 2024 03:13:02 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id enttrQIhDk2tLentur22IC; Tue, 27 Feb 2024 03:13:02 +0000 X-Authority-Analysis: v=2.4 cv=Xvr8O0F9 c=1 sm=1 tr=0 ts=65dd533e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=zstS-IiYAAAA:8 a=5S_eGvRSsEjQ3BIV9RUA:9 a=QEXdDO2ut3YA:10 a=JBl1FMDXjovBvWafNo1k:22 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=1pZPO76XsxeLjc2hFeINTGq7V5YPV821DPPhqQmaUOk=; b=oKaTtF11Skb7uoD47j1wdFRRBk b8FmilOrcJfIuMPjYy9+VfxNedf54hmHO9Q5MBd/k/nHAhGN9a7wWbioiw/0091ULKw7awnUCJ41G vUUHBG6RaN7O6jYwGs+QPhhAU; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:51654 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rentt-004JgU-1S for gcc-patches@gcc.gnu.org; Mon, 26 Feb 2024 20:13:01 -0700 From: Tom Tromey Date: Mon, 26 Feb 2024 20:12:55 -0700 Subject: [PATCH 2/3] Fix version negotiation in libcc1 plugins MIME-Version: 1.0 Message-Id: <20240226-gdb-compile-align-v1-2-0f95d6435299@tromey.com> References: <20240226-gdb-compile-align-v1-0-0f95d6435299@tromey.com> In-Reply-To: <20240226-gdb-compile-align-v1-0-0f95d6435299@tromey.com> To: gcc-patches@gcc.gnu.org X-Mailer: b4 0.12.4 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 - gcc.gnu.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.170.195 X-Source-L: No X-Exim-ID: 1rentt-004JgU-1S X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:51654 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEBXPIJYuAAGxhCJZtYVSeefy2IWsadCUzIiwJMeT4xsxAy03X5akIFh+a822UFXulbY5DXKMenuPkrRM27iAQaa9YvcS7ZJRkSfi09s7VsBcve1ErDT SDitqA/q8qKpoFlIVi3G081T+9/Y011qbTOXsBQSbBrFCqkWsxSmDAaV0RURwP0pnOShCFu2H9MeFv0LO3ZtClH2COX5SWgFKg0= X-Spam-Status: No, score=-3022.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org This fixes version negotiation in the libcc1 plugins. It's done in a simple way: the version number from the context object is now passed to base_gdb_plugin. The idea behind this is that when the client (gdb) requests version N, the plugin should respond with the newest version that it knows of that is backward compatible to N. That is, the connection can be upgraded. Note that the protocol does not change much, and no backward incompatibilities have ever been needed. The C plugin is also changed to advertise GCC_C_FE_VERSION_1. The version negotiation approach should of course be documented, but I did that in a subsequent patch, in order to only have one patch touching the 'include' directory and thus needing a merge to binutils-gdb. 2024-02-26 Tom Tromey * libcp1.cc (libcp1::libcp1): Use FE version number from context. * libcc1.cc (libcc1::libcc1): Use FE version number from context. (c_vtable): Use GCC_C_FE_VERSION_1. --- libcc1/ChangeLog | 6 ++++++ libcc1/libcc1.cc | 4 ++-- libcc1/libcp1.cc | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libcc1/ChangeLog b/libcc1/ChangeLog index b0b31ee6586..b4072574ba8 100644 --- a/libcc1/ChangeLog +++ b/libcc1/ChangeLog @@ -1,3 +1,9 @@ +2024-02-26 Tom Tromey + + * libcp1.cc (libcp1::libcp1): Use FE version number from context. + * libcc1.cc (libcc1::libcc1): Use FE version number from context. + (c_vtable): Use GCC_C_FE_VERSION_1. + 2024-02-26 Tom Tromey * libcc1plugin.cc (safe_lookup_builtin_type): Handle ERROR_MARK. diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc index 8d4ddc5ddfe..992181e8fdc 100644 --- a/libcc1/libcc1.cc +++ b/libcc1/libcc1.cc @@ -54,7 +54,7 @@ struct libcc1 : public cc1_plugin::base_gdb_plugin libcc1::libcc1 (const gcc_c_fe_vtable *cv) : cc1_plugin::base_gdb_plugin ("libcc1plugin", C_COMPILER_NAME, - GCC_C_FE_VERSION_1) + cv->c_version) { c_ops = cv; } @@ -108,7 +108,7 @@ set_callbacks (struct gcc_c_context *s, static const struct gcc_c_fe_vtable c_vtable = { - GCC_C_FE_VERSION_0, + GCC_C_FE_VERSION_1, set_callbacks, #define GCC_METHOD0(R, N) \ diff --git a/libcc1/libcp1.cc b/libcc1/libcp1.cc index ec3eec2c606..cc2915d30af 100644 --- a/libcc1/libcp1.cc +++ b/libcc1/libcp1.cc @@ -55,7 +55,7 @@ struct libcp1 : public cc1_plugin::base_gdb_plugin libcp1::libcp1 (const gcc_cp_fe_vtable *cv) : cc1_plugin::base_gdb_plugin ("libcp1plugin", CP_COMPILER_NAME, - GCC_CP_FE_VERSION_0) + cv->cp_version) { cp_ops = cv; } From patchwork Tue Feb 27 03:12:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 86414 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 433A53858C56 for ; Tue, 27 Feb 2024 03:14:37 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from omta040.useast.a.cloudfilter.net (omta040.useast.a.cloudfilter.net [44.202.169.39]) by sourceware.org (Postfix) with ESMTPS id AD00E3858C98 for ; Tue, 27 Feb 2024 03:13:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AD00E3858C98 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 AD00E3858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709003585; cv=none; b=ksuDNyn6ZELygcR7Dc4MOIV3JcQ7bUOsHVXrHVRzjTLXlI6bTgM/wpp80w5zU6fR+a4l3QzeOWgdcHpoBIk9ZMxnUVQbkww2pMqzFtbvy8AUo8ZAEPF5WZEQAZhPGJWj5DsvU2h/HKFUfcqRV5HfQMxhEU701o2ZXoBLKFOcMTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709003585; c=relaxed/simple; bh=p6y5zFtA5UM9AHSQpwf+jnXKSd8cRiuicJkxwDsPaTc=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=jB9W6YvzMoFZoOJrcQaN7MKyw3R5LYMIwCXvfYtS2JP5JHxHuPIEJ/5I8eRG67tzZAx0X56VSe5iG8EmdqHBuvG8moX0ettImniRplXin8/V+YKJyPQyJwvzI9E2oT9CxrLI172rvvuhH0crwf9WPRbys0NyWaglUSGuR5QM5M0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5001a.ext.cloudfilter.net ([10.0.29.139]) by cmsmtp with ESMTPS id ek2QreEHml9dRenturtPgr; Tue, 27 Feb 2024 03:13:02 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id enttrXpjtmKT3enturfN2W; Tue, 27 Feb 2024 03:13:02 +0000 X-Authority-Analysis: v=2.4 cv=f/dOBvyM c=1 sm=1 tr=0 ts=65dd533e a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=k7vzHIieQBIA:10 a=Qbun_eYptAEA:10 a=zstS-IiYAAAA:8 a=20KFwNOVAAAA:8 a=wRGsumYYegGURm0rCcgA:9 a=QEXdDO2ut3YA:10 a=4G6NA9xxw8l3yy4pmD5M:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc: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=Q2ffYDW6UhzSiY0P/psH6jjvgkv6W91nrcDIumnlI94=; b=PLFIezHxJISa8qdrfsml7KBskI gTDQsw/B62/I+7y1Ld/lvzGAGQ566PVPkidkRYfMdPTMdi30TviKgFx+E5rruMjsvW1kzg3Wngscr vhtEoeH1BE9rOmovKzSUmSHhq; Received: from 71-211-170-195.hlrn.qwest.net ([71.211.170.195]:51654 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rentt-004JgU-1t for gcc-patches@gcc.gnu.org; Mon, 26 Feb 2024 20:13:01 -0700 From: Tom Tromey Date: Mon, 26 Feb 2024 20:12:56 -0700 Subject: [PATCH 3/3] Fix PR libcc1/113977 MIME-Version: 1.0 Message-Id: <20240226-gdb-compile-align-v1-3-0f95d6435299@tromey.com> References: <20240226-gdb-compile-align-v1-0-0f95d6435299@tromey.com> In-Reply-To: <20240226-gdb-compile-align-v1-0-0f95d6435299@tromey.com> To: gcc-patches@gcc.gnu.org X-Mailer: b4 0.12.4 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 - gcc.gnu.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.170.195 X-Source-L: No X-Exim-ID: 1rentt-004JgU-1t X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-170-195.hlrn.qwest.net ([192.168.0.21]) [71.211.170.195]:51654 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEQjSy2ufZkV7be2wCxrYi4viknXFgNDY7Q6nyJ+C3PAqZPZKYwG0Swxi9UXy8fEXrJbHy0jIj+g0rxUaZy+1k0ugZFRO9n+MDangUb3Fqy5RxvG+5Lj gc9E/tk5YZa6Y/HcyUuozM64EEApecfW/T9V2uo90QhBSNxAIJNFHZ8Q3qRgWxxP4AOBCmhKmSbNOkiJSx1MmHbgGwjjeholZyQ= X-Spam-Status: No, score=-3022.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org PR libcc1/113977 points out a case where a simple expression is rejected with a compiler error message. The bug here is that gdb does not inform the plugin of the correct alignment -- in fact, there is no way to do that. This patch adds a new method to allow the alignment to be set, and bumps the C front end protocol version. It also includes some updates to various comments in 'include', done here to simplify the merge to binutils-gdb. include/ChangeLog 2024-02-26 Tom Tromey * gcc-cp-interface.h (gcc_cp_fe_context_function): Update comment. * gcc-c-interface.h (enum gcc_c_api_version) : New constant. (gcc_c_fe_context_function): Update comment. * gcc-c-fe.def (finish_record_with_alignment): New method. Update documentation. libcc1/ChangeLog 2024-02-26 Tom Tromey PR libcc1/113977 * libcc1plugin.cc (plugin_finish_record_or_union): New function. (plugin_finish_record_or_union): Rewrite. (plugin_init): Use GCC_C_FE_VERSION_2. * libcc1.cc (c_vtable): Use GCC_C_FE_VERSION_2. (gcc_c_fe_context): Check for GCC_C_FE_VERSION_2. --- include/ChangeLog | 10 ++++++++++ include/gcc-c-fe.def | 13 ++++++++++++- include/gcc-c-interface.h | 11 +++++++++-- include/gcc-cp-interface.h | 6 +++++- libcc1/ChangeLog | 9 +++++++++ libcc1/libcc1.cc | 5 +++-- libcc1/libcc1plugin.cc | 26 ++++++++++++++++++-------- 7 files changed, 66 insertions(+), 14 deletions(-) diff --git a/include/ChangeLog b/include/ChangeLog index 8bfaec6faa1..4c8b5b28039 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,13 @@ +2024-02-26 Tom Tromey + + * gcc-cp-interface.h (gcc_cp_fe_context_function): Update + comment. + * gcc-c-interface.h (enum gcc_c_api_version) : + New constant. + (gcc_c_fe_context_function): Update comment. + * gcc-c-fe.def (finish_record_with_alignment): New method. + Update documentation. + 2024-01-13 Jakub Jelinek * demangle.h (enum demangle_component_type): Add diff --git a/include/gcc-c-fe.def b/include/gcc-c-fe.def index 36a765484a7..cb7cf197525 100644 --- a/include/gcc-c-fe.def +++ b/include/gcc-c-fe.def @@ -89,7 +89,10 @@ GCC_METHOD5 (int /* bool */, build_add_field, /* After all the fields have been added to a struct or union, the struct or union type must be "finished". This does some final - cleanups in GCC. */ + cleanups in GCC. + + Note that when using GCC_C_FE_VERSION_2, it is preferable to call + finish_record_with_alignment instead. */ GCC_METHOD2 (int /* bool */, finish_record_or_union, gcc_type, /* Argument RECORD_OR_UNION_TYPE. */ @@ -220,3 +223,11 @@ GCC_METHOD2 (gcc_type, float_type, unsigned long, /* Argument SIZE_IN_BYTES. */ const char *) /* Argument BUILTIN_NAME. */ +/* New in GCC_FE_VERSION_2. Like finish_record_or_union but the caller also + supplies the alignment. If the alignment is 0, this acts identically to + finish_record_or_union. */ + +GCC_METHOD3 (int /* bool */, finish_record_with_alignment, + gcc_type, /* Argument RECORD_OR_UNION_TYPE. */ + unsigned long, /* Argument SIZE_IN_BYTES. */ + unsigned long) /* Argument ALIGNMENT. */ diff --git a/include/gcc-c-interface.h b/include/gcc-c-interface.h index feece1e38a2..700d7483a4a 100644 --- a/include/gcc-c-interface.h +++ b/include/gcc-c-interface.h @@ -45,7 +45,10 @@ enum gcc_c_api_version /* Added char_type. Added new version of int_type and float_type, deprecated int_type_v0 and float_type_v0. */ - GCC_C_FE_VERSION_1 = 1 + GCC_C_FE_VERSION_1 = 1, + + /* Added finish_record_with_alignment method. */ + GCC_C_FE_VERSION_2 = 2, }; /* Qualifiers. */ @@ -198,7 +201,11 @@ struct gcc_c_context /* The type of the initialization function. The caller passes in the desired base version and desired C-specific version. If the request can be satisfied, a compatible gcc_context object will be - returned. Otherwise, the function returns NULL. */ + returned. In particular, this may return a context object with a higher + actual version number than was requested, provided the higher version is + fully compatible. (As of GCC_C_FE_VERSION_2, this is always true.) + + Otherwise, the function returns NULL. */ typedef struct gcc_c_context *gcc_c_fe_context_function (enum gcc_base_api_version, diff --git a/include/gcc-cp-interface.h b/include/gcc-cp-interface.h index 2f950729b9b..15b911cb216 100644 --- a/include/gcc-cp-interface.h +++ b/include/gcc-cp-interface.h @@ -483,7 +483,11 @@ struct gcc_cp_context /* The type of the initialization function. The caller passes in the desired base version and desired C-specific version. If the request can be satisfied, a compatible gcc_context object will be - returned. Otherwise, the function returns NULL. */ + returned. In particular, this may return a context object with a higher + actual version number than was requested, provided the higher version is + fully compatible. + + Otherwise, the function returns NULL. */ typedef struct gcc_cp_context *gcc_cp_fe_context_function (enum gcc_base_api_version, diff --git a/libcc1/ChangeLog b/libcc1/ChangeLog index b4072574ba8..a23130bac15 100644 --- a/libcc1/ChangeLog +++ b/libcc1/ChangeLog @@ -1,3 +1,12 @@ +2024-02-26 Tom Tromey + + PR libcc1/113977 + * libcc1plugin.cc (plugin_finish_record_or_union): New function. + (plugin_finish_record_or_union): Rewrite. + (plugin_init): Use GCC_C_FE_VERSION_2. + * libcc1.cc (c_vtable): Use GCC_C_FE_VERSION_2. + (gcc_c_fe_context): Check for GCC_C_FE_VERSION_2. + 2024-02-26 Tom Tromey * libcp1.cc (libcp1::libcp1): Use FE version number from context. diff --git a/libcc1/libcc1.cc b/libcc1/libcc1.cc index 992181e8fdc..1c570f3054d 100644 --- a/libcc1/libcc1.cc +++ b/libcc1/libcc1.cc @@ -108,7 +108,7 @@ set_callbacks (struct gcc_c_context *s, static const struct gcc_c_fe_vtable c_vtable = { - GCC_C_FE_VERSION_1, + GCC_C_FE_VERSION_2, set_callbacks, #define GCC_METHOD0(R, N) \ @@ -165,7 +165,8 @@ gcc_c_fe_context (enum gcc_base_api_version base_version, enum gcc_c_api_version c_version) { if ((base_version != GCC_FE_VERSION_0 && base_version != GCC_FE_VERSION_1) - || (c_version != GCC_C_FE_VERSION_0 && c_version != GCC_C_FE_VERSION_1)) + || (c_version != GCC_C_FE_VERSION_0 && c_version != GCC_C_FE_VERSION_1 + && c_version != GCC_C_FE_VERSION_2)) return NULL; return new libcc1 (&c_vtable); diff --git a/libcc1/libcc1plugin.cc b/libcc1/libcc1plugin.cc index f1082d8e9d3..72d17c3b81c 100644 --- a/libcc1/libcc1plugin.cc +++ b/libcc1/libcc1plugin.cc @@ -387,9 +387,10 @@ plugin_build_add_field (cc1_plugin::connection *, } int -plugin_finish_record_or_union (cc1_plugin::connection *, - gcc_type record_or_union_type_in, - unsigned long size_in_bytes) +plugin_finish_record_with_alignment (cc1_plugin::connection *, + gcc_type record_or_union_type_in, + unsigned long size_in_bytes, + unsigned long align) { tree record_or_union_type = convert_in (record_or_union_type_in); @@ -407,10 +408,10 @@ plugin_finish_record_or_union (cc1_plugin::connection *, } else { - // FIXME there's no way to get this from DWARF, - // or even, it seems, a particularly good way to deduce it. - SET_TYPE_ALIGN (record_or_union_type, - TYPE_PRECISION (pointer_sized_int_node)); + if (align == 0) + align = TYPE_PRECISION (pointer_sized_int_node); + + SET_TYPE_ALIGN (record_or_union_type, align); TYPE_SIZE (record_or_union_type) = bitsize_int (size_in_bytes * BITS_PER_UNIT); @@ -441,6 +442,15 @@ plugin_finish_record_or_union (cc1_plugin::connection *, return 1; } +int +plugin_finish_record_or_union (cc1_plugin::connection *conn, + gcc_type record_or_union_type_in, + unsigned long size_in_bytes) +{ + return plugin_finish_record_with_alignment (conn, record_or_union_type_in, + size_in_bytes, 0); +} + gcc_type plugin_build_enum_type (cc1_plugin::connection *self, gcc_type underlying_int_type_in) @@ -755,7 +765,7 @@ int plugin_init (struct plugin_name_args *plugin_info, struct plugin_gcc_version *) { - generic_plugin_init (plugin_info, GCC_C_FE_VERSION_1); + generic_plugin_init (plugin_info, GCC_C_FE_VERSION_2); register_callback (plugin_info->base_name, PLUGIN_PRAGMAS, plugin_init_extra_pragmas, NULL);