From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 76564 invoked by alias); 13 Feb 2018 15:37:20 -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 76553 invoked by uid 89); 13 Feb 2018 15:37:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: eggs.gnu.org Received: from eggs.gnu.org (HELO eggs.gnu.org) (208.118.235.92) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 13 Feb 2018 15:37:18 +0000 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1elcdt-0001gz-8B for gdb@sourceware.org; Tue, 13 Feb 2018 10:37:17 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:45090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1elcdt-0001gr-2T for gdb@sourceware.org; Tue, 13 Feb 2018 10:37:13 -0500 Received: from [50.226.24.42] (port=48344 helo=pdsdesk) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1elcds-0002P2-QS for gdb@sourceware.org; Tue, 13 Feb 2018 10:37:12 -0500 Message-ID: <1518536232.1130.9.camel@gnu.org> Subject: GDB syntax error if class members overlap C++ header file names From: Paul Smith Reply-To: psmith@gnu.org To: gdb@sourceware.org Date: Tue, 13 Feb 2018 15:37:00 -0000 Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg00091.txt.bz2 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 `'.