lldb:无法实现:无法获取变量的值 [英] lldb: Couldn't materialize: couldn't get the value of variable

查看:440
本文介绍了lldb:无法实现:无法获取变量的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个命令行编译了一个cpp文件: g ++ -g test.cpp

I have compiled a cpp file with this command line: g++ -g test.cpp

在第28行的异常。我想通过检查lldb中的变量来调查原因。我在第28行设置断点,并运行lldb中的 a.out

It throws an exception at line 28. I want to investigate the cause by inspecting the variables in lldb. I set a break point at line 28 and run the a.out in lldb.

(lldb) n
Process 84233 stopped
* thread #1: tid = 0xa44b86, 0x00000001000017fb a.out`say(s=<unavailable>) + 987 at so.cpp:28, queue = 'com.apple.main-thread', stop reason = step over
    frame #0: 0x00000001000017fb a.out`say(s=<unavailable>) + 987 at so.cpp:28
   25       }
   26       else{
   27           s.insert(0, to_string(sz));
-> 28           s.erase(2, sz-1);
   29       }
   30       return s;
   31   }
(lldb) po s
error: Couldn't materialize: couldn't get the value of variable s: variable not available
Errored out in Execute, couldn't PrepareToExecuteJITExpression

为什么会出现错误消息?如何检查变量 s

Why the error message? How can I inspect the variable s?

lldb版本:lldb-320.4。 115.3

lldb version: lldb-320.4.115.3

g ++版本配置为:--prefix = / Applications / Xcode6-Beta5.app / Contents /开发人员/ usr --with-gxx-include-dir = / usr / include / c ++ / 4.2.1
Apple LLVM版本6.0(clang-600.0.45.3)(基于LLVM 3.5svn)
目标:x86_64-apple-darwin13.3.0
线程模型:posix

推荐答案

意味着调试信息确实提到了变量,但表示它在当前PC上没有存储位置。

That error means the debug information does mention the variable, but says it has no storage location at the current PC.

这可能是因为变量已优化出来只是调用变量上的函数),或者因为编译器对变量调试信息并丢失了它的去处。

That can be because the variable got optimized out (unlikely given you are just calling a function on the variable) or because the compiler flubbed the debug info for the variable and lost track of where it went.

确保编译代码正试图在-O0调试,因为没有很多编译器在较高的优化级别发出良好的调试信息。如果你在-O0编译,这是一个编译器错误。你应该报告给gcc的人。你可以看看你有没有更好的运气与ang。否则,您必须读取函数的汇编,以确定变量实际存在的位置,然后告诉调试器打印相应的转换地址。

Make sure you are compiling the code you are trying to debug at -O0 as there aren't many compilers that emit good debug information at higher optimization levels. If you are compiling at -O0, this is a compiler bug. You should probably report it to the gcc folks. You could see if you have better luck with clang. Otherwise, you have to read the assembly of the function to figure out where the variable actually lives, then tell the debugger to print the appropriately cast address.

这篇关于lldb:无法实现:无法获取变量的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆