How can I get sensible variable displays when using libc++ in Xcode 4.3.1?

狂风中的少年 提交于 2019-12-10 14:07:06

问题


I'm using Xcode 4.3.1's C++11 language dialect along with libc++ as the standard library. The language support in this combination is amazing, but debugging is torture. Neither Xcode's "Summary Format" nor lldb's summary format features display any of the standard types (std::string, std::vector, etc.) with pretty printing. Writing a pretty printer for these types is highly non-trivial due to their complexity. (E.g., std::string is remarkably complex in libc++.)

How in the world are other developers getting decent variable displays for STL types in this situation? Or is no one else using libc++ with Xcode/lldb yet?


回答1:


W ell there is support in the lldb repository. This is what I did:

svn co http://llvm.org/svn/llvm-project/lldb/trunk lldb

(I got revision 160855) In the lldb shell of Xcode you can than do:

command script import  /Users/arne/oss/lldb/examples/synthetic/libcxx.py

After that lldb formats std::vector, std::map, std::string and std::map more nicely:

(lldb) p rv
(std::__1::vector<unsigned long, std::__1::allocator<unsigned long> >) $3 = size=2 {
  (unsigned long) [0] = 503
  (unsigned long) [1] = 503
}

I have tested this with Xcode 4.4. Should work similar with Xcode 4.3

You can put the command in your .lldbinit init file. Even Xcode will then display the structures nicely formatted.




回答2:


This feature works correctly in Xcode 4.4. The best solution for Xcode 4.3 users is simply to update Xcode.



来源:https://stackoverflow.com/questions/10214477/how-can-i-get-sensible-variable-displays-when-using-libc-in-xcode-4-3-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!