Lldb打印寄存器值

新手发问,请多指点。
1 2
如图,x8的值是"demo",但是po打印出来的始终编码不对,要怎么才能打印呢

发现NSString类型的就能打印
1 2

没复现出来你的操作,我感觉有几个概念要弄清楚:

  1. ppo 的区别

https://lldb.llvm.org/use/map.html 里的 Evaluating Expressions 有解释

  • GDB 里po代表打印ObjC description

Printing the ObjC “description” of an object.
(gdb) po [SomeClass returnAnObject]

  • lldb里 poexpr命令的别名,执行表达式求值

(lldb) expr -o – [SomeClass returnAnObject]
or using the po alias:
(lldb) po [SomeClass returnAnObject]

  1. $x8 和 $8
    看一下 (lldb) help expression

User defined variables:

You can define your own variables for convenience or to be used in
subsequent expressions.  You define them the same way you would define
variables in C.  If the first character of your user defined variable is a
$, then the variable's value will be available in future expressions,
otherwise it will just be available in the current expression.

$ 开头的,后续也可以使用(作用域变大)。
所以 $x8$8 是不一样的。
$x8 是lldb的内置变量,并且作用域全局
$8 是你自己定义(有可能误操作?)的名字叫做8,作用域全局的变量.

所以重新运行一下程序,直接 p (char*)$x3 或者 p (char*)0x0000000104211a99 试试。

所以我猜是不是误操作把这个地址的值给覆盖了。。。 但是我没复现出来。。。

3 个赞