QEMU can be used to test LLDB in an emulation environment in the absence of
actual hardware. This page describes instructions to help setup a QEMU emulation
environment for testing LLDB.
The scripts under llvm-project/lldb/scripts/lldb-test-qemu can quickly help
setup a virtual LLDB testing environment using QEMU. The scripts currently work
with Arm or AArch64, but support for other architectures can be added easily.
***setup.sh** is used to build the Linux kernel image and QEMU system emulation executable(s) from source.
***rootfs.sh** is used to generate Ubuntu root file system images to be used for QEMU system mode emulation.
***run-qemu.sh** utilizes QEMU to boot a Linux kernel image with a root file system image.
Once we have booted our kernel we can run lldb-server in emulation environment.
Ubuntu Bionic/Focal x86_64 host was used to test these scripts instructions in this
document. Please update it according to your host distribution/architecture.
..note::
Instructions on this page and QEMU helper scripts are verified on a Ubuntu Bionic/Focal (x86_64) host. Moreover, scripts require sudo/root permissions for installing dependencies and setting up QEMU host/guest network.
Given below are some examples of common use-cases of LLDB QEMU testing
helper scripts:
Create Ubuntu root file system image for QEMU system emulation with rootfs.sh
rootfs.sh has been tested for generating Ubuntu Bionic and Focal images but they can be used to generate rootfs images of other Debian Linux distribution.
rootfs.sh defaults username of generated image to your current username on host computer.
Build QEMU or cross compile Linux kernel from source using setup.sh
* Cross compile LLDB server for AArch64 Linux: Please visit https://lldb.llvm.org/resources/build.html for instructions on how to cross compile LLDB server.
* Transfer LLDB server executable to emulation environment