gpt4 book ai didi

c++ - 无法检查 lldb 中的 std::string 变量

转载 作者:行者123 更新时间:2023-12-03 06:54:01 32 4
gpt4 key购买 nike

当我尝试使用 LLDB 检查 std::string 变量时,出现“错误:摘要字符串解析错误”。

#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++ ,但我假设您使用 clang++ 编译如果您使用的是 lldb。

关于c++ - 无法检查 lldb 中的 std::string 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58578615/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com