public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* pretty printer failed on gdb 7.3.1 compiled with gcc 4.6.2 (built from source) on Mac OS X Snow Leopard
@ 2011-11-16 23:43 sunggam
  0 siblings, 0 replies; only message in thread
From: sunggam @ 2011-11-16 23:43 UTC (permalink / raw)
  To: gdb

I am trying to compile gdb 7.3.1 with pretty printer on Mac OS X (Snow
Leopard). I first compiled gcc 4.6.2 and used gcc 4.6.2 to compile gdb
7.3.1.

However, the compiled gdb 7.3.1 cannot use pretty printers in the
binaries compiled from gcc 4.6.2. These warnings are displayed in gdb:
warning: can't find section '.const' in OSO file /Users/XXX/mybuild/gcc/gcc-4.
6.2/build/x86_64-apple-darwin10.8.0/libstdc++-v3/src/.libs/bitmap_allocator.o
warning: can't find section '.const_data' in OSO file
/Users/XXX/mybuild/gcc/gcc-4.6.2/build/x86_64-apple-darwin10.8.0/libstdc++-v3/src/.libs/bitmap_allocator.o
warning: can't find section '.data' in OSO file
/Users/XXX/mybuild/gcc/gcc-4.6.2/build/x86_64-apple-darwin10.8.0/libstdc++-v3/src/.libs/mt_allocator.o

But it can use pretty printers on some STL classes in the binaries
from gcc-4.2, shipped with XCode 3.2.6. No warnings are displayed.

Has anyone met similar problems? Some details are listed in the following:


# the sample .cc file: welcome.cc

$ cat welcome.cc
#include <iostream>
#include <vector>
#include <string>

int main(int argc, char**argv) {

    std::string s("abcd");
    std::vector<int> a(5,3);
    std::cout << s << std::endl;
    return 0;
}

$ ~/local/bin/bin/c++-4.6.2 -g welcome.cc -o welcome
$ ~/local/bin/bin/gdb-7.3.1 welcome
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 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-apple-darwin10.8.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/XXX/welcome...Reading symbols from
/Users/XXX/welcome.dSYM/Contents/Resources/DWARF/welcome...done.
done.
(gdb) br 10
Breakpoint 1 at 0x100000f9e: file welcome.cc, line 10.
(gdb) run
Starting program: /Users/XXX/welcome
warning: can't find section '.const' in OSO file
/Users/XXX/mybuild/gcc/gcc-4.6.2/build/x86_64-apple-darwin10.8.0/libstdc++-v3/src/.libs/bitmap_allocator.o
warning: can't find section '.const_data' in OSO file
/Users/XXX/mybuild/gcc/gcc-4.6.2/build/x86_64-apple-darwin10.8.0/libstdc++-v3/src/.libs/bitmap_allocator.o
warning: can't find section '.data' in OSO file
/Users/XXX/mybuild/gcc/gcc-4.6.2/build/x86_64-apple-darwin10.8.0/libstdc++-v3/src/.libs/mt_allocator.o
abcd

Breakpoint 1, main (argc=1, argv=0x7fff5fbff768) at welcome.cc:10
10        return 0;
(gdb) p s
$1 = {static npos = <optimized out>, _M_dataplus = {<allocator<char>>
= {<new_allocator<char>> = {<No data fields>}, <No data fields>},
    _M_p = 0x100200098 "abcd"}}
(gdb) p a
$2 = {<_Vector_base<int, std::allocator<int> >> = {_M_impl =
{<allocator<int>> = {<new_allocator<int>> = {<No data fields>}, <No
data fields>},
      _M_start = 0x1002000a0, _M_finish = 0x1002000b4,
_M_end_of_storage = 0x1002000b4}}, <No data fields>}



However, if I use the gcc-4.2 shipped with Xcode 3.2.6 to compile the
sample test code, it can parse std::vector, but not std::string. I
guess it is because std::string has been changed from since gcc-4.2.

$ /usr/bin/c++-4.2 -g welcome.cc -o welcome2
$ ~/local/bin/bin/gdb-7.3.1 welcome2
GNU gdb (GDB) 7.3.1
Copyright (C) 2011 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-apple-darwin10.8.0".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /Users/XXX/welcome2...Reading symbols from
/Users/XXX/welcome2.dSYM/Contents/Resources/DWARF/welcome2...done.
done.
(gdb) br 10
Breakpoint 1 at 0x10000100b: file welcome.cc, line 10.
(gdb) run
Starting program: /Users/XXX/welcome2
abcd

Breakpoint 1, main (argc=1, argv=0x7fff5fbff760) at welcome.cc:10
10        return 0;
(gdb) p a
$1 = std::vector of length 5, capacity 5 = {3, 3, 3, 3, 3}
(gdb) p s
$2 = Traceback (most recent call last):
  File "/Users/XXX/local/bin/gdb_printers/python/libstdcxx/v6/printers.py",
line 590, in to_string
    reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer ()
RuntimeError: No type named std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_Rep.


(gdb)


Here is the Mac OS X version:

$ uname -a
Darwin delaware 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun  7
16:32:41 PDT 2011; root:xnu-1504.15.3~1/RELEASE_X86_64 x86_64

Thanks

-Gang

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-11-16 23:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-16 23:43 pretty printer failed on gdb 7.3.1 compiled with gcc 4.6.2 (built from source) on Mac OS X Snow Leopard sunggam

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).