From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gHIVAmzvXWAHRQAAWB0awg (envelope-from ) for ; Fri, 26 Mar 2021 10:27:56 -0400 Received: by simark.ca (Postfix, from userid 112) id 06FCC1EF7C; Fri, 26 Mar 2021 10:27:56 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham 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 508151E789 for ; Fri, 26 Mar 2021 10:27:55 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8A40D38618AA; Fri, 26 Mar 2021 14:27:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A40D38618AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616768874; bh=wrXAnTUXOLpNc1eY1FFFsklQo3LQ3sdLXLZ7aDKg3sU=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=ZRpG1QB/63cFXULZNWYDMxarNvzYG/wHZhBhNW6FPFKTn9fvm+z2K54CYbm+ibLFc 1MKgBKY+gLt2iLGhdgeTbKAWt1VaHrWtyFM2jE7OpH/psX/clZfkrSnh5bhIh1zjXU 1Upm/CuR644bhrejmZAsXwAa1iTakg9M8Df9d4Cs= Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by sourceware.org (Postfix) with ESMTPS id B50813860C3F for ; Fri, 26 Mar 2021 14:27:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B50813860C3F IronPort-SDR: DA3bvHLsOdEk1csQ9I69UUrra1URTOyB6fssy3N7Vfng8cOsSg9AwZi6AxLy+BXkmo6I3s/GKX t8Wc0rXSkBPg== X-IronPort-AV: E=McAfee;i="6000,8403,9935"; a="171146838" X-IronPort-AV: E=Sophos;i="5.81,280,1610438400"; d="scan'208";a="171146838" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2021 07:27:50 -0700 IronPort-SDR: nyTeUlHabFsiCidMDoscVi1CcI/z/vBdsYUzc7/oKAgdA449hayOQhpd4Wj1fWaJovHEQDH6Q9 C0S185fYhTJQ== X-IronPort-AV: E=Sophos;i="5.81,280,1610438400"; d="scan'208";a="409919219" Received: from mulvlfelix.iul.intel.com (HELO localhost) ([172.28.48.31]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Mar 2021 07:27:49 -0700 To: gdb-patches@sourceware.org, felix.willgerodt@intel.com Subject: [PATCH 2/2] gdb: Fix reduce/reduce conflicts for qualifier_seq_noopt in the C parser. Date: Fri, 26 Mar 2021 15:26:09 +0100 Message-Id: <20210326142609.245016-3-felix.willgerodt@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20210326142609.245016-1-felix.willgerodt@intel.com> References: <20210326142609.245016-1-felix.willgerodt@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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: , From: Felix Willgerodt via Gdb-patches Reply-To: Felix Willgerodt Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" This fixes a problem with GDB's address space qualifier parsing. GDB uses '@' as a way to express an address space in expression evaluation. This can currently lead to a crash for "Add support for the __flash qualifier on AVR" (487d975399dfcb2bb2f0998a7d12bd62acdd9fa1), the only user I am aware of. Program: ~~~ const __flash char data_in_flash = 0xab; int main (void) { const __flash char *pointer_to_flash = &data_in_flash; } ~~~ Before: ~~~ (gdb) p data_in_flash $1 = -85 '\253' (gdb) p *(const char * @flash) pointer_to_flash $2 = -85 '\253' (gdb) p *(@flash const char *) pointer_to_flash type-stack.c:201: internal-error: type* type_stack::follow_types(type*): unrecognized tp_ value in follow_types A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) ~~~ After: ~~~ (gdb) p data_in_flash $1 = -85 '\253' (gdb) p *(const char *) pointer_to_flash $2 = 0 '\000' (gdb) p *(const char * @flash) pointer_to_flash $3 = -85 '\253' (gdb) p *(@flash const char *) pointer_to_flash $4 = 0 '\000' (gdb) ~~~ Note that how the binding of this qualifier is interpreted and resolved for an address/pointer is target specific. Hence only the prepended qualifier works for AVR, even if it seems syntactically incorrect. I won't change this for AVR, as I am not familiar with that target. Bison now also complains about less conflicts: Before: YACC c-exp.c gdb/gdb/c-exp.y: warning: 153 shift/reduce conflicts [-Wconflicts-sr] gdb/gdb/c-exp.y: warning: 70 reduce/reduce conflicts [-Wconflicts-rr] After: YACC c-exp.c gdb/gdb/c-exp.y: warning: 60 shift/reduce conflicts [-Wconflicts-sr] gdb/gdb/c-exp.y: warning: 69 reduce/reduce conflicts [-Wconflicts-rr] gdb/ChangeLog: 2021-03-22 Felix Willgerodt * c-exp.y (qualifier_seq_noopt): Replace qualifier_seq with qualifier_seq_noopt. --- gdb/c-exp.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index e2ceb2057a1..256937f2034 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1275,7 +1275,7 @@ single_qualifier: qualifier_seq_noopt: single_qualifier - | qualifier_seq single_qualifier + | qualifier_seq_noopt single_qualifier ; qualifier_seq: -- 2.25.4 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928