c++clanglldbclang++

Cannot inspect a std::string variable in lldb


When I try to inspect std::string variable using LLDB, I get "error: summary string parsing error".

#include <iostream>
#include <string>

int main() {
    std::string a{"123"};
    std::cout << a << std::endl;
    return 0;
}
Process 4492 stopped
* thread #1, name = 'main', stop reason = breakpoint 1.1
    frame #0: 0x00005555555551e9 main`main at main.cpp:6:1
   3    
   4    int main() {
   5        std::string a{"123"};
-> 6        std::cout << a << std::endl;
   7        return 0;
   8    }
(lldb) v a
(std::string) a = error: summary string parsing error

Additional information:

$ clang++ --version
clang version 8.0.1 (tags/RELEASE_801/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ lldb --version
lldb version 8.0.1
uname -s -r -m -o
Linux 5.3.5-arch1-1-ARCH x86_64 GNU/Linux

Solution

  • Recompile your source code with the -fstandalone-debug flag. This option disables optimizations that (may) prevent clang from emitting type definitions, preventing lldb from accessing the underlying structure of your environment's std::string implementation.