summerofcode2023projects:lldbkernelmoduleimprovement

This is an old revision of the document!


Project name

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

In kgdb’s scheme, it does the following things:

  1. 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.
  2. Search the LKM from the raw and absolute path to find the corresponding kernel module and get the table offset from bfd
  3. Relocating sections in ko files found in step 2 with LKM base address found in step 1
  4. 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

1. LKM parse and LLDB FreeBSD Kernel Module implementation

(5-10 milestones, with dates, indicating when you hope or expect to be able to complete features. This section is mandatory. Please negotiate these with your mentor to make sure you're not under or over-estimating the amount of work to be done. Please also make sure the following four dates are included within your milestones)

  • May 29th - June 12th
  • June 12th - June 26th

Implement LLDB interface for DynamicLoader FreeBSD Kernel (DynamicLoaderFreeBSDKernel)

  • June 26th - July 10th

Parse kld and Finish all implementation about DynamicLoaderFreeBSDKernel

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.

(Link to your code, for example https://svnweb.freebsd.org/socsvn/soc2018/username/ or a Github URL etc)

  • summerofcode2023projects/lldbkernelmoduleimprovement.1689162806.txt.gz
  • Last modified: 2023/07/12 11:53
  • by ShengYiHong