Dev: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.

Command line options
debugserver can be invoked with

debugserver [ ] host: [ ...]

Where options can be:

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.
 * 1. Thin the binary because ldid does not support fat binaries:

lipo -thin armv6 /Developer/usr/bin/debugserver -output ~/debugserver ldid -Sent.xml debugserver
 * 2. Save for following as ent.xml:
 * 3. Apply the entitlement with ldid</tt>:

Example session
~/debugserver -x spring host:6789 /Applications/MobileNotes.app/MobileNotes "This will launch MobileNotes and wait for the remote debugger."
 * 1. Copy MobileNotes to your Mac, e.g. to /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.1.sdk/Applications/MobileNotes.app/MobileNotes</tt>.
 * 2. On the device, type:

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."
 * On your Mac, launch /Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gdb/gdb-arm-apple-darwin</tt>.
 * Type the following in gdb</tt>:

LLDB
platform select remote-ios process connect connect://192.168.1.101:6789
 * On your Mac, launch lldb</tt>.
 * Type the following in lldb</tt>:


 * 5. Enter c</tt> to continue and do whatever you want.