Linux kernel module debugging

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.