From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18592 invoked by alias); 13 Feb 2018 15:52:29 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 18300 invoked by uid 89); 13 Feb 2018 15:52:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*i:sk:1518536, H*f:sk:1518536 X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Feb 2018 15:52:27 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w1DFqKUH025138 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 13 Feb 2018 10:52:25 -0500 Received: by simark.ca (Postfix, from userid 112) id B92E21E767; Tue, 13 Feb 2018 10:52:20 -0500 (EST) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 98AD51E4F4; Tue, 13 Feb 2018 10:52:18 -0500 (EST) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 13 Feb 2018 15:52:00 -0000 From: Simon Marchi To: psmith@gnu.org Cc: gdb@sourceware.org Subject: Re: GDB syntax error if class members overlap C++ header file names In-Reply-To: <1518536232.1130.9.camel@gnu.org> References: <1518536232.1130.9.camel@gnu.org> Message-ID: X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.4 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Tue, 13 Feb 2018 15:52:20 +0000 X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00092.txt.bz2 On 2018-02-13 10:37, Paul Smith wrote: > Has anyone had any thoughts about > https://sourceware.org/bugzilla/show_bug.cgi?id=22231 > > This is a really unfortunate bug, because there are so many useful > symbol names which are also C++ header files! Just ran into this again > with "queue". > > Quoted from the bug: > >> I've discovered that if you compile a C++ program with -ggdb3 (not >> -g) then any C++ header file (sans .h extension) that is included >> will cause a syntax error whenever you try to print that name. Also, >> if you try to print a class member with that name it will also fail. >> >> I've tried this with GDB 7.7, 7.11, and 8.0 and all behave the same >> way. I've used both GCC 6.2 and 6.3. > > And I've tried 8.1 as well just to be sure; same behavior: > >> (gdb) p memory >> A syntax error in expression, near `'. >> >> This will be the same for any other C++ (without .h) header that is >> included. If you change to #include then you won't get >> this error (you'll get 'No symbole "memory" in current context.' as >> expected). >> >> If you create a local variable or an auto variable named "memory", >> GDB will print it properly. >> >> However, if you have a class member named "memory", GDB again won't >> parse it; > >> (gdb) p foo.memory >> A syntax error in expression, near `'. >> >> >> >> If you enable debugging you'll see: >> >> (gdb) set debug parser on >> (gdb) p memory >> Starting parse >> Entering state 0 >> Reading a token: Next token is token FILENAME (bval<0x1a66ac0>) >> Shifting token FILENAME (bval<0x1a66ac0>) >> Entering state 47 >> Reducing stack by rule 107 (line 877): >> $1 = token FILENAME (bval<0x1a66ac0>) >> -> $$ = nterm block () >> Stack now 0 >> Entering state 57 >> Reading a token: Now at end of input. >> A syntax error in expression, near `'. Hi Paul, This looks like an issue that has been fixed recently, but it's not in 8.1, only master. https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commit;h=59498c305e6f1db2a1ed8d44cb58f0d24ec092fe Can you verify if it works for you? Simon