Macos 使用gcc-4.8和mac os 10.9的GDB 7.6 STL漂亮打印

Macos 使用gcc-4.8和mac os 10.9的GDB 7.6 STL漂亮打印,macos,gcc,stl,gdb,pretty-print,Macos,Gcc,Stl,Gdb,Pretty Print,我正努力在我的mac电脑上获得gdb中描述的漂亮打印。我通过macports下载了最新的gdb,并使用了gcc-4.8。 我加载了~/.gdbinit文件并注册了打印机,但每当我调用 print myVector它提供原始输出。 有什么建议我可以做吗?谢谢大家 如果您在libc++中使用STL实现(默认为clang),GDB将不知道如何漂亮地打印STL容器 切换到使用GNUlibstdc++,在gdb中进行STL漂亮打印应该可以工作 STL pretty打印机作为Python程序实现,了解ST

我正努力在我的mac电脑上获得gdb中描述的漂亮打印。我通过macports下载了最新的gdb,并使用了
gcc-4.8
。 我加载了
~/.gdbinit
文件并注册了打印机,但每当我调用
print myVector
它提供原始输出。 有什么建议我可以做吗?谢谢大家

  • 如果您在
    libc++
    中使用STL实现(默认为
    clang
    ),GDB将不知道如何漂亮地打印STL容器
  • 切换到使用GNU
    libstdc++
    ,在
    gdb
    中进行STL漂亮打印应该可以工作
  • STL pretty打印机作为Python程序实现,了解STL容器的实现细节,并与STL实现一起维护
  • libc++
    不提供确认为
由于您从MacPorts获得了
gcc-4.8
,并声称
gcc-*
默认值为
libstdc++
,因此在使用gcc时应避免传递
-stdlib=
选项

有什么建议我可以做吗

您可以尝试直接从gdb命令行注册漂亮的打印机,绕过
.gdbinit
文件以缩小问题范围:

ks@ks-comp:~$ gdb -n
GNU gdb (GDB) 7.6.1-ubuntu
Copyright (C) 2013 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-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) python
>import sys
>sys.path.insert(0, '/home/ks/stlPrettyPrinter')
>from libstdcxx.v6.printers import register_libstdcxx_printers
>register_libstdcxx_printers (None)
>end
(gdb) 

要使pretty printer具有libc++(Clang++/LLVM中使用的新库),请使用此新的pretty printer:

.gdbinit几乎是一样的()


我刚刚在OS X 10.10上试用了Eclipse Luna,效果很好。

谢谢,它可以与clang++和passing-stdlib=libstdc++一起使用!但是你有机会知道如何通过g++-4.8吗?它不识别标志-stdlib=libstdc++。我通常通过-std=c++11来获得c++11功能。@user3428018,您的
gcc-4.8
也通过macports获得了吗?是的,我得到了,我必须使用它,因为openmp支持谢谢您的建议!尝试了它,我没有收到任何抱怨,但仍然得到以下输出:
(gdb)pv$1={={{={={},},{M_start=0x1004000a0,{M_finish=0x1004000f0,{M_end_of_storage=0x1004000f0},}
。我用g++-4.8-g-std=c++11 main.cpp编译代码。我刚接触gdb,真的不知道如何解决这个问题:/我试着在我的mac os x 10.10.3上运行,GNU gdb(gdb)7.9.1,g++--版本配置为--prefix=/Applications/Xcode.app/Contents/Developer/usr--gxx include dir=/usr/include/c++/4.2.1苹果LLVM版本6.1.0(clang-602.0.53)(基于LLVM 3.6.0svn)目标:x86_64-apple-darwin14.3.0线程模型:posix clang——版本苹果LLVM版本6.1.0(clang-602.0.53)(基于LLVM 3.6.0svn)目标:x86_64-apple-darwin14.3.0try@Marco回答:成功!
ks@ks-comp:~$ ls -a /home/ks/stlPrettyPrinter
.  ..  hook.in  index.html  libstdcxx  Makefile.am  Makefile.in  patch.txt  .svn
ks@ks-comp:~$