I don’t have much LLDB experience, but I’m trying to finally get it working in a visual debugger (VS Code at the moment). It seems like I should be able to look at a C++ string without much trouble. But…
(lldb) p name
(const std::string) $5 = Summary Unavailable
(lldb) po name
Summary Unavailable
(lldb) p *name.c_str()
(const std::basic_string<char, std::char_traits<char>, std::allocator<char> >::value_type) $14 = '+'
Is there something wrong with my setup? Should those first two print something nice? (The actually string is just "+" in this case.) I do have a custom built libc++, so the full namespace looks like: std::__myname::basic_string. I don’t know if that’s a problem.
Typing p foo.c_str() isn’t horrible, but in VS Code and I notice all strings in the “Variables” panel say “Summary Unavailable” and have a tree of gobblygook implementation details under them. I’d like it show the string’s value, of course.
My namespace does match that regex I see there in the code: "^std::__[[:alnum:]]+::string$", so maybe I’ll try to build an LLDB like I’ve built LLVM, Clang, and libc++, and see if that helps. I’m currently using the one that came from Apple with Xcode.
These builds take forever on my poor MacBook Pro, so it’s hard to experiment and try things out. Maybe I can set up something on an AWS instance, so I can rebuild these things without tying up my laptop for 1-3 hours.
We changed how the data is represented in source a couple of months ago, which broke the LLDB formatter. That might be the reason your Xcode LLDB doesn’t recognize the string.
Updating to the latest version of Xcode Command Line Tools solved the issue for me. (Specifically short strings not being formatted and shown as “Summary Unavailable” in lldb and in the VSCode debugger.)
softwareupdate --install "Command Line Tools for Xcode-15.0"