Bug 9496 - GDB does not understand pointer of STL class
Summary: GDB does not understand pointer of STL class
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.6
: P3 normal
Target Milestone: 7.2
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-23 03:58 UTC by vicshen
Modified: 2010-02-19 20:23 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description vicshen 2007-12-23 03:58:01 UTC
[Converted from Gnats 2391]

----- stl.cpp -----
#include <list>

int main()
{
  std::list<int> l;
  l.push_back(1);
}
----- stl.cpp -----

(gdb) b main
Breakpoint 1 at 0x80497b1: file stl.cpp, line 5.
(gdb) run
Breakpoint 1, main () at stl.cpp:5
5         std::list<int> l;
(gdb) whatis int
type = int
(gdb) whatis int*
type = int *
(gdb) whatis std::list<int,std::allocator<int> >
type = std::list<int, std::allocator<int> >
(gdb) whatis std::list<int,std::allocator<int> > *
A syntax error in expression, near `'.
(gdb) whatis 'std::list<int,std::allocator<int> > *'
No symbol "std::list<int,std::allocator<int> > *" in current context.

GDB can understand pointer to int, but there's no way to understand a pointer to std::list.

From Daniel:
  This looks like a bug in GDB, in the c-exp.y parser.

Release:
GNU gdb 6.6, gcc version 3.3.6

Environment:
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux".
Comment 1 apoenitz 2008-08-06 15:07:06 UTC
From: =?iso-8859-1?q?Andr=E9_P=F6nitz?= <apoenitz@trolltech.com>
To: gdb-gnats@sources.redhat.com,
 vicshen@gmail.com,
 gdb-prs@sources.redhat.com
Cc:  
Subject: Re: c++/2391: GDB does not understand pointer of STL class
Date: Wed, 6 Aug 2008 17:07:06 +0200

 http://sourceware.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audit-trail&database=
 =3Dgdb&pr=3D2391
 
 It "works" with
 
  whatis 'std::list<int,std::allocator<int> >'*
 
 i.e. quote everything but the star. Don't ask me why.
 And it's hard to automize...
 
 Andr=E9
Comment 2 Sourceware Commits 2010-02-19 20:22:17 UTC
Subject: Bug 9496

CVSROOT:	/cvs/src
Module name:	src
Changes by:	tromey@sourceware.org	2010-02-19 20:22:03

Modified files:
	gdb            : ChangeLog c-exp.y cp-namespace.c 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.cp: namespace.exp 

Log message:
	gdb
	PR c++/8693, PR c++/9496:
	* cp-namespace.c (cp_lookup_nested_type): Handle TYPE_CODE_UNION.
	* c-exp.y (lex_one_token): Rename from yylex.  Don't call
	write_dollar_variable.  Don't try to classify NAME tokens.
	(token_and_value): New type.
	(token_fifo, popping, name_obstack): New globals.
	(classify_name): New function.
	(classify_inner_name): Likewise.
	(yylex): Likewise.
	(VARIABLE): Now has type sval.
	(exp : VARIABLE): Call write_dollar_variable.
	(qualified_name): Use TYPENAME, not typebase.  Add production for
	multiple "::" instances.
	(variable): Use name_not_typename.
	(qualified_type): Remove.
	(typebase): Update.
	gdb/testsuite
	PR c++/8693, PR c++/9496:
	* gdb.cp/namespace.exp: Remove some setup_kfail calls.  Added
	regression tests.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11381&r2=1.11382
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/c-exp.y.diff?cvsroot=src&r1=1.70&r2=1.71
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/cp-namespace.c.diff?cvsroot=src&r1=1.34&r2=1.35
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2149&r2=1.2150
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.cp/namespace.exp.diff?cvsroot=src&r1=1.16&r2=1.17

Comment 3 Tom Tromey 2010-02-19 20:23:33 UTC
I checked in the fix.