Article title: Linux kernel module debugging. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
1. enable the VM and run it to kgdb: Waiting for connection from remote gdb.
2. run socat tcp-listen: 8888/tmp/vbox2 on the Host, where/tmp/vbox2 is the pipeline file, which is the redirection destination file of the serial port of the target machine, socat redirects the MPs queue file to port 8888 of tcp socket.
3. start a new virtual terminal, cd path/to/kernel/source/tree, and then execute gdb./vmlinux
Output
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3 +: gnu gpl version 3 or later
This is free software: you are free to change and redistribute it.
There is no warranty, to the extent permitted by law. Type "show copying"
And "show warranty" for details.
This GDB was configured as "i486-linux-gnu "...
(Gdb) set-remote
Set remote baud rate to 115200c/s
Set remote target to local tcp socket
Kgdb_breakpoint () at kernel/kgdb. c: 1721
1721 wmb ();/* Sync point after breakpoint */
(Gdb) c
Continuing.
The target opportunity is started until the user name and password are prompted.
4. enter the target machine, enter the user name and password (the root user under the character interface is recommended), enter the g command, the target machine is disconnected, and the control is handed over to gdb on the Host machine. (Add a line alias g = 'echo g>/proc/sysrq-trigger' to. bashrc in the root user directory of the target machine ')
5. in gdb on the Host machine
(Gdb) set-mod-break
Set breakpoint in system module init function
Breakpoint 1 at 0xc014bac5: file kernel/module. c, line 2288.
(Gdb) c
Continuing.
6. on the target machine
Insmod klogger2.ko
When the target machine is disconnected again, the control is transferred to gdb on the Host machine.
[1] [2] Next page