Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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
like image 960
mukkumayc Avatar asked Jan 26 '23 16:01

mukkumayc


1 Answers

Try recompiling your source code with the -fstandalone-debug flag. I had this same problem when I was using lldb today and when I tried accessing the string character-by-character it threw an error that recommended compiling with this flag. After I had recompiled my binary files lldb handled strings just fine.

Note: I'm unsure if this flag works with g++, but I'm assuming that you compile with clang++ if you're using lldb.

like image 122
Nolan Faught Avatar answered Jan 31 '23 02:01

Nolan Faught