Skip to content

Commit 9f364fe

Browse files
[lldb][docs] Add section on testing with QEMU user (#149057)
This is not recommended to basically anyone but on occasion it's useful and could be used for testing with other simulator programs for example bare metal simulators. It is not something we do officially support or make any quality guarantees for. Adding this is also an excuse to document the limitations and make the time spent setting up system mode look more worthwhile and might be good to cite in future discussions about testing in simulation.
1 parent 97922a7 commit 9f364fe

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

lldb/docs/resources/qemu-testing.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,50 @@ The result of this is that:
167167

168168
Your VM configuration should have ports ``54321`` and ``49140`` forwarded for
169169
this to work.
170+
171+
QEMU user mode emulation
172+
------------------------
173+
174+
Serious testing of LLDB should be done using system mode emulation. The following
175+
is presented for information only and is not a supported testing configuration
176+
supported by the LLDB project.
177+
178+
However, it is possible to run the test suite against user mode QEMU if you just
179+
want to test a specific aspect of ``lldb`` and are ok ignoring a lot of expected
180+
failures. This method can also be adapted for simulators with a qemu-like command
181+
line interface.
182+
183+
(``lldb-server`` cannot be tested using user mode QEMU because that does not
184+
emulate the debugging system calls that ``lldb-server`` tries to make)
185+
186+
Change ``LLDB_TEST_USER_ARGS`` to choose the ``qemu-user`` platform and
187+
configure it for your architecture. The example below is for AArch64 and assumes
188+
that ``qemu-aarch64`` is installed and on your path.
189+
190+
If you need to override how the ``qemu-user`` platform finds the QEMU binary,
191+
look up the rest of the platform's settings in LLDB.
192+
193+
::
194+
195+
-DLLDB_TEST_USER_ARGS="--platform-name;qemu-user;--setting;platform.plugin.qemu-user.architecture=aarch64;--arch;aarch64"
196+
197+
Also set ``LLDB_TEST_COMPILER`` to something that can target the emulated
198+
architecture. Then you should be able to run ``ninja check-lldb`` and it will
199+
run the tests on QEMU user automatically.
200+
201+
You will see a number of failures compared to a normal test run. Reasons for
202+
this can be, but are not limited to:
203+
204+
* QEMU's built-in debug stub acting differently and supporting different
205+
features to different extents, when compared to ``lldb-server``. We try to
206+
be compatible but LLDB is not regularly tested with QEMU user.
207+
208+
* Tests that spawn new processes to attach to. QEMU user only emulates a single
209+
process.
210+
211+
* Watchpoints. Either these are not emulated or behave differently to real
212+
hardware. Add ``--skip-category;watchpoint`` to ``-DLLDB_TEST_USER_ARGS`` to
213+
skip those.
214+
215+
* Lack of memory region information due to QEMU communicating this in the
216+
GDB server format which LLDB does not use.

0 commit comments

Comments
 (0)