开发者

kernel stack trace while carrying out specific command

while typing a comm开发者_运维问答and like #ifconfig 10.0.0.10 up is it possible to see all "possible" prints inside kernel.

I know something like echo t > /proc/sysrq-trigger will give you stack trace with respect to processes running in a system. What I am interested in is, with respect to a 'specific command' how can I get the kernel functions(stack trace) that gets executed?

I know about debuggers like kgdb,but I am interested in quick ways like sysrq methods if any.

Thanks.


The answer to your question is "ftrace". It is not a tool, not a command, but just a kernel feature built into most modern linux kernel.

For example, here you can use ftrace to understand how swap space are implemented (see all the key functions executed and its sequence inside the pastebin files indicated below):

http://tthtlc.wordpress.com/2013/11/19/using-ftrace-to-understanding-linux-kernel-api/

Read this carefully and you can see there are many ways of using ftrace (one is dump kernel stack trace which you requested, another is identifying executed function flow):

http://lwn.net/Articles/366796/

If you don't want to use ftrace, another option is to use QEMU: installing Linux inside the qemu guest is needed, and it is a lot more powerful, as you can use gdb to step through every lines (in C source code) or assembly.

https://tthtlc.wordpress.com/2014/01/14/how-to-do-kernel-debugging-via-gdb-over-serial-port-via-qemu/

Just in case you want to google further, this is called "kgdb", or gdbserver, and outside the qemu you are running a gdb client.


tail -f /var/log/kern.log should display any interaction that occurrs in the kernel.
It is more or less an equivalent to the dmesg command.


strace ifconfig 10.0.0.10 up will show all system calls called by ifconfig, but will not get inside kernel's calls

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜