Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 332
OldPeculier Avatar asked Oct 09 '22 01:10

OldPeculier


1 Answers

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.

like image 188
plaisthos Avatar answered Oct 13 '22 11:10

plaisthos