zoukankan      html  css  js  c++  java
  • [转]iOS 设备上的 debugserver 补丁

    debugserver is a console app that as server for remote gdb debugging. It is installed when a device is marked for development. It can be found in /Developer/usr/bin/debugserver. This is also the process invoked by Xcode to debug applications on the device.

    Contents

     [hide

    Command line options

    debugserver can be invoked with

    debugserver [<options>] host:<port> [<prog-name> <arg1> <arg2> ...]
    

    Where options can be:

    OptionEffect
    -a processAttach debugserver to process. The process can be a pid or executable name.
    -d integerAssign the waitfor-duration.
    -f ? ?
    -gTurn on debugging.
    -i integerAssign the waitfor-interval.
    -l filenameLog to file. Set filename to stdout to log to standard output.
    -tUse task ID instead of process ID.
    -vVerbose.
    -w ? ?
    -x method 
    --launch=method
    How to launch the program. Can be one of:
    • auto: Auto-detect the best launch method to use.
    • fork: Launch program using fork(2) and exec(3).
    • posix: Launch program using posix_spawn(2).
    • spring: Launch program via SpringBoard.
    --lockdownObtain parameters from lockdown (?)

    Patching for process attaching

    The vanilla debugserver cannot attach to any processes due to lack of entitlement to allow task_for_pid(). An entitlement must be inserted to the binary to allow this.

    • 0. cd ~
    • 1. Thin the binary because ldid does not support fat binaries:
    lipo -thin armv6 /Developer/usr/bin/debugserver -output ~/debugserver
    
    • 2. Save for following as ent.xml:
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>com.apple.springboard.debugapplications</key>
    	<true/>
    	<key>get-task-allow</key>
    	<true/>
    	<key>task_for_pid-allow</key>
    	<true/>
    	<key>run-unsigned-code</key>
    	<true/>
    </dict>
    </plist>
    • 3. Apply the entitlement with ldid:
    ldid -Sent.xml debugserver
    

    Example session

    Suppose you want to debug MobileNotes on 3.1. Also suppose you already have the iPhone SDK, and you already have the patched debugserver at ~.

    • 1. Copy MobileNotes to your Mac, e.g. to /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/Applications/MobileNotes.app/MobileNotes.
    • 2. On the device, type:
    ~/debugserver -x spring host:6789 /Applications/MobileNotes.app/MobileNotes
    
    This will launch MobileNotes and wait for the remote debugger.
    • 3. On your Mac, launch /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin.
    • 4. Type the following in gdb:
    set shlib-path-substitutions / /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/
    file /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/Applications/MobileNotes.app/MobileNotes
    target remote-macosx 192.168.1.101:6789
    
    where 192.168.1.101 should be replaced by the actual IP address of your device. The remote debug connection is now complete.
    • 5. Enter c to continue and do whatever you want.

    References

  • 相关阅读:
    10-tensorflow-tf.concat()
    09-tensorflow-tf.split()
    10-numpy笔记-np.random.randint
    学习网络编程的一些实用技巧和细节
    读书笔记_Effective_C++_条款三十一:将文件间的编译依存关系降至最低(第一部分) 重新学习了 继续学习第二 三部分更加精彩
    对四次挥手中的TIME_WAIT状态的学习
    accept 和 connect API深入 重点accept阻塞和非阻塞问题学习
    几种IO情况的学习和总结 关于 =====阻塞/非阻塞以及同步/异步区别
    tcp头和ip头 图文简介和简要说明
    Nginx 为什么要延迟关闭
  • 原文地址:https://www.cnblogs.com/Proteas/p/2826928.html
Copyright © 2011-2022 走看看