kgdb: step-through debugging the Linux kernel
Step-through debugging is an especially important skill for an embedded software engineer to master. Step-through debugging of bare-metal or RTOS-based embedded systems is usually performed by an IDE provided by the silicon vendor. The hardware and software, for the most part, are proprietary and costly. On the other hand, the Linux kernel contains the necessary tools to support step-through debugging, and we can use the GDB utility and a UART connection. In this section, we will walk through the necessary steps to connect the GDB debugger to a running kernel. Afterward, we can use the available GDB commands to perform typical debugging operations.
Before we can start debugging the kernel, it needs to be configured appropriately. First, we need to configure the kernel to enable debugging and not to randomize the address of the kernel image, which is used as a security feature.
We can disable the feature to randomize the address...