书中最后一章关于变量跟踪的问题

书中最后一章iMessage里定位堆栈(SP+0x14)那里感觉好繁琐,作者的方法我完全看不懂,我最后还是用自己的方法一步步往上推当前的offset才弄懂的,在弄懂后我就在想这个问题不就是下一个内存write断点就能解决了吗。然后我就去lldb官网找内存读写断点,发现好像只有一个内存写得断点,我就尝试一下看是否有用,结果是悲催的,他断不下来,估计是我没弄好的问题,我在研究下。另外请教下老大内存读写断点如何下呢。
写个伪代码:
假如:
move r0,r1
如果给r0下read断点是否可行,如果可行应该怎么下呢,lldb文档里没有说明(也有可能是我挫,没找到),请大牛指点下。能否给个下内存读写断点的具体命令呢。

我就是没找到下watchpoint的方法,才采用这种方法的;看不懂可能是因为我的iOS版本跟你不一样,导致汇编代码不一样,你对不上号

连你都不知道怎么用watchpoint了,那我再去找使用方法岂不是大海捞针啊,可惜内存读写断点真的太强大了,如果不能用的话个人感觉在定位数据读写时真是断了一条胳膊。如果单纯的靠一步步推数据修改点的话,遇到逻辑复杂一点的都不敢想要推到啥时呢。

是的,我这样的分析方式有碰运气的成分在里面,如果逻辑再复杂一点,人工分析就很吃力了

我也尽力研究下watchpoint能否用在内存断点上吧,如果找到和大家分享。

1 个赞

(lldb) help watchpoint set
The following subcommands are supported:

expression -- Set a watchpoint on an address by supplying an expression.
              Use the '-w' option to specify the type of watchpoint and the
              '-x' option to specify the byte size to watch for. If no '-w'
              option is specified, it defaults to write. If no '-x' option
              is specified, it defaults to the target's pointer byte size.
              Note that there are limited hardware resources for
              watchpoints. If watchpoint setting fails, consider
              disable/delete existing ones to free up resources.  This
              command takes 'raw' input (no need to quote stuff).
variable   -- Set a watchpoint on a variable. Use the '-w' option to
              specify the type of watchpoint and the '-x' option to specify
              the byte size to watch for. If no '-w' option is specified,
              it defaults to write. If no '-x' option is specified, it
              defaults to the variable's byte size. Note that there are
              limited hardware resources for watchpoints. If watchpoint
              setting fails, consider disable/delete existing ones to free
              up resources.

是有这个方法的,但是我set了总是失败,请大牛也帮我一起试试呢。

哈哈试出来了:
(lldb) wa s e -w r – 0x27d61114
Watchpoint created: Watchpoint 5: addr = 0x27d61114 size = 4 state = enabled type = r
new value: 391767744
(lldb) wa s e -w w – 0x27d61114
Watchpoint created: Watchpoint 6: addr = 0x27d61114 size = 4 state = enabled type = w
new value: 391767744
(lldb)

1 个赞

你可以用watchpoint把第10章的一些大的改进总结一下发个帖,造福后来人啊!

好,我尽力尝试一下吧,我会在今后实战中和大家随时分享。另外本书都已看完,之前没看完时感觉还行不就这么回事嘛,可等自己看完书了感觉路太长,只有坚持才能有一丝希望,不经想起这句话:梦想总是要有的。。。

1 个赞

只要行动起来了,什么时候都不算晚 :stuck_out_tongue_winking_eye: