KGTP 介绍

KGTP 是一个能在产品系统上实时分析 Linux 内核和应用程序(包括 Android)问题的全面动态跟踪器。 使用 KGTP 不需要 在 Linux 内核上打 PATCH 或者重新编译,只要编译 KGTP 模块并insmod 就可以。 其让 Linux 内核提供一个远程 GDB 调试接口,于是在本地或者远程的主机上的 GDB 可以在不需要停止内核的情况下用 GDB tracepoint 和其他一些功能调试和跟踪Linux内核和应用程序。

Github

https://github.com/teawater/kgtp

在上面有帮助手册,也可以点击这里查看帮助手册。

本文目的

在Qemu模拟的vexpress板子上面体验KGTP

软件版本

Linux 4.10

Qemu-2.8

ARM-Versatile Express

arm-none-linux-gnueabi 4.8.3

正文

一、交叉编译gdb

请参考博客 http://www.cnblogs.com/pengdonglin137/p/7093417.html

编译完成后,将生成的gdb可执行程序拷贝到板子上

二、重新编译kernel,打开相关的配置

要编译kgtp的话,需要打开下面的几个配置:

General setup --->[*] Kprobes[*] Enable loadable module support --->
Kernel hacking --->Compile-time checks and compiler options  ---> [*] Compile the kernel with debug info[*] Tracers  --->[*]   Enable uprobes-based dynamic events

使能上面的配置后,重新编译kernel。

三、交叉编译KGTP

目前KGTP在Linux-4.10上还无法直接编译通过,需要稍作修改,修改后的kgtp我上传到了github,可以使用下面的命令下载:

git clone git@github.com:pengdonglin137/kgtp.git -b  aarch32_version

下载完成后,需要对Makefile稍作修改,将其中的INSTALL、KERNELDIR以及OUT

使用下面的命令编译

make
make install

然后将生成的可执行程序以及ko文件拷贝到板子上

四、测试

1、本地测试

我们将编译出的vmlinux拷贝到板子上,加载gtp.ko,直接在板子上运行GDB,然后连接GTP,开始测试:

# 在PC机上将vmlinux拷贝到NFS共享目录下
cp /home/pengdonglin/src/qemu/aarch32/linux-4.10/out_aarch32/vmlinux /nfsroot/# 进入板子,挂载共享目录
[root@vexpress ]# mount -t nfs -o nolock 192.168.1.100:/nfsroot /mnt# 加载驱动
[root@vexpress ]# insmod /mnt/install/modules/gtp.ko # 运行gdb
[root@vexpress ]# gdb
GNU gdb (GDB) 8.0
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-none-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".# 加在vmlinux
(gdb) file /mnt/vmlinux
Reading symbols from /mnt/vmlinux...done.# 将gdb连接到gtp上
(gdb) target remote /sys/kernel/debug/gtp
Remote debugging using /sys/kernel/debug/gtp

#打印jiffies_64变量
(gdb) p jiffies_64
$1 = 4294969128
(gdb) p jiffies_64
$2 = 4294969245
(gdb) p jiffies_64
$3 = 4294969332
(gdb) p jiffies_64
$4 = 4294969419
(gdb) 

可以看到,jiffies_64的值一直在递增。

2、远程测试

在PC上运行GDB,连接板子上的GTP,开始调试:

在板子上运行nc命令:nc -l -p 2345 < /sys/kernel/debug/gtp > /sys/kernel/debug/gtp 之后,nc会在那里等待连接。在PC上运行GDB:$arm-none-linux-gnueabi-gdb ./vmlinux
GNU gdb (Sourcery CodeBench Lite 2014.05-29) 7.7.50.20140217-cvs
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-pc-linux-gnu --target=arm-none-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://sourcery.mentor.com/GNUToolchain/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./vmlinux...done.
# 连接板子上的GTP
(gdb) target remote 192.168.1.2:2345
Remote debugging using 192.168.1.2:2345
0x00000000 in ?? ()# 查看jiffies_64的值
(gdb) p jiffies_64
$1 = 4295030342
(gdb) p jiffies_64
$2 = 4295030453
(gdb) p jiffies_64
$3 = 4295030536
(gdb) p jiffies_64
$4 = 4295030622
(gdb) 

完。

转载于:https://www.cnblogs.com/pengdonglin137/p/7094862.html

在qemu模拟的aarch32上使用kgtp相关推荐

  1. Ubuntu 上使用 qemu 模拟 Arm64 linux

    Ubuntu 上用 qemu 模拟 Arm64 linux 环境配置 1. 安装Arm64交叉编译工具链 2. 安装qemu 下载源码包 编译 编译Linux kernel 编译qemu 编译busy ...

  2. 下qemu模拟arm9_QEMU搭建树莓派环境

    0x01 最近树莓派被同学借去做毕设了,没有其他ARM平台供我研究,无奈之下只好尝试使用QEMU模拟raspbian,搭建过程比较繁琐,网上的教程有很多坑都没有指出,所以有了此文,给同样有兴趣做IoT ...

  3. QEMU模拟vexpress-a9 搭建Linux kernel运行环境

    众所周知,QEMU是一个可以模拟ARM架构的虚拟机,拥有高速.开源.跨平台.支持多种架构等优点.接下来,我们将使用QEMU模拟vexpress-a9,并在上面跑一个Linux kernel,为接下来的 ...

  4. 我是穷人,可以不买开发板了吗?---QEMU 模拟arm系统

    文章目录 序言 准备工作 QEMU开始 Linux内核 U-boot 的修改及编译 构建根文件系统 busybox配置安装 制作根文件系统 启动QEMU模拟arm开发板 出现的问题 结束语 序言 一直 ...

  5. 用QEMU模拟ARM开发板,搭建Linux kernel运行环境

    前言 有的时候我们想调试linux kernel或者linux应用程序,但是又没有硬件环境,这个时候可以选择用模拟器的方法,模拟出一个硬件环境. Android emulator Android系统的 ...

  6. 联发科cpu能装linux,是否可以使用qemu模拟MediaTek ARM处理器?

    我为MT6582 Build 了Linux kernel Cortex-A7(ARMv7-A) 在真实设备上这个内核工作 在QEMU中我跑完后有空白屏幕 我希望看到一些内核初始化消息但什么都没有 是否 ...

  7. qemu模拟arm64一直卡住不动

    qemu模拟arm64一直卡住不动 问题描述 运行qemu-system-aarch64后一直卡在那里不动,终端无信息输出 做过的尝试 解决方法 发现编译内核方法有问题 更新qemu到3.0解决问题 ...

  8. 为 QEMU ARM 仿真器编译 Linux 内核:QEMU 模拟 ARM 环境

    QEMU 是一套由法布里斯·贝拉(Fabrice Bellard)所编写的以 GPL 许可证分发源码的模拟处理器,在GNU/Linux 平台上使用广泛.简单来说,QEMU 是一个虚拟机,与常见的 Vm ...

  9. QEMU模拟FriendlyArm的Mini2440开发板

    这篇博文中主要从以下几点进行叙述: 1.Mini2440开发板和QEMU模拟器简介 2.编译适配Mini2440的QEMU 3.Buildroot (2012.05)的使用 4.在QEMU中运行编译好 ...

最新文章

  1. Task01:青少年软件编程(Scratch)等级考试模拟卷(二级)
  2. 课堂上我们为什么不发言
  3. Docker 下安装 Spark
  4. gdb调试: 多线程-宏-条件断点
  5. Sublime Text 3 中文乱码的解决方法
  6. PHP中header用法详解带范例(转)
  7. 威马汽车否认接盘ST众泰:没有任何兴趣参与
  8. 如何成为一名牛逼Web前端开发人员?入行学习完整指南
  9. 第9章 互相作用的圆球 (《Python趣味创意编程》教学视频)
  10. 搭建java框架写CRD_硬核:如何开发一个Operator
  11. 数据质量管理有哪些方法
  12. 在 Ubuntu 和 Linux Mint 上释放空间的9种简单方法
  13. 判断一个变量是否在一个数组里
  14. urlrewrite java_Java中URL重写(urlrewrite+Maven)
  15. 【好用的压缩软件7-zip】
  16. linux 查看磁盘实际空间,如何运用linux查看磁盘总空间
  17. PS:成功解决点击PS中的裁剪工具时,整张图片消失掉或者整张图片变的及其小的问题
  18. (莱昂氏unix源代码分析导读-19)再谈进程swtch
  19. 生活妙语--智慧语言
  20. IT能力框架(模型)

热门文章

  1. 保留索引,cdh更新schema.xml
  2. listview改变选中行字体颜色
  3. Linux程序前台后台切换
  4. javascript判断输入的值是不是正整数
  5. 增加自增列 耗时长_又一批长事务,P0故障谁来背锅?
  6. Matlab中fileter和conv的区别及卷积的计算方法
  7. MFCC+DTW做声纹识别
  8. 从源码分析DEARGUI之draw的一系列操作
  9. App Store上微信的评论地址
  10. python进程间通信的秘密