One of the major benefits of using a virtual environment is the ability to inspect and modify the state of the whole system under user control. The primary interface to these features is through the TCP-based GDB remote protocol compatible stub.
watch
/ awatch
/ rwatch
with conditions, every breakpoint is sent to your local machine, the condition is calculated, and then resumed if it was meant to ignore. This is how GDB functions, but it is typically not noticeable for local kernel debugging. On the local GDB end, nothing will visually indicate that this is happening unless the condition is met, in which case you’ll receive a prompt.To connect using GDB / LLDB, check out our article on GDB / LLDB.
Note: The address and port provided here are for example purposes only. You will need to use the address and port for your particular virtual device. You can find the address and port for your device at the end of the "kernel gdb" link.
Example
To Switch CPUs (in this case, to CPU 1)
To Access Monitor Commands
Otherwise, use regular GDB commands to control the debug stub.
Note: The address and port provided here are for example purposes only. You will need to use the address and port for your particular virtual device. You can find the address and port for your device at the end of the "kernel gdb" link.
Example
Example
The GDB stub represents CPU cores as threads.
While LLDB is specified in the UI, users are free to use GDB as well.
You can use the regular LLDB commands to control the debug stub.
Your debugger will work as if it was attached to a hardware debugger (think OpenOCD).
The following instructions are for IDA 7.0 versions.
Select Debugger | Switch debugger... from the main menu, then pick Remote GDB debugger in the dialog box.
Then, again from the main menu, select Debugger then Debugger options.... Click the Set specific options button and make sure the Use stepping support checkbox is checked.
Finally, select Debugger | Process options... from the main menu, enter the stub's address in the Hostname and Port fields. After this setup, which is saved in the IDA database, select Debugger | Attach to process... to attach to the running device.
To access monitor commands from IDA, locate the GDB command line bar at the bottom of the window (just above the status bar, next to a GDB button). Enter the monitor commands there, without the word "monitor" itself. For instance, instead of monitor sr
, simply write sr and press Enter. The output will appear in IDA's text output window above.
Looking to debug the kernel on a virtual device? Book a meeting to deep dive into TCP-based GDB remote protocol usage, handle multiple CPUs, and manage breakpoints with precision.
Experience Corellium’s groundbreaking virtualization technology for mobile devices and discover never-before-possible mobile vulnerability and threat research for iOS and Android phones. Book a meeting today to explore how our platform can optimize mobile security research and malware analysis.