Debugging Linux Kernel using KGDB Part8 - Debugging Kernel Module

In this post, we will debug the e1000 module present on our Ubuntu VM.

Steps for debugging using KGDB:

On the target:
gdb client needs to know the load address of the kernel module
$ cat /sys/module/e1000/sections/.text
0xffffffffc0091000

Switch to KGDB Debugger mode by activating magic sysrq
$ echo 'ttyS1,115200' > /sys/module/kgdboc/parameters/kgdboc
$ echo g > /proc/sysrq-trigger

On the Development Machine:
Run the following commands:
$ gdb ./vmlinux
$ target remote /dev/ttyS1
$ add-symbol-file drivers/net/ethernet/intel/e1000/e1000.ko  0xffffffffc0091000


Let's put breakpoint at e1000_xmit_frame which is called while transmitting a frame.

(gdb) break e1000_xmit_frame
Breakpoint 1 at 0xffffffffc0092f90: file drivers/net/ethernet/intel/e1000/e1000_main.c, line 3102.
(gdb) c

Now see as soon as it transmits a packet, system will stop and enter into kgdb session






Comments

  1. Thank you for sharing this! What you have shared is very helpful and informative. Would love to see more updates from you.

    Website Development

    ReplyDelete
  2. The tutorials are very helpful,thanks.
    I tried the same steps as mentioned in tutorial but facing some issues.
    When i insmod the kernel module on target(Beagle-Bone),i don't see a .text section under /sys/module//sections/.
    Any input on this will be helpful.

    ReplyDelete
    Replies
    1. The below command also gives the module's loaded address

      ```
      $ sudo grep MODULE_NAME /proc/modules
      ```

      Delete

Post a Comment

Popular posts from this blog

bb.utils.contains yocto

make config vs oldconfig vs defconfig vs menuconfig vs savedefconfig

PR, PN and PV Variable in Yocto