1How to create vmcores for tests
2===============================
3
41. Boot a FreeBSD VM with as little memory as possible and create a core dump
5   per `FreeBSD Handbook Kernel Debugging Chapter`_.  Note that you may need to
6   reboot with more memory after the kernel panic as otherwise savecore(8) may
7   fail.
8
9   For instance, I was able to boot FreeBSD and qemu-system-x86_64 with 128 MiB
10   RAM but had to increase it to 256 MiB for the boot after kernel panic.
11
122. Transfer the kernel image (``/boot/kernel/kernel``) and vmcore
13   (``/var/crash/vmcore.latest``) from the VM.
14
153. Patch libfbsdvmcore using ``libfbsdvmcore-print-offsets.patch`` and build
16   LLDB against the patched library.
17
184. Do a test run of ``test.script`` in LLDB against the kernel + vmcore::
19
20    lldb -b -s test.script --core /path/to/core /path/to/kernel
21
22   If everything works fine, the LLDB output should be interspersed with
23   ``%RD`` lines.
24
255. Use the ``copy-sparse.py`` tool to create a sparse version of the vmcore::
26
27       lldb -b -s test.script --core /path/to/core /path/to/kernel |
28           grep '^% RD' | python copy-sparse.py /path/to/core vmcore.sparse
29
306. Compress the sparse vmcore file using ``bzip2``::
31
32       bzip2 -9 vmcore.sparse
33
34
35.. _FreeBSD Handbook Kernel Debugging Chapter:
36   https://docs.freebsd.org/en/books/developers-handbook/kerneldebug/
37