Debugging a Linux* OS Kernel Object Module

  • The kernel module, xdbntf.ko, must be installed and running on the target device.

    The folder <install-dir>/<debugger-dir>/debugger/xdb/kernel-modules/xdbntf contains code to generate a Linux* kernel module that enables kernel module debugging with the Intel® System Debugger. To generate xdbntf.ko, transfer these files to your target system and invoke make.

  • The loaded kernel object module on the host and target must be identical. The plug-in searches for <source_path>/<kernel_module_name>.ko.

  1. To unload the module, exit the debugger and enter the command

    rmmod xdbntf.

To debug a the Linux* OS kernel module:

  1. On the target system, enter the command insmod xdbntf.ko.
  2. Establish a connection to the target and launch the debugger as described in Starting and Finishing a Debugging Session.
  3. In the debugger console window enter the command SET DIRECTORY "kernel_module_path".
    This enables the automatic source and symbol info mapping upon kernel module load.
  4. In the debugger, select View > Linux Modules.
  5. Right-click in the Linux Kernel Modules window.
  6. Click Add new module to watchlist.

    The Module Settings dialog box is opened where you can predefine the plug-in behavior while loading the specified module.

  7. Specify the module name without extension and path.
  8. Check Break at Init if you wish the debugger to stop the target when the kernel module is loaded.
  9. To unload a module, exit the debugger and enter the command rmmod xdbntf on the target.

Stopping at Init

  1. In the Module Settings dialog box (as described above), enter the module name, for example,sum1 and check Break at Init.
  2. Select Options > Source Directories and add the search path for the kernel module on the host system.

    This enables the debugger to automatically find and load the debug symbols, for example, the directory containing sum1.ko.

  3. Load the kernel module on the target system using the insmod command, for example insmod sum1.ko.
  4. The debugger will stop at the module's init function and you can scroll through the source code and start debugging as usual.

Note

Stopping at the init function updates the module list automatically, because the kernel notifies the debugger that it has loaded the module to the kernel space. Therefore, the Linux Kernel Modules window might contain more modules than only the one you entered in this example. After the init function returns and the init section of the kernel module is unloaded by the kernel, the debugger will be notified again. The Linux Kernel Modules window will be updated with the information.

See Also

For more complete information about compiler optimizations, see our Optimization Notice.