首先准备linux内核编译环境:
- sudo apt-get install fakeroot build-essential crash kexec-tools makedumpfile kernel-wedge kernel-package
- sudo apt-get build-dep linux
- sudo apt-get install git-core libncurses5 libncurses5-dev libelf-dev asciidoc binutils-dev
检出带有utrace补丁的官方内核代码,并生成对应Ubuntu当前版本内核(3.0)的补丁:
- git clone https://github.com/utrace/linux.git utrace-linux-git
- cd utrace-linux-git/
- git checkout -b utrace-3.0 origin/utrace-3.0
- git diff v3.0 > /tmp/utrace.patch
获得Ubuntu定制内核代码,并打上utrace补丁
- sudo apt-get install linux-source
- tar xjf /usr/src/linux-source-3.0.0.tar.bz2
- cd linux-source-3.0.0/
- patch -p1 < /tmp/utrace.patch
输出为:
patching file Documentation/DocBook/Makefile
patching file Documentation/DocBook/utrace.tmpl
patching file arch/x86/kernel/ptrace.c
patching file fs/proc/array.c
patching file include/linux/ptrace.h
patching file include/linux/sched.h
Hunk #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.h
patching file include/linux/tracehook.h
patching file include/linux/utrace.h
patching file init/Kconfig
Hunk #1 succeeded at 388 (offset 16 lines).
patching file kernel/Makefile
patching file kernel/fork.c
Hunk #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.rej
patching file kernel/ptrace.c
patching file kernel/sched.c
patching file kernel/signal.c
Hunk #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 调用即可。
编译新的内核,使用当前系统内核的配置参数作为基准,开启 utrace 补丁提供的 CONFIG_UTRACE 功能即可:
- cp /boot/config-`uname -r` .config
-
make oldconfig ,出现如下提示时回答 y:Infrastructure for tracing and debugging user processes (UTRACE) [N/y/?] (NEW)
- make-kpkg clean
-
export CONCURRENCY_LEVEL=9 ,这里指定编译内核时的并发任务数,设置为核数+1即可
- fakeroot make-kpkg --initrd --append-to-version=-utrace binary-arch
编译完成后,在 linux-source-3.0.0/ 的上级目录会生成 linux-headers/image/debug-symbol 的 deb 安装包,直接用 sudo dpkg -i *.deb 安装即可。重启后选择新内核进入即可用 systemtap 进行用户态程序跟踪。
参考:
- https://help.ubuntu.com/community/Kernel/Compile#Alternate_Build_Method:_The_Old-Fashioned_Debian_Way
分享到:
相关推荐
Ubuntu 11.10 Oneiric安装Epiphany 3.2.0浏览器.docx
ubuntu 11.10下成功编译linux3.0.73
Ubuntu 11.10 搭建编译环境 这个都是deb包,直接上传运行就可以了 sudo dpkg -i *
android ubuntu 11.10 32 编译源码
ubuntu+11.10+安装过程详解 能快捷安装
ubuntu11.10环境搭建,tftp,nfs,samba,vmtool等的配置;
ubuntu11.10安装及网络配置,其中包括安装说明和网络配置两份文件
完全原创,Ubuntu 11.10系统安装,手把手带你安装每一步
Ubuntu 11.10 安装方法全程记录
ubuntu 11.10 设置固定ip,需要vi /etc/network/interfaces。
本文档介绍在windows7上使用Win7+Ubuntu11.10(EasyBCD硬盘安装)来安装双系统,需要的朋友可以下载看看
详细介绍了ubuntu的安装过程,并且附有安装过程的照片
默认的 ubuntu 安装后对本地化的支持是不完整的,这很正常,ubuntu 的软件工程师们已经替我们做了绝大部分的工作,我们需要做的只是一点点细小的工作,来使我们的 ubuntu 更利于使用。以下所有软件都可以通过在...
针对Ubuntu下乱码问题,提出以下解决方案,实测成功。
Ubuntu 11.10 H3C iNode 客户端 H3C iNode 客户端 for Ubuntu 11.10
VMware下安装Ubuntu 11.10 全程图解
ubuntu11.10安装教程及设置,本人自己照此安装,非常详细!
Ubuntu11.10 libxml2-dev 安装包 libxml2_2.7.8.dfsg-4_i386.deb libxml2-dev_2.7.8.dfsg-4_i386.deb python-libxml2_2.7.8.dfsg-4_i386.deb zlib1g_1.2.3.4.dfsg-3ubuntu3_i386.deb zlib1g-dev_1.2.3.4.dfsg-3...
ubuntu11.10 图文全攻略 linux
Ubuntu 11.10上删除Empathy的聊天记录.docx