一步一步用debugserver + lldb代替gdb进行动态调试


#24

自己搞定了。

cd /usr/bin

chmod 777 debugserver


#25

7.1 beta3 直接ldid 就可以调试了。

我7.1 beta3 的,直接弄倒/usr/bin 下,报下面错误“error: failed to attach to process named: “” unable to start the exception thread” ,上面的签名应该就是给lldb 赋予,调试权限吧


#26

安照操作,最后下得断点,是下面这样的,有点晕,睡了。
“Process 26 stopped

  • thread #1: tid = 0x0225, 0x00101aac SpringBoard, queue = ‘com.apple.main-thread’, stop reason = instruction step over
    frame #0: 0x00101aac SpringBoard
    -> 0x101aac: strmi r11, [r4], -lr, lsl #1
    0x101ab0: sbcshs pc, r6, r9, asr #4
    0x101ab4: eorseq pc, r1, r0, asr #5
    0x101ab8: ldrbtmi r4, [r8], #-1557

#27

你试试看“c”能不能resume进程?


#28

可以的,感觉像是指令解析错误了。


#29

stop reason = instruction step over

没有报错,更像是你“ni”了之后的结果


#30

楼主
(lldb) po [UIApplication sharedApplication] windows] objectAtIndex:0] recursiveDescription]
2014-04-17 09:37:28.732 xxxx[870:60b] -[UILabel length]: unrecognized selector sent to instance 0x14648fb0
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-3)…
The process has been returned to the state before expression evaluation.

报以上错,是什么原因呢?


#31
2014-04-17 09:37:28.732 xxxx[870:60b] -[UILabel length]: unrecognized selector sent to instance 0x14648fb0

你这种调法貌似不对,多了个

objectAtIndex:0

改成

[UIApplication sharedApplication] keyWindow] recursiveDescription]

试试


#32

(lldb) process connect connect://192.168.0.225:1234
Assertion failed: (pointer_byte_size == m_host_arch.GetAddressByteSize()), function GetHostInfo, file /SourceCache/lldb/lldb-310.2.37/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp, line 1497.
Abort trap: 6

前面都正常,连接的时候就出错了~


#33

po [UIApplication sharedApplication] keyWindow] recursiveDescription]
2014-04-18 13:33:52.581 HouseRent[2861:60b] -[UILabel length]: unrecognized selector sent to instance 0x16760b70
error: Execution was interrupted, reason: internal ObjC exception breakpoint(-3)…
The process has been returned to the state before expression evaluation.

一样的,

还有楼主,我设置了断点成功后,再怎么调试?

(lldb) frame var
(lldb) 无输出,

(lldb) bt

  • thread #1: tid = 0x42a1f, 0x2fdf00e8 UIKit`-[UIViewController viewDidLoad], queue = ‘com.apple.main-thread’, stop reason = breakpoint 6.1
    • frame #0: 0x2fdf00e8 UIKit-[UIViewController viewDidLoad] frame #1: 0x001e143e HouseRent frame #2: 0x00415032 HouseRent frame #3: 0x00421af4 HouseRent frame #4: 0x2fd7c95a UIKit-[UIViewController loadViewIfRequired] + 518
      frame #5: 0x2fd7c718 UIKit-[UIViewController view] + 24 。。。。。。 frame #22: 0x3225b2ea GraphicsServicesGSEventRunModal + 138
      frame #23: 0x2fddc844 UIKit`UIApplicationMain + 1136
      frame #24: 0x001045ce HouseRent

#34

ni = step over
si = step into
c = continue
更多指令看manual


#35

我注意到你的lldb版本号是310.2.37,而我今天在升级到Xcode 5.1.1之后,发现用lldb时,ARM指令和THUMB指令混到了一起,完全没法调试,lldb的版本正是310.2.37。我正在尝试装回Xcode 5.0.X,用旧版的lldb试试看,如果问题解决了,就说明是新版lldb的bug


#36

应该是我自身的问题。我用的mini2,结果用armv7s瘦身了= =.应该用arm64才对。
麻烦大名了~~谢谢。


#37

你试试用lldb-310.2.37调试时指令显示得对不对,我这边是有问题的,怀疑就是lldb的问题


#38

换回Xcode 5.0.2后,lldb版本为300.2.53,问题解决。我猜测lldb-310.x.x有bug


#39

~ root# debugserver *:1234 -a “SpringBoard”
debugserver-199 for armv7.
Listening to port 1234…
到这里touch 卡住了,不响应触摸,home键也没反应等了几分钟,白屏了一下,然后自己重启了

((lldb) process connect connect://iOSIP:1234
error: Connection refused
(lldb)
这是怎么回事?touch 4th,iOS 6.1.6


#40

第一个问题,是因为你attach了SpringBoard,自然SpringBoard就卡住了。而SpringBoard响应一旦超时就要被watchdog给kill掉,所以造成了这种现象。解决这种现象的方法就是赶紧在OSX上用lldb连过去开始调试:tongue:
第二个问题,把这里的iOSIP换成你iOS的实际IP地址啊啊啊啊啊啊啊!不然连不过去,造成了第一个问题……


#41

嗯,是这样的,谢谢


#42

我用arm64瘦身就正常了

你说的指令不正确是指什么?我试试~

我用lldb打印指令,如x/10i 和IDA的差很多,这个好像是针对固定指令长度的~- -!


#43

画瓢成功:lol: