kgtp linux内核调试
作者:朱辉
开源网址:https://github.com/teawater
http://teawater.github.io/kgtp/ 有中文版说明
内核编绎:
General setup ---> [ * ] Prompt for development and/or incomplete code/drivers [ * ] KprobeKernel hacking ---> [ * ] Compile the kernel with debug info [ * ] Compile the kernel with frame pointers1.编绎
tar -zxvf kgtp-20140510.tar.gz [root@localhost kgtp-]# ls
add-ons gtp_2..20_to_2.6.32.patch gtp_rb.c plugin_example.c
dkms.conf gtp_2..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..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-]# make
make CROSS_COMPILE= -C /lib/modules/2.6./build/ M=/root/kgtp- modules
make[]: Entering directory `/usr/src/kernels/linux-2.6.'
CC [M] /root/kgtp-/gtp.o
/root/kgtp-/gtp.c::: warning: #warning "Current Kernel is too old. Function of performance counters is not available."
/root/kgtp-/gtp.c::: warning: #warning "Cannot trace user program because the Linux Kernel that older than 3.9 doesn't support UPROBES."
/root/kgtp-/gtp_rb.c: In function ‘gtp_rb_walk’:
/root/kgtp-/gtp_rb.c:: warning: ‘step’ may be used uninitialized in this function
/root/kgtp-/gtp.c::: warning: #warning "Current Kernel is too old. Function of performance counters is not available."
/root/kgtp-/gtp.c::: warning: #warning "Cannot trace user program because the Linux Kernel that older than 3.9 doesn't support UPROBES."
Building modules, stage .
MODPOST modules
CC /root/kgtp-/gtp.mod.o
LD [M] /root/kgtp-/gtp.ko
make[]: Leaving directory `/usr/src/kernels/linux-2.6.'
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 at 0xffffffff810d751f: file fs/readdir.c, line .
--------------------------------------------------------------------
(gdb) actions 设轩预到跟踪点进行收集信息
Enter actions for tracepoint , 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
# vfs_readdir (file=0xffff88003c087480, filler=0xffffffff810d7468 <filldir>,
buf=0xffff88004884df38) at fs/readdir.c:
{
(gdb) p jiffies_64
$ =
(gdb) p file->f_path.dentry->d_iname
$ = "/\000r", '\000' <repeats times>
(gdb) list vfs_readdir
#include <linux/unistd.h> #include <asm/uaccess.h> int vfs_readdir(struct file *file, filldir_t filler, void *buf)
{
struct inode *inode = file->f_path.dentry->d_inode;
int res = -ENOTDIR;
if (!file->f_op || !file->f_op->readdir)
goto out;
(gdb) disassemble /m vfs_readdir
Dump of assembler code for function vfs_readdir:
{
0xffffffff810d751f <vfs_readdir+>: push %r15
0xffffffff810d7521 <vfs_readdir+>: mov %rdx,%r15
0xffffffff810d7524 <vfs_readdir+>: push %r14
0xffffffff810d7526 <vfs_readdir+>: mov %rsi,%r14
0xffffffff810d7529 <vfs_readdir+>: push %r13
0xffffffff810d752b <vfs_readdir+>: push %r12
0xffffffff810d752d <vfs_readdir+>: push %rbp
0xffffffff810d752e <vfs_readdir+>: mov %rdi,%rbp
0xffffffff810d7531 <vfs_readdir+>: push %rbx
0xffffffff810d7532 <vfs_readdir+>: sub $0x8,%rsp struct inode *inode = file->f_path.dentry->d_inode;
0xffffffff810d7536 <vfs_readdir+>: mov 0x18(%rdi),%rax
0xffffffff810d753a <vfs_readdir+>: mov 0x10(%rax),%r12 int res = -ENOTDIR;
if (!file->f_op || !file->f_op->readdir)
0xffffffff810d753e <vfs_readdir+>: mov 0x20(%rdi),%rax
---Type <return> to continue, or q <return> to quit---
0xffffffff810d7542 <vfs_readdir+>: test %rax,%rax
0xffffffff810d7545 <vfs_readdir+>: je 0xffffffff810d75b3 <vfs_readdir+>
0xffffffff810d7547 <vfs_readdir+>: cmpq $0x0,0x30(%rax)
0xffffffff810d754c <vfs_readdir+>: je 0xffffffff810d75b3 <vfs_readdir+> goto out; res = security_file_permission(file, MAY_READ);
0xffffffff810d754e <vfs_readdir+>: mov $0x4,%esi
0xffffffff810d7553 <vfs_readdir+>: callq 0xffffffff8113848d <security_file_permission>
0xffffffff810d755a <vfs_readdir+>: mov %eax,%ebx if (res)
0xffffffff810d7558 <vfs_readdir+>: test %eax,%eax
0xffffffff810d755c <vfs_readdir+>: jne 0xffffffff810d75b8 <vfs_readdir+> goto out; res = mutex_lock_killable(&inode->i_mutex);
0xffffffff810d755e <vfs_readdir+>: lea 0xb8(%r12),%r13
---Type <return> to continue, or q <return> to quit---
0xffffffff810d7566 <vfs_readdir+>: mov %r13,%rdi
0xffffffff810d7569 <vfs_readdir+>: callq 0xffffffff812f4bff <mutex_lock_killable>
0xffffffff810d7570 <vfs_readdir+>: mov %eax,%ebx if (res)
0xffffffff810d756e <vfs_readdir+>: test %eax,%eax
0xffffffff810d7572 <vfs_readdir+>: jne 0xffffffff810d75b8 <vfs_readdir+> goto out; res = -ENOENT;
if (!IS_DEADDIR(inode)) {
0xffffffff810d7574 <vfs_readdir+>: testb $0x10,0x220(%r12)
0xffffffff810d757d <vfs_readdir+>: mov $0xfffffffe,%ebx
0xffffffff810d7582 <vfs_readdir+>: jne 0xffffffff810d75a9 <vfs_readdir+> res = file->f_op->readdir(file, buf, filler);
0xffffffff810d7584 <vfs_readdir+>: mov 0x20(%rbp),%rax
0xffffffff810d7588 <vfs_readdir+>: mov %r14,%rdx
0xffffffff810d758b <vfs_readdir+>: mov %r15,%rsi
---Type <return> to continue, or q <return> to quit---
0xffffffff810d758e <vfs_readdir+>: mov %rbp,%rdi
0xffffffff810d7591 <vfs_readdir+>: callq *0x30(%rax)
0xffffffff810d7598 <vfs_readdir+>: mov %eax,%ebx file_accessed(file);
}
mutex_unlock(&inode->i_mutex);
0xffffffff810d75a9 <vfs_readdir+>: mov %r13,%rdi
0xffffffff810d75ac <vfs_readdir+>: callq 0xffffffff812f4a35 <mutex_unlock>
0xffffffff810d75b1 <vfs_readdir+>: jmp 0xffffffff810d75b8 <vfs_readdir+> out:
0xffffffff810d75b3 <vfs_readdir+>: mov $0xffffffec,%ebx return res;
}
0xffffffff810d75b8 <vfs_readdir+>: pop %rcx
0xffffffff810d75b9 <vfs_readdir+>: mov %ebx,%eax
0xffffffff810d75bb <vfs_readdir+>: pop %rbx
0xffffffff810d75bc <vfs_readdir+>: pop %rbp
---Type <return> to continue, or q <return> to quit---
0xffffffff810d75bd <vfs_readdir+>: pop %r12
0xffffffff810d75bf <vfs_readdir+>: pop %r13
0xffffffff810d75c1 <vfs_readdir+>: pop %r14
0xffffffff810d75c3 <vfs_readdir+>: pop %r15
0xffffffff810d75c5 <vfs_readdir+>: retq
http://www.cnblogs.com/ahuo/archive/2012/08/10/2632227.html
kgtp linux内核调试的更多相关文章
- Linux内核调试的方式以及工具集锦【转】
转自:https://blog.csdn.net/gatieme/article/details/68948080 版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原 ...
- Linux内核调试的方式以及工具集锦
原文:https://blog.csdn.net/gatieme/article/details/68948080 CSDN GitHubLinux内核调试的方式以及工具集锦 LDD-LinuxDev ...
- Linux内核调试方法总结【转】
转自:http://my.oschina.net/fgq611/blog/113249 内核开发比用户空间开发更难的一个因素就是内核调试艰难.内核错误往往会导致系统宕机,很难保留出错时的现场.调试内核 ...
- linux内核调试指南
linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级调试 ***第一部分:基础知识*** 总纲:内核世界的陷阱 源码阅读的陷阱 代码调试的陷阱 原理理解的陷阱 ...
- 【转】Linux内核调试方法总结
目录[-] 一 调试前的准备 二 内核中的bug 三 内核调试配置选项 1 内核配置 2 调试原子操作 四 引发bug并打印信息 1 BUG()和BUG_ON() 2 dump_sta ...
- Linux内核调试方法总结
Linux内核调试方法总结 一 调试前的准备 二 内核中的bug 三 内核调试配置选项 1 内核配置 2 调试原子操作 四 引发bug并打印信息 1 BUG()和BUG_ON() 2 ...
- Linux内核调试方法【转】
转自:http://www.cnblogs.com/shineshqw/articles/2359114.html kdb:只能在汇编代码级进行调试: 优点是不需要两台机器进行调试. gdb:在调试模 ...
- Linux内核调试 - 一般人儿我都不告诉他(一)【转】
转自:http://www.cnblogs.com/armlinux/archive/2011/04/14/2396821.html 悄悄地进入Linux内核调试(一) 本文基址:http://blo ...
- Linux内核调试技术——jprobe使用与实现
前一篇博文介绍了kprobes的原理与kprobe的使用与实现方式,本文介绍kprobes中的另外一种探測技术jprobe.它基于kprobe实现,不能在函数的任何位置插入探測点,仅仅能在函数的入口处 ...
随机推荐
- java基础67 JavaScript通过关系找节点、添加附件(网页知识)
1.通过关系找节点(父子关系,兄弟关系) 1.1.常用方法 parentNode:获取当前元素的父节点. childNodes:获取当前元素的所有下一级子元素 firstChild:获取当 ...
- Oracle学习笔记:decode函数
decode函数主要作用:将查询结果翻译成其他值(即以其他形式变现出来) 使用方法: SELECT DECODE(colunm_name,值1,翻译值1,值2,翻译值2……值n,翻译值n,缺省值) F ...
- Mac OS 下安装mysqlclient报“mysql_config not found”的解决
如问题所示,应该是你没有将mysql_config所在文件夹加入系统的PATH路径,解决方案下: 1.第一步找到你的mysql_config所在位置 1.1. 如果是直接安装mysql,所在位置应该是 ...
- 更快的速度、更好的服务——易普优APS云排程
众所周知软件执行效率受制于硬件性能,市面上的APS产品多为单机版本,企业要应用好APS,保证紧急插单.计划下发全程无忧,用户电脑硬件性能是不容忽视的一大瓶颈.APS的直接用户是车间管理人员.计划员,而 ...
- HTTP.Socket.TCP详解
这会没事,整理了一下HTTP,socket,TCP之间的关系与区别,我们在面试的时候应该会经常问到这方面的东西,那么什么是HTTP呢? HTTP属于老话题了,在项目中我们经常需要往服务端发POST或者 ...
- poj1970 The Game(DFS)
题目链接 http://poj.org/problem?id=1970 思路 题目的意思是判断五子棋棋局是否有胜者,有的话输出胜者的棋子类型,并且输出五个棋子中最左上的棋子坐标:没有胜者输出0. 这道 ...
- mac 用密钥远程登陆
window远程登陆命令:mstsc A为本地主机(即用于控制其他主机的机器) ;B为远程主机(即被控制的机器Server), 假如ip为192.168.60.110;A和B的系统都是Linux 在A ...
- 采用Post请求的方式提交参数并导出excel
一般情况下,我们都是采用get请求的方式导出excel.例如采用如下方式: var exportUrl = '/xxx;'; window.open(exportUrl); 导出excel所需的逻辑参 ...
- php中的PDO函数库详解
PHP中的PDO函数库详解 PDO是一个“数据库访问抽象层”,作用是统一各种数据库的访问接口,与mysql和mysqli的函数库相比,PDO让跨数据库的使用更具有亲和力:与ADODB和MDB2相比,P ...
- Web安全漏洞深入分析及其安全编码
摘自:http://blog.nsfocus.net/web-vulnerability-analysis-coding-security/ 超全Web漏洞详解及其对应的安全编码规则,包括:SQL注入 ...