2012-10-22 91 views
5

我的機器上安裝了GDB 7.5。這似乎是相當的打印機的STL已經捆綁了這個版本,因爲跑:漂亮的印刷STL與GDB和Clang

(gdb) info pretty-printers 

打印所有可用的STL打印機的一個長長的清單。

調試用g ++編譯的C++代碼會獲得正確的漂亮打印行爲。但是,如果使用clang ++編譯相同的代碼,則不會發生同樣的情況。

下面是一個輸出,當我run GDB:

BFD: /usr/lib/libstdc++.6.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/libstdc++.6.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/libSystem.B.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/libSystem.B.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/libc++abi.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/libc++abi.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libcache.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libcache.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libcommonCrypto.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libcommonCrypto.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libcompiler_rt.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libcompiler_rt.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libcopyfile.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libcopyfile.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libdispatch.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libdispatch.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libdnsinfo.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libdnsinfo.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libdyld.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libdyld.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libkeymgr.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libkeymgr.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/liblaunch.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/liblaunch.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libmacho.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libmacho.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libquarantine.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libquarantine.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libremovefile.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libremovefile.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_blocks.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_blocks.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_c.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_c.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_dnssd.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_dnssd.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_info.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_info.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_kernel.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_kernel.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_m.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_m.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_network.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_network.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_notify.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_notify.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libsystem_sandbox.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libsystem_sandbox.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libunc.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libunc.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libunwind.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libunwind.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libxpc.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libxpc.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/system/libcorecrypto.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/system/libcorecrypto.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/libobjc.A.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/libobjc.A.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/libauto.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/libauto.dylib(i386:x86-64): unknown load command 0x2b 
BFD: /usr/lib/libc++.1.dylib(i386:x86-64): unknown load command 0x2a 
BFD: /usr/lib/libc++.1.dylib(i386:x86-64): unknown load command 0x2b 

我想知道我怎樣才能STL容器適合打印時的代碼是鏗鏘++編譯? 請注意,我可以調試應用程序;我無法漂亮地打印STL內容。

回答

4

您正在使用的gdb有一個已知Mach-O加載命令編號的列表,但在Mac OS X 10.8中添加了兩個新的命令(LC_SOURCE_VERSION,0x2a和LC_DYLIB_CODE_SIGN_DRS,0x2b),它抱怨它沒有了解這些。它不需要了解這些,這些加載命令中的調試器沒有必要。警告應該是無害的。

使用Apple提供的gdb(我不知道是否支持python)或者使用Apple支持的新調試器LLDB,您會好得多。 lldb是一個非常令人興奮的新調試器,它正在迅速改進,Apple在過去的幾年裏一直從頭開始開發它(儘可能利用llvm現有的基礎架構和功能),而且今天它非常有能力。它的設計從一開始就可以通過Python進行擴展,並且很容易爲您可能遇到的容器類型創建新的數據格式化程序。

如果你還沒有使用LLDB過,但熟悉GDB,一個有用的小抄是命令等價頁上的http://lldb.llvm.org/lldb-gdb.html

給LLDB一試。這是未來在Mac OS X上支持的調試 - 今天有很多需要調試的地方,每個版本都會變得更好。它也是開源的,你可以從http://lldb.llvm.org/中檢查出來並自己玩。