How to use LLDB to debug an application on an Electra jailbreak device
This article is about how to use LLDB debugging applications on Electra jailbreak devices. Xiaobian thinks it is quite practical, so share it with you. I hope you can gain something after reading this article. Let's not say much. Let's take a look at it together with Xiaobian.
I tried to Google search for brief instructions on debugging AppStore apps on iOS devices using Electra jailbreak. However, I am disappointed that I have not found any useful information. After my testing it works perfectly for me, but I'm not sure it works for you. I tested it on the following devices:
iPhone 7 running iOS 11.1.2
iPhone 5s running iOS 11.0.1
Both devices were jailbroken using Electra jailbreak 1.0.4.
Deploy debugserver to your device from Xcode
First, connect to your iOS device via ssh and see if/Developer/usr/bin/debugserver exists. If not,
Running Xcode on Mac
Open an ObjC project for iOS (or create a new project from scratch)
Keep Xcode running. Connect your iOS device to USB
Then in Xcode you should see the following information in the red box:
Wait until "Ready to debug iPhone support" is complete. Then check/Developer/usr/bin/debugserver on the device. At this point, the debugserver binary file should already exist.
Debugging via USB
For me, it only works if I debug via USB. If iproxy is not installed on your Mac, install it via brew:
$ brew install usbmuxd
Then run in Mac console:
$ iproxy 6666 6666 &$ iproxy 2222 22 &
Finally, connect the iPhone to USB. That's it, we're ready to go.
Attaching LLDB to an already running process
On your Mac console, connect iPhone:
$ ssh -p 2222 root@localhost
Run in iPhone console
# ps ax
Find the pid of the process you want to attach. then run
# /electra/jailbreakd_client 1# /Developer/usr/bin/debugserver localhost:6666 -a
If you see something like me,
debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-360.0.26.14 for arm64.Attaching to process 1418... Listening to port 6666 for a connection from localhost...
It indicates that everything is normal. Now, open another console on your Mac and run
$ lldb
Run in LLDB console
(lldb) platform select remote-ios(lldb) process connect://localhost:6666 Run the application under LLDB
On your Mac console, connect iPhone:
$ ssh -p 2222 root@localhost
Run in iPhone console
# /Developer/usr/bin/debugserver localhost:6666 -x backboard /var/containers/Bundle/Application/
If you see something like me,
debugserver-@(#)PROGRAM:debugserver PROJECT:debugserver-360.0.26.14 for arm64.Listening to port 6666 for a connection from localhost...
It indicates that everything is normal. Now, open another console on your Mac and run
$ lldb
Run in LLDB console
(lldb) platform select remote-ios(lldb) process connect connect://localhost:6666
Important note! If you encounter an error, try:
Running an application without a debugger
Attach the debugger to the application as described in the previous section
Close (LLDB) Application
Run the application again under the debugger
The above is how to use LLDB to debug applications on Electra jailbroken devices. Xiaobian believes that some knowledge points may be seen or used in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.