LinuxKernelDebugHelper Module

VisualKernel can greatly enhance the kernel debugging experience by building and installing LinuxKernelDebugHelper.ko – a special kernel module facilitating several debugging tasks.

Overview

The module implements the following functionality:

  • Maintains a list of currently loaded kernel modules and allows VisualKernel to query them instantly. This saves considerable time compared to parsing the kernel module structures manually.
  • Serves as a back end for Live Watch – the mechanism for viewing the values of kernel variables in real time without stopping the kernel in debugger.

You can configure VisualKernel to build the KernelDebugHelper module via the VisualKernel Project Properties -> Debug Settings -> Obtain module information via -> Optimized Kernel Module.

Troubleshooting

We normally test LinuxKernelDebugHelper for compatibility with recent kernel releases, however if you are using a rare (or a very new) kernel version, the module may not build out-of-the-box. If this happens, VisualKernel will display an error message showing the detailed build log:You can troubleshoot the build errors as shown below:

  1. Locate the source code of LinuxKernelDebugHelper under C:\Program Files (x86)\Sysprogs\VisualKernel\KernelTools\Common and copy them to your target. If you have previously attempted building the module with VisualKernel, the source will be already uploaded to /tmp/LinuxKernelDebugHelper-<GUID>.
  2. Run the following command lines:
    sh configure.sh /lib/modules/$(uname -r)/build
    make -C /lib/modules/$(uname -r)/build M=$(pwd) modules

    If the build fails due to an error in LiveMemoryEngine.c, your kernel might be configured without network support:If this happens, you can disable the live memory functionality by building the module as shown below:

     make -C /lib/modules/$(uname -r)/build M=$(pwd) DISABLE_LIVE_MEMORY_ENGINE=1 modules

    If you manually disabled the live memory support, make sure you also disable Live Watch via VisualKernel Project Properties -> Debug Settings -> Live Watch -> Show live values of variables -> Never. Otherwise, VisualKernel will try to build the module again.

  3. Once the module has been built successfully, run the following command to find out the address of kallsyms_lookup_name():
    sudo cat /proc/kallsyms | grep kallsyms_lookup_name

    Then load the newly built module passing the address of kallsyms_lookup_name() to it as a parameter:

    sudo insmod ./LinuxKernelDebugHelper.ko kallsyms_lookup_name_address=0x<...>

You can verify that the module is loaded by running “sudo dmesg” or “cat /proc/com_sysprogs_LinuxKernelDebugHelper_DebugBlockAddress_v2”. If the file in /proc is present, VisualKernel will be able to use the functionality provided by the module.