【发布时间】:2016-07-06 10:05:51
【问题描述】:
我正在尝试使用lldb 打印变量的地址。但是,调用 print &(myVar) 会打印变量的内容而不是其地址。
(lldb) print &(myVar)
(const string *) $18 = "hello"
expression &(myVar) 也一样。
(lldb) expression &(myVar)
(const string *) $19 = "hello"
我还尝试了expression 的-L 选项:
(lldb) expression -L -- &(myVar)
0x00000000021aea80: (const string *) $20 = "hello"
(lldb) expression -L -- myVar
0x0000000002a15430: (std::string) $23 = "hello"
但是每次我调用expression -L 时,输出的地址都会发生变化。因此我假设它与内存中变量的地址不对应。
如何获取变量在内存中的地址?
(我使用 lldb 3.4)
【问题讨论】:
标签: memory-address lldb