kgtp linux内核调试

摘要:
作者:朱辉开源网站:https://github.com/teawaterhttp://teawater.github.io/kgtp/有一个中文版本的描述内核编译:Generalsetup--˃[*]提示开发和/或completecode/drivers[*]KrobeKernel hacking--˃[*]使用调试编译内核

作者:朱辉 

开源网址:https://github.com/teawater

                    http://teawater.github.io/kgtp/      有中文版说明

内核编绎:

General setup  --->
     [ * ] Prompt fordevelopment and/or incomplete code/drivers
     [ * ] Kprobe
Kernel hacking  --->
     [ * ] Compile the kernel with debug info
     [ * ] Compile the kernel with frame pointers
 
 
gdb版本:
 
 KGTP_NEED_GDB_VERSION = 7.6

KGTP_INSTALL_GDB = "gdb-7.7"

1.编绎

 

tar -zxvf kgtp-20140510.tar.gz

[root@localhost kgtp-20140510]# ls add-ons gtp_2.6.20_to_2.6.32.patch gtp_rb.c plugin_example.c dkms.conf gtp_2.6.33_to_2.6.38.patch kgtpcn.odt putgtprsp.c dkms_others_install.sh gtp_2.6.39.patch kgtpcn.pdf README.md dkms_others_uninstall.sh gtp_3.0_to_3.6.patch kgtp.odt ring_buffer.c getframe.c gtp_3.7_to_upstream.patch kgtp.pdf ring_buffer.h getgtprsp.pl gtp.c kgtp.py UPDATE getmod.c gtp.h Makefile getmod.py gtp_older_to_2.6.19.patch perf_event.c
[root@localhost kgtp
-20140510]# make make CROSS_COMPILE= -C /lib/modules/2.6.32/build/ M=/root/kgtp-20140510 modules make[1]: Entering directory `/usr/src/kernels/linux-2.6.32' CC [M] /root/kgtp-20140510/gtp.o /root/kgtp-20140510/gtp.c:132:2: warning: #warning "Current Kernel is too old. Function of performance counters is not available." /root/kgtp-20140510/gtp.c:168:2: warning: #warning "Cannot trace user program because the Linux Kernel that older than 3.9 doesn't support UPROBES." /root/kgtp-20140510/gtp_rb.c: In function ‘gtp_rb_walk’: /root/kgtp-20140510/gtp_rb.c:337: warning: ‘step’ may be used uninitialized in this function /root/kgtp-20140510/gtp.c:132:2: warning: #warning "Current Kernel is too old. Function of performance counters is not available." /root/kgtp-20140510/gtp.c:168:2: warning: #warning "Cannot trace user program because the Linux Kernel that older than 3.9 doesn't support UPROBES." Building modules, stage 2. MODPOST 1 modules CC /root/kgtp-20140510/gtp.mod.o LD [M] /root/kgtp-20140510/gtp.ko make[1]: Leaving directory `/usr/src/kernels/linux-2.6.32' gcc -O2 -static -o getmod getmod.c gcc -O2 -static -o getframe getframe.c gcc -O2 -static -o putgtprsp putgtprsp.c

 2.insmod   gtp.ko

3.  mount -t sysfs none /sys/

     mount   -t  debugfs none  /sys/kernel/debug/

 

4. cd  /usr/src/kernels/linux-2.6.32    进入源代码目录

5.gdb vmlinux   

6.(gdb) target remote /sys/kernel/debug/gtp

7. 调试内核

(gdb) trace vfs_readdir     跟踪涵数名
Tracepoint 1 at 0xffffffff810d751f: file fs/readdir.c, line 23.
-------------------------------------------------------------------- (gdb) actions 设轩预到跟踪点进行收集信息
Enter actions
for tracepoint 1, one per line. End with a line saying just "end".
> collect jiffies_64 > collect file->f_path.dentry->d_iname > end
------------------------------------------------------------------------------------------- (gdb) tstart 开始跟踪
-------------------------------------------------------------------------------------------- (gdb) shell ls :跟踪ls arch Documentation init MAINTAINERS net security virt block drivers ipc Makefile README sound vmlinux COPYING firmware Kbuild mm REPORTING
-BUGS System.map vmlinux.o CREDITS fs kernel modules.order samples tools crypto include lib Module.symvers scripts usr
---------------------------------------------------------------------------------------------- (gdb) tstop 停止跟踪
------------------------------------------------------------------------------------------------- (gdb) tfind #
0 vfs_readdir (file=0xffff88003c087480, filler=0xffffffff810d7468 <filldir>, buf=0xffff88004884df38) at fs/readdir.c:23 23 { (gdb) p jiffies_64 $1 = 4297940608 (gdb) p file->f_path.dentry->d_iname $2 = "/

免责声明:内容来源于网络,仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇【JS笔记】5.2 Array类型sde 安装下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

SecureCRT连接linux设置vim显示颜色

只需要两个步骤: 1) 选项 --> 会话选项 --> 终端 --> 仿真 --> 勾选“ANSI 颜色”。 2) 在.bashrc中添加:export TERM=xterm 可用如下命令: [root@host1 conf]# echo "export TERM=xterm" >> ~/.bashrc [root@...

Linux下Apache配置HTTPS功能

Apache配置HTTPS功能转https://www.cnblogs.com/liaojiafa/p/6028816.html 一、yum 安装openssl和openssl-devel,httpd-devel 二、生成证书(也可以从公司的证书颁发机构获取): #建立服务器密钥 openssl genrsa -des3 1024 > /...

pycharm远程上传文件到Linux

配置远程SFTP 1. 在PyCharm中打开SFTP配置面板,路径为Tools => Deployment => Configuration: 2. 配置Connection参数设置,填写远程服务器域名或者IP地址及用户名密码后,点击Test按钮进行连接测试,另外可以点击Autodetect按钮自动关联root path: 3. 配置Ma...

linux上如何让other用户访问没有other权限的目录

目前遇到一个问题,一个other用户要访问一个目录,他需要在这个目录下创建文件,因此这个目录需要一个写权限,于是就给了这个目录777的权限,这样这个权限有点太大了,很容易出现安全问题,那我们应该怎么办呢。 我们先来看为什么一定要给这个目录777的权限呢?例如这个other用户为lbh,这个目录为/home/tmp_test/。我们在/home目录下创建tm...

Linux 线程占用CPU过高定位分析

今天朋友问我一个Linux程序CPU占用涨停了,该如何分析, CPU占用过高,模拟CPU占用过高的情况 先上一段代码: 1 #include <iostream> 2 #include <thread> 3 #include <vector> 4 5 6 int main(int argc, char *...

linux环境下排查cpu占比高的MySQL数据库sql语句

自MySQL 5.7版本后,PERFORMANCE_SCHEMA.THREADS表中新增一个字段THREAD_OS_ID,对应操作系统中的线程ID 1.安装sysstat工具包(为了使用pidstat命令),更多信息参考: https://www.linuxidc.com/Linux/2019-08/160082.htm Ubuntu: apt-get i...