LLDB Remote debugging iOS

  • 4350
  • 0

摘要:LLDB远程调试iOS程序

 

很多时候,iOS直接gdb可以满足我们的需求,但是很多条件下,这个暂时满足不了我们的需求,就需要使用远程调试。

远程调试需要使用debugserver。提取的方法可以参考:http://bbs.pediy.com/showthread.php?t=138472

不过debugserver和GDB一样,在iOS5上面也会有一些Bug,可以用同样的方法解决,参考:http://www.dotblogs.com.tw/cmd4shell/archive/2012/10/22/78740.aspx

重新签名之后可以这样绑定到本机的8625端口。

# debugservermod 0.0.0.0:8625 ./test

debugserver-64 for armv6 Copyright (c) 2007-2009 Apple, Inc. All Rights Reserved.

Listening to port 8625...

Got a connection, waiting for debugger instructions for task "./test".

LLDB连接的方式:

$ lldb

(lldb) platform select remote-ios --sysroot /Application/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk

  Platform: remote-ios

 Connected: no

  SDK Path: "/Application/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.1.sdk"

(lldb) process connect connect://192.168.1.213:8625

Process 557 stopped

* thread #1: tid = 0x1603, 0x2fe90028 dyld`_dyld_start, stop reason = signal SIGSTOP

    frame #0: 0x2fe90028 dyld`_dyld_start

dyld`_dyld_start:

-> 0x2fe90028: mov r8, sp

   0x2fe9002c: sub sp, sp, #8

   0x2fe90030: bic sp, sp, #7

   0x2fe90034: ldr r3, [pc, #44] ; _dyld_start + 64

(lldb) target list

Current targets:

* target #0: /usr/lib/dyld ( arch=armv7-apple-ios, platform=remote-ios, pid=557, state=stopped )

(lldb) c

Process 557 resuming

 

iauditor>

 

(lldb) target stop-hook add

Enter your stop hook command(s). Type 'DONE' to end.

> bt 

> disassemble --pc

> DONE

Stop hook #1 added.

(lldb) kill

* thread #1: tid = 0x1603, 0x361a6418 libsystem_kernel.dylib`read$NOCANCEL + 8, stop reason = signal SIGINT

    frame #0: 0x361a6418 libsystem_kernel.dylib`read$NOCANCEL + 8

    frame #1: 0x330325e0 libsystem_c.dylib`_sread + 12

    frame #2: 0x3306e8f0 libsystem_c.dylib`__srefill1 + 16

    frame #3: 0x3306e972 libsystem_c.dylib`__srefill + 22

libsystem_kernel.dylib`read$NOCANCEL + 8:

-> 0x361a6418: blo 0x361a6430 ; read$NOCANCEL + 32

   0x361a641c: ldr r12, [pc, #4] ; read$NOCANCEL + 24

   0x361a6420: ldr r12, [pc, r12]

   0x361a6424: b 0x361a642c ; read$NOCANCEL + 28

Process 557 exited with status = 6 (0x00000006) failed to send the k packet

(lldb) 

 

 

 

------------------------------

文章的授權使用CC BY-ND2.5協議。凡是標示“轉載”的文章,均來源於網絡並儘可能標註作者。如果有侵犯您的權益,請及時聯繫刪除或者署名、授權。


Gtalk/Email: cmd4shell  [at]  gmail.com