This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug python/12520] New: cannot parse function types as templateparameters


http://sourceware.org/bugzilla/show_bug.cgi?id=12520

           Summary: cannot parse function types as template parameters
           Product: gdb
           Version: 7.2
            Status: NEW
          Severity: normal
          Priority: P2
         Component: python
        AssignedTo: unassigned@sourceware.org
        ReportedBy: zilla@kayari.org


$ cat gdb.cc
#include <map>
#include <string>

template<typename Callable> struct function { };

int main()
{
    typedef function<int(std::string)> func_type;

    std::map<int, func_type> m;

    return 0;
}
$ $GCC46/bin/g++ -Wl,-rpath,$GCC46/lib64 -g gdb.cc
$ gdb ./a.out
GNU gdb (GDB) 7.2
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /dev/shm/wakelj/b/a.out...done.
(gdb) br main
Breakpoint 1 at 0x40064d: file gdb.cc, line 10.
(gdb) r
Starting program: /dev/shm/wakelj/b/a.out

Breakpoint 1, main () at gdb.cc:10
10          std::map<int, func_type> m;
(gdb)
(gdb) p m
$1 = std::map with 0 elementsTraceback (most recent call last):
  File
"/home/wakelj/tools/Linux-x86_64/test/share/gcc-4.6.0/python/libstdcxx/v6/printers.py",
line 409, in children
    keytype = self.val.type.template_argument(0).const()
RuntimeError: syntax error, near `)>, std::less<int>, std::allocator<st'


The full type is:

std::map<int, function<int(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >)>, std::less<int>, std::allocator<std::pair<const int,
function<int(std::basic_string<char, std::char_traits<char>,
std::allocator<char> >)> > > >

GDB seems to get confused at the ')' in the template parameters.

This means the libstdc++ pretty-printers cannot display a std::function or
boost::function object.


A simpler form using a pointer-to-function instead of function<R()> also fails
in the pretty printer, on the next line:

$ cat gdb.cc
#include <map>
#include <string>

template<typename Callable> struct function { };

int main()
{
    typedef int(*func_type)();

    std::map<int, func_type> m;

    return 0;
}
$ $GCC46/bin/g++ -Wl,-rpath,$GCC46/lib64 -g gdb.cc
$ gdb -quiet ./a.out
Reading symbols from /dev/shm/wakelj/b/a.out...done.
(gdb) br main
Breakpoint 1 at 0x40064d: file gdb.cc, line 10.
(gdb) r
Starting program: /dev/shm/wakelj/b/a.out

Breakpoint 1, main () at gdb.cc:10
10          std::map<int, func_type> m;
(gdb) n
12          return 0;
(gdb) p m
$1 = std::map with 0 elementsTraceback (most recent call last):
  File
"/home/wakelj/tools/Linux-x86_64/test/share/gcc-4.6.0/python/libstdcxx/v6/printers.py",
line 410, in children
    valuetype = self.val.type.template_argument(1)
RuntimeError: No type named int ()().

The correct type is 'int ()' not 'int ()()'

Is this second problem related to http://gcc.gnu.org/PR46332 ? Do I need a
newer binutils, or is the demangling code included in gdb?

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]