LLDB 在编译时无法调试字符串
lldb can't debug string when compiled by clang++
这是测试代码。
#include <string>
int main(int argc, char const *argv[]) {
std::string a = "hello";
std::string b = "world";
return 0;
}
我用命令编译它:
clang++ test.cpp -g
然后我试着调试它:
lldb a.out
我在a = "hello"
运行后的第4行添加断点。我尝试通过p a
打印a
,它显示了以下错误:
error: incomplete type 'string' (aka 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >') where a complete type is requ
ired
note: forward declaration of 'std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >'
error: 1 errors parsing expression
我想不出来。
虽然当我尝试用g++编译时,它是OK的
这是因为clang没有为std::string
发出调试信息。确保安装了libstdc++的调试信息。有关更多信息,请参阅此无效错误:
好像没有安装libstdc++的调试信息:
缺少单独的debuginfo,请使用:dnf debuginfo-install libgcc-5.1.1-4.fc22。x86_64 libstdc + + 5.1.1-4.fc22.x86_64
Clang没有为std::string发出调试信息,因为它是被告知libstdc++提供了它(但在您的情况下,它不是)安装);这显然是一个调试大小的优化,GCC不执行。
相关文章:
- 小字符串优化(调试与发布模式)
- 在qt创建器中调试时如何访问字符串变量的完整值?
- C++:用于调试的类的字符串表示形式
- 字符串抛出矢量下标调试断言
- 如何在我的C++程序中调试字符串处理
- 调试宏中的字符串变量扩展
- 如何在Eclipse调试器中更改C++字符串值
- C++ 显示字符串变量"<不完整类型>的调试窗口
- 需要帮助调试我的代码,以逆转字符串中的单词
- 调试断言失败 字符串下标超出范围
- 使用子字符串构造函数构建字符串 - 调试 - 当自动跳过代码时
- 在 VS 调试器中显示 UTF-16 字符串
- 调试读/写字符串到二进制文件
- 为了验证std::字符串是否已损坏,您将执行哪些调试验证
- C++将 char 复制到 char 数组(调试断言失败)时,字符串不是以 null 结尾的
- 字符串下标超出范围C++:调试
- 将调试中的QUrl可视化为VS中的字符串
- 字符串 - 调试断言失败;缓冲区太小
- 无法输出游标位置到调试字符串(WIN32)
- LLDB 在编译时无法调试字符串