DebugserverIs 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]
- 1 Command line options
- 2 Patching for process attaching
- 3 Example session
- 4 References
|
Command line options
DebugserverCan be invoked
debugserver [<options>] host:<port> [<prog-name> <arg1> <arg2> ...]
WhereOptionsCan be:
Option |
Effect |
- Process |
AttachDebugserverToProcess.ProcessCan be a pid or executable name. |
-D Integer |
Assign the waitfor-duration. |
-F ? |
? |
-G |
Turn on debugging. |
-I Integer |
Assign the waitfor-interval. |
-L Filename |
Log to file. SetFilenameToStdoutTo log to standard output. |
-T |
Use task ID instead of process ID. |
-V |
Verbose. |
-W ? |
? |
-X Method -- Launch=Method |
How to launch the program. Can be one:
- Auto: Auto-detect the best launch method to use.
- Fork: Launch program usingFork (2)AndExec (3).
- Posix: Launch program usingPosix_spawn (2).
- Spring: Launch program via SpringBoard.
|
-- Lockdown |
Obtain parameters fromLockdown(?) |
Patching for process attaching
The vanillaDebugserverCannot attach to any processes due to lack of entitlement to allowTask_for_pid (). An entitlement must be inserted to the binary to allow this.
- 0.
cd ~
- 1.Thin the binary becauseLdidDoes not support fat binaries:
lipo -thin armv6 /Developer/usr/bin/debugserver -output ~/debugserver
- 2.Save for followingEnt. 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 entitlementLdid:
ldid -Sent.xml debugserver
Example session
Suppose you want to debug your enotes on 3.1. Also suppose you already have the iPhone SDK, and you already have the patchedDebugserverAt ~.
- 1.Copy your enotes to your Mac, e.g./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 your enotes and wait for the remote debugger.
- 3.On your Mac, launch/Developer/Platforms/iPhoneOS. platform/Developer/usr/libexec/gdb-arm-apple-darwin.
- 4.Type the following inGdb:
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/MobileNotestarget remote-macosx 192.168.1.101:6789
Where 192.168.1.101 shoshould be replaced by the actual IP address of your device. The remote debug connection is now complete.
- 5.EnterCTo continue and do whatever you want.
References
- Iphone-debugserver project-http://code.google.com/p/iphone-debugserver/