Debugging a loadable kernel module
You can use Arm® Development Studio to develop and debug a loadable kernel module. Loadable modules can be dynamically inserted and removed from a running kernel during development without the need to frequently recompile the kernel.
This tutorial uses a simple character device driver
modex.c which is part of the Armv7 Linux application examples available in Arm Development Studio.
You can use
modex.c to compile, run, and debug against your target. The
readme.html in the
<installation_directory>/examples/docs/kernel_module contains information about customizing this for your target.
If you are working with your own module, before you can debug it, you must ensure that you:
- Unpack kernel source code and compile the kernel against exactly the same kernel version as your target.
- Compile the loadable module against exactly the same kernel version as your target.
- Ensure that you compile both images with debug information. The debugger requires run-time information from both images when debugging the module.
Create a new Debug Configuration.
- From the main Arm Development Studio menu, select Run > Debug Configurations.
In the Debug Configurations dialog box, create a New Launch Configuration and give it a name. For example,
In the Connection tab, select the target and platform and set up your target connection.
Figure 10-6 Typical connection settings for a Linux kernel/Device Driver Debug
In the Files tab, set up the debugger settings to load debug information for the Linux kernel and the module.
Figure 10-7 Typical Files settings for a Linux kernel/Device Driver Debug
- In the Debugger tab, select Connect only in the Run control panel.
- Click Debug to connect the debugger to the target.
- Configure and connect a terminal shell to the target. You can use the Remote System Explorer (RSE) provided with Arm Development Studio.
Using RSE, copy the compiled module to the target:
On the host workstation, navigate to
- Drag and drop the module to a writeable directory on the target.
- On the host workstation, navigate to
Using the terminal shell, insert the
The Modules view updates to display details of the loaded module.
- Navigate to the location of the kernel module.
Execute the following command:
- To debug the module, set breakpoints, run, and step as required.
To modify the module source code:
Remove the module using commands as required in the terminal shell. For example:
- Recompile the module.
- Repeat steps 3 to 5 as required.
- Remove the module using commands as required in the terminal shell. For example:
OS modules loaded after connection are displayed in the Modules view.