This is an old revision of the document!
Project name
- Student: ShengYiHong (aokblast@FreeBSD.org)
Project description
FreeBSD has replaced the GNU toolchain with the LLVM toolchain for a long time. In the LLVM toolchain, there is a bundle debugger called lldb, which is also bundled in FreeBSD. The lldb debug facilities in userland have been well implemented for a long time. However, there are some works still need to be done in the kernel space. What I want to do is to finish the parse mechanism about kernel module information for the kernel debugger
Approach to solving the problem
In kgdb’s scheme, it does the following things:
- Setup the related structure offset in ./kern/linker.c and find the linkerfiles structure that is a linkedlist containing all of the loaded LKM information.
- Search the LKM from the raw and absolute path to find the corresponding kernel module and get the table offset from bfd
- Relocating sections in ko files found in step 2 with LKM base address found in step 1
- Load symbol from symbol file and thus finish
In LLDB’s userspace implementation, it read the kinfovmentry to get the loaded module information, and thus modules can be found in the GetLoadedModuleFileSpce method. What we have to do is to combine LLDB userspace and kgdb in LLDB kernel space. Except for the LKM, I also want to support static kernel module which is also a possible module type in the FreeBSD kernel. But things are different in that the static kernel module will not appear in kldstat. In other words, it will not appear in linkerfiles, so we need a special handler on these files
Deliverables
1. LKM parse and LLDB FreeBSD Kernel Module implementation
Report
- May 29th - June 12th
Busy on my school final exam. The development environment have been set up in these weeks.
- June 12th - June 26th
In this week, I implement LLDB interface sketch for DynamicLoader FreeBSD Kernel (DynamicLoaderFreeBSDKernel) that contains parsing kernel loader address and designinbg kld memory Image structure that contain enough information to create lldb Module. Also, the lldb Module information for Kernel is also parsed so that can provide lldb recognize the Kernel.
- June 26th - July 10th
Parse kld info and Finish all implementation about DynamicLoaderFreeBSDKernel. The kld info is in a linked list structure defined at linked_files symbol that is a TAILQ structure. The necessary member's offset in the structure is provided by the kernel to provide the compatibility in different implementation. Merge the source code from llvm-project to FreeBSD codebase
Test Plan
Because performance is not that important for a debugger, I will focus the test on functionality. In the first stage of the test, I will try to write some small kernel modules with some function symbols contained for debug pur- poses. In the second stage of the test, I will try to use the large kernel module like wifi to test the functionality. In the second stage of the test, I will post my work on reviews.freebsd.org to let other module developers test it.