Linux内核实时调试,是怎么做的,用的什么工具? [英] Linux kernel live debugging, how it's done and what tools are used?

查看:18
本文介绍了Linux内核实时调试,是怎么做的,用的什么工具?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于在 Linux 内核上进行实时调试的最常见的方法和工具是什么?为什么不是不常用的方法和工具?我知道 Linus 例如.是反对这种Linux内核调试,或者至少是和因此,那些年在这个意义上没有做太多事情,但老实说,自 2000 年以来已经过去了很多时间,我很感兴趣关于 Linux 项目的心态是否发生了变化以及当前使用哪些方法在 Linux 内核上进行实时调试目前(本地或远程)?

What are the most common and why not uncommon methods and tools used to do live debugging on the Linux kernel? I know that Linus for eg. is against this kind of debugging for the Linux Kernel or it least was and thus nothing much has been done in that sense in those years, but honestly a lot of time has passed since 2000 and i am interested if that mentality has changed regarding the Linux project and what current methods are used to do live debugging on the Linux kernel at the moment(either local or remote)?

欢迎参考上述技术和工具的演练和教程.

References to walkthroughs and tutorials on mentioned techniques and tools are welcome.

推荐答案

另一种选择是使用 ICE/JTAG 控制器和 GDB.这种硬件"解决方案特别适用于嵌入式系统,

Another option is to use ICE/JTAG controller, and GDB. This 'hardware' solution is especially used with embedded systems,

但例如 Qemu 提供了类似的功能:

but for instance Qemu offers similar features:

  • 用 gdb 'remote' stub 启动 qemu,它监听 'localhost:1234' : qemu -s ...,

然后使用 GDB 打开内核文件 vmlinux 编译的调试信息(您可以查看 这个 邮件列表线程,他们讨论内核的未优化.

then with GDB you open the kernel file vmlinux compiled with debug information (you can take a look a this mailing list thread where they discuss the unoptimization of the kernel).

连接GDB和Qemu:target remote localhost:1234

connect GDB and Qemu: target remote localhost:1234

查看您的实时内核:

(gdb) where
#0  cpu_v7_do_idle () at arch/arm/mm/proc-v7.S:77
#1  0xc0029728 in arch_idle () atarm/mach-realview/include/mach/system.h:36
#2  default_idle () at arm/kernel/process.c:166
#3  0xc00298a8 in cpu_idle () at arch/arm/kernel/process.c:199
#4  0xc00089c0 in start_kernel () at init/main.c:713

不幸的是,到目前为止,使用 GDB 无法进行用户空间调试(没有任务列表信息,没有 MMU 重新编程以查看不同的进程上下文,...),但是如果您留在内核空间,那将非常方便.

unfortunately, user-space debugging is not possible so far with GDB (no task list information, no MMU reprogramming to see different process contexts, ...), but if you stay in kernel-space, that's quite convenient.

  • infothreads 会给你不同CPUs
  • 的列表和状态
  • info threads will give you the list and states of the different CPUs

您可以在此 PDF 中获取有关该过程的更多详细信息:

You can get more details about the procedure in this PDF:

使用 GDB 和 QEMU 调试 Linux 系统.

这篇关于Linux内核实时调试,是怎么做的,用的什么工具?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆