| Issue |
60994
|
| Summary |
lldb cannot print std::string
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
fonqL
|
OS: Ubuntu 22.04
```shell
$ clang -v
Ubuntu clang version 15.0.6
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ lldb --version
lldb version 15.0.6
```
main.cpp
```cpp
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char **argv) {
int a = 0;
std::string s = "1234555";
std::vector<int> c{1, 2, 3, 4, 5};
s[0] = '9';
std::cout << s;
}
```
Compile:
```shell
$ g++ -g -O0 main.cpp -o gcc_out
$ clang++ -g -O0 main.cpp -o clang_out
```
**lldb can print std::string when using gcc_out, but shows error when using clang_out.**
```
(lldb) print s
error: _expression_ failed to parse:
error: <user _expression_ 0>:1:1: incomplete type 'std::string' (aka 'std::basic_string<>') where a complete type is required
s
^
```
When using Codelldb to debug in VScode, it shows `error: summary string parsing error`
I know a workaround is to add `-fstandalone-debug` flag, but that's a bit annoying.
Another solution is install a debug version of libstdc++. I think I have already installed it.
I wonder if there is another way to solve it.
```shell
$ dpkg --list|grep libstdc++
ii libstdc++-11-dev:amd64 11.3.0-1ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (development files)
ii libstdc++-12-dev:amd64 12.1.0-2ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (development files)
ii libstdc++-12-doc 12.1.0-2ubuntu1~22.04 all GNU Standard C++ Library v3 (documentation files)
ii libstdc++6:amd64 12.1.0-2ubuntu1~22.04 amd64 GNU Standard C++ Library v3
ii libstdc++6-12-dbg:amd64 12.1.0-2ubuntu1~22.04 amd64 GNU Standard C++ Library v3 (debug build)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs