Kernel debugging support for LLDB
I'm planning to add a plugin called FreeBSD-kernel and FreeBSD kernel loader to LLDB, and the existing userland ELF core strategies can be inherited. On FreeBSD system, kernel virtual memory image can be accessed using libkvm interfaces, as to support kernel debugging, libkvm APIs, i.e. kvm_read(3)/kvm_write(3), will be mainly used. As we need a way to enumerate all the regions which is not supported by libkvm yet, I'll have to implement an interface to list all the regions organized as a hashtable(hpt_head) in a vmstate struct. To fully support kernel debugging, module metadata parsing and module automatic loading will also be implemented.
There is some existing work related to this project. The first is kgdb in FreeBSD code base, it is a kernel debugger based on gdb. Plus, there is Mac OS X kernel debugging support in LLDB as well. This project will be focused on the platform that LLDB supports, including amd64, mips and i386. Once this project is done, remote kernel debugging and cross-platform kernel debugging would be the next steps of interest.
There are two major milestones:
- Basic support for opening kernel crash dumps and /dev/mem. (mid-term deliverable)
- Full debugging support by adding module parsing and loading. (final deliverable)
Based on LLDB testing framework, add test cases (python scripts) on basic functionality of commands such as backtrace, list, up, down, where, frame, etc. Tests will be conducted locally using a vmcore.
- Compare behavior with kgdb and LLDB.
- Benchmark tests on startup, stepping, etc.
Week 1 - 3
Kernel crash dumps support
Week 4 - 6
Live debugging against /dev/mem support
Week 7 - 10
Kernel Module parsing and loading support
Week 11 - 12
Porting kernel debugging lldbmacros, which is a set of python scripts can be found here
Week 11 - 12
Tests and bug fixing, and documentation work
All features should be done by the firm Pencils down day (Aug. 18th).