Skip to main content

LLDB / GDB

GDB

You can connect to the stub via LLDB with the address and port for your particular virtual device, located at the bottom of the virtual device page.

Our lldb command wraps wraps and runs a GDB-remote session. GDB-remote is a protocol used for remote debugging, and both GDB and our LLDB setup supports it. This is useful for running on a remote target and debug programs running on that target, making it possible to use LLDB as a front-end for GDB-remote debugging.

LLDB

Debugging with LLDB is beneficial for virtual devices because LLDB already has built-in knowledge of the Mach-O format and the fact that it is dealing with an XNU kernel. It is possible to use the debugger with or without the Mach-O kernel binary. Using the binary slows down load time, but gives you access to the symbols that are in the binary.

GDB

To use GDB directly, you will need an AArch64-compatible GDB. The versions that ship with Ubuntu 16.04 on AArch64, as well as the Linaro public releases since 7.1.1 (x86_64 Linux), have been tested to work. The AArch64 debug protocol was somewhat in flux until 2015, so very old GDB versions may not interoperate correctly.

Make sure to use the correct version of GDB for your device. 32-bit devices, including Cortex-M based ones, require 32-bit Arm GDB, and 64-bit devices require a 64-bit one.

Examples

Please refer to our Kernel Debugging article. It provides a detailed guide on how to debug the kernel using LLDB or GDB.

To see this in action, check out our guide on Debugging the Kernel.