LLDB FreeBSD CPU target support and userland debugging improvements
- 3 minutes read - 549 wordsThe Moritz Systems team has started a new contract on LLDB FreeBSD CPU target support and userland debugging improvements.
The LLDB project builds on libraries provided by LLVM and Clang to provide a great modern debugger. It uses the Clang ASTs and expression parser, LLVM JIT, LLVM disassembler, etc so that it provides an experience that “just works”. It is also blazing fast and more permissively licensed than GDB, the GNU Debugger.
LLDB is the default debugger in Xcode on macOS and supports debugging C, Objective-C and C++ on the desktop and iOS devices and simulator.
FreeBSD includes LLDB, the debugger in the LLVM family, in the base system. At present it has some limitations in comparison with the GNU GDB debugger, and does not yet provide a complete replacement. It relies on an obsolete plugin model in LLDB that causes growing technical debt. This project aims to bring LLDB closer to a fully featured replacement for GDB, and therefore for FreeBSD to feature a modern debugger for software developers.
The legacy monolithic target support, still in use in non-x86 targets, executed the frontend and backend of the debugger in the same process space. The modern LLDB plugin approach, used on other supported targets, executes the target process under a separate lldb-server process. This improves reliability and simplifies the process / thread model in LLDB itself. In addition, remote and local debugging will both be performed using the same approach.
First, we are going to work on enhancing the FreeBSD support in LLDB, reusing the prior art already done for FreeBSD LLDB/x86 and expanding it to other CPUs. We are going to switch all the CPUs to the new remote process plugin framework and remove the old native-debugging process plugin altogether. Once the port is complete, we would like to focus on reiterating all LLDB tests on ARM64 addressing the detected bugs as time permits, and marking non-trivial issues as known failures. The verification of the remaining CPUs and the new remote process plugin is expected to be deferred to the user community.
Next, we plan to implement the support for follow-fork and follow-vfork operations on par with the GNU GDB support and cover this functionality with LLDB regression tests. We anticipate that we could implement follow-spawn in one go, featuring enhanced support for tracing process events on NetBSD as well.
Next, we plan to implement the SaveCore functionality for FreeBSD, allowing users to create core dump files on demand and enhance the regression testing of core files in LLDB, validating that they are operational on cross-OS and cross-ABI basis.
Finally, we intend to update the FreeBSD manual to update it for the improved LLDB support.
The Project Schedule is divided into four milestones, each taking approximately one month:
- M1 Switch all the non-x86 CPUs to the LLDB FreeBSD Remote-Process-Plugin
- M2 Iteration over regression tests on ARM64 and fixing known bugs, marking the non-trivial ones for future work. Remove the old local-only Process-Plugin.
- M3 Implement follow-fork and follow-vfork operations on par with the GNU GDB support. Cover the functionality with LLDB regression tests.
- M4 Implement SaveCore functionality for FreeBSD and enhance the regression testing of core files in LLDB. Update the FreeBSD manual.
This work is sponsored by The FreeBSD Foundation.