无法检查 lldb 中的 std::string 变量
Cannot inspect a std::string variable in lldb
当我尝试使用 LLDB 检查 std::string 变量时,我得到 "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
附加信息:
$ 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
尝试使用 -fstandalone-debug
标志重新编译您的源代码。我今天使用 lldb 时遇到了同样的问题,当我尝试逐个字符访问字符串时,它抛出了一个错误,建议使用此标志进行编译。在我重新编译我的二进制文件后,lldb 可以很好地处理字符串。
注意:我不确定此标志是否适用于 g++
,但我假设如果您使用的是 lldb,则使用 clang++
进行编译。
当我尝试使用 LLDB 检查 std::string 变量时,我得到 "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
附加信息:
$ 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
尝试使用 -fstandalone-debug
标志重新编译您的源代码。我今天使用 lldb 时遇到了同样的问题,当我尝试逐个字符访问字符串时,它抛出了一个错误,建议使用此标志进行编译。在我重新编译我的二进制文件后,lldb 可以很好地处理字符串。
注意:我不确定此标志是否适用于 g++
,但我假设如果您使用的是 lldb,则使用 clang++
进行编译。