[英]VS2017 Debugger : has no address, possibly due to compiler optimizations
似乎与一些标题相似的问题无关。
//some other code
std::string s = Lookup->getName().str();
-> break here //some other code
注意:“查找”是 clang::DirectoryLookup http://clang.llvm.org/doxygen/classclang_1_1DirectoryLookup.html ,“Lookup->getName()”是 llvm::StringRef http://llvm.org/doxygen/classllvm_1_1StringRef .html
在上述位置中断时,在VS2017的“Watch”窗格中,字符串变量“s”初始化成功,其值可以在“Watch”窗格中显示。
但是当尝试显示(观察)表达式“Lookup->getName().str()”这就是“s”的初始化方式时,它说:
Lookup->getName().str() | Function llvm::StringRef::str has no address, possibly due to compiler optimizations.
StringRef::str() 的源代码是:
/// str - Get the contents as an std::string.
LLVM_NODISCARD
std::string str() const {
if (!Data) return std::string();
return std::string(Data, Length);
}
并且所有库都在调试版本中。 基于上述事实,似乎没有理由发生这种情况。
在调试 Clang Libtooling 程序的其他情况下会发生这种情况,这使得调试非常困难。
可能的原因是什么以及如何解决?
我尝试了 @user15331850 解决方案,但没有帮助,但是将 Linker-> Debugging-> Generate Debug Info 设置为 "/DEBUG:FULL" 似乎现在给了我所有变量。
这可能是由于启用了优化选项。 您可以按照以下步骤禁用它:
就是这样。 希望这对你有用!!
我有这个问题。 我需要更改以下设置:链接器-> 调试-> 生成调试信息从“/DEBUG:FASTLINK”到“/DEBUG”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.