Ubuntu 11.10 (Oneiric)上编译带utrace补丁的内核
首先准备linux内核编译环境:
patching file Documentation/DocBook/Makefilepatching file Documentation/DocBook/utrace.tmplpatching file arch/x86/kernel/ptrace.cpatching file fs/proc/array.cpatching file include/linux/ptrace.hpatching file include/linux/sched.hHunk #1 succeeded at 187 (offset 3 lines).Hunk #2 succeeded at 206 (offset 3 lines).Hunk #3 succeeded at 1415 with fuzz 2 (offset 7 lines).patching file include/linux/signal.hpatching file include/linux/tracehook.hpatching file include/linux/utrace.hpatching file init/KconfigHunk #1 succeeded at 388 (offset 16 lines).patching file kernel/Makefilepatching file kernel/fork.cHunk #1 FAILED at 168.Hunk #2 succeeded at 1098 (offset 3 lines).1 out of 2 hunks FAILED -- saving rejects to file kernel/fork.c.rejpatching file kernel/ptrace.cpatching file kernel/sched.cpatching file kernel/signal.cHunk #4 succeeded at 1993 (offset -2 lines).Hunk #5 succeeded at 2017 (offset -2 lines).Hunk #6 succeeded at 2124 (offset -2 lines).Hunk #7 succeeded at 2132 (offset -2 lines).patching file kernel/utrace.c?注意 kernel/fork.c 的补丁失败了,看看 kernel/fork.c.rej:
--- kernel/fork.c +++ kernel/fork.c @@ -168,6 +168,7 @@ free_thread_info(tsk->stack); rt_mutex_debug_task_free(tsk); ftrace_graph_exit_task(tsk); + tracehook_free_task(tsk); free_task_struct(tsk); } EXPORT_SYMBOL(free_task);修改 kernel/fork.c,在 free_task 函数的 ftrace_graph_exit_task(tsk); 之后手工加上这行 tracehook_free_task 调用即可。
编译完成后,在 linux-source-3.0.0/ 的上级目录会生成 linux-headers/image/debug-symbol 的 deb 安装包,直接用 sudo dpkg -i *.deb 安装即可。重启后选择新内核进入即可用 systemtap 进行用户态程序跟踪。
?
参考:
?