Is there any method to debug Linux kerne开发者_如何学Gol module?
I am looking for a GUI based facility like the ones used for user processes?
If you can run your kernel in a virtual machine, VMware Workstation lets GDB attach to the VM to debug the running kernel. You can probably do the same with other VM platforms, though I'm not familiar with those.
There is also KGDB for debugging a kernel on bare hardware. You connect to the target computer over its serial port. I've used this a little, and it works, but VMware does it better. Modern kernels have merged KGDB into mainline, so you won't need to patch.
That doesn't fully answer your question, because GDB isn't exactly a GUI-based tool on its own. You'll have to find some GUI debugger that uses GDB's stub protocol for debugging or that wraps GDB with a usable interface.
Yes, if u want GUI, then virtualization and kgdb is needed. Eg, VirtualBox running linux with kernel module to be debugged, and host is another linux.
http://allmybrain.com/2010/04/29/debugging-linux-kernel-modules-with-virtualbox-and-kgdb/
I have done it for Linux and OpenSolaris, and I must say VirtualBox is really superb for understanding things happening in the kernel.
Don't know of any GUI based debug utility but so far what I've used from my SOC kernel perspective:
ftrace - Function tracer
Many docs and tutorials over internet. Some here and here official. Also videos on youtube from Steven Rostedt main author, developer, and maintainer of the tool.
You can also use ftrace_printk
messages instead of dev_dbg
, dev_err
and dev_*
familly (also better than default printk
).
Must enable those bellow when building the kernel
CONFIG_FUNCTION_TRACER
CONFIG_FUNCTION_GRAPH_TRACER
CONFIG_STACK_TRACER
CONFIG_DYNAMIC_FTRACE
Other option included is the KernelShark front-end for ftrace.
IPC Logging (Qualcomm Linux kernel)
Some modules are build using the ipc logging system. Enabled with CONFIG_IPC_LOGGING=y
on kernel build. And read from /sys/kernel/debug/ipc_logging/[module_name]
DMESG
Reading messages from buffer of the kernel logging (dmesg
) for the standard printk
family functions. Good also to enable CONFIG_MESSAGE_LOGLEVEL_DEFAULT=7
on kernel build.
精彩评论