mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-28 12:34:26 +01:00
readme ++
This commit is contained in:
17
README.md
17
README.md
@@ -1,6 +1,6 @@
|
|||||||
# Linux Kernel Module Cheat
|
# Linux Kernel Module Cheat
|
||||||
|
|
||||||
Run one command, get into QEMU Buildroot BusyBox with several minimal Linux kernel 4.9 module example tutorials. Tested in Ubuntu 14.04 host.
|
Run one command, get into QEMU Buildroot BusyBox with several minimal Linux kernel 4.9 module example tutorials. Tested in Ubuntu 14.04 - 16.10 hosts.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -17,6 +17,15 @@ QEMU opens up, and you can run:
|
|||||||
rmmod hello
|
rmmod hello
|
||||||
rmmod hello2
|
rmmod hello2
|
||||||
|
|
||||||
|
This should print to the screen:
|
||||||
|
|
||||||
|
hello init
|
||||||
|
hello2 init
|
||||||
|
hello cleanup
|
||||||
|
hello2 cleanup
|
||||||
|
|
||||||
|
which are `printk` messages from `init` and `cleanup` methods of those modules.
|
||||||
|
|
||||||
Each module comes from a C file under `kernel_module/`. For module usage do:
|
Each module comes from a C file under `kernel_module/`. For module usage do:
|
||||||
|
|
||||||
head *. use Buildroot's default kernel version, you can confirm it after build with:
|
head *. use Buildroot's default kernel version, you can confirm it after build with:
|
||||||
@@ -37,11 +46,11 @@ See also: <https://superuser.com/questions/351387/how-to-stop-kernel-messages-fr
|
|||||||
|
|
||||||
## Debugging
|
## Debugging
|
||||||
|
|
||||||
GDB the linux kernel:
|
To GDB the Linux kernel, first run:
|
||||||
|
|
||||||
./runqemu -d
|
./runqemu -d
|
||||||
|
|
||||||
If you want to break immediately at a symbol, e.g. `start_kernel` of the boot sequence, open another terminal and run for example:
|
If you want to break immediately at a symbol, e.g. `start_kernel` of the boot sequence, open another terminal and run:
|
||||||
|
|
||||||
./rungdb start_kernel
|
./rungdb start_kernel
|
||||||
|
|
||||||
@@ -72,6 +81,8 @@ And now you can control the counting from GDB:
|
|||||||
continue
|
continue
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
See also: <http://stackoverflow.com/questions/11408041/how-to-debug-the-linux-kernel-with-gdb-and-qemu>
|
||||||
|
|
||||||
## Text mode
|
## Text mode
|
||||||
|
|
||||||
Show serial output of QEMU directly on the current terminal, without opening a QEMU window:
|
Show serial output of QEMU directly on the current terminal, without opening a QEMU window:
|
||||||
|
|||||||
Reference in New Issue
Block a user