文章目录

  • 前言
    • 1.dis
    • 2.rd
    • 3.struct
    • 4.mod
    • 5.set
    • 6.task
    • 7.ps
    • 8.p
  • 总结
  • 参考资料

前言

在这篇文章中搭建了crash的调试环境,简单的描述了crash的使用:centos7 kdump、crash调试内核,接下来详细描述crash的功能,主要是调试系统正在运行的内核虚拟地址空间。

  crash [OPTION]... [NAMELIST]                          (live system form)

1.dis

disassembles memory, either entire kernel functions, from a location for a specified number of instructions, or from the start of a function up to a specified memory location.

反汇编整个内核函数,内存地址、从指定数量的指令的位置,或从函数的开始到指定的内存位置

cat /proc/kallsyms | grep '\<_text\>'
cat /proc/kallsyms | grep '\<startup_64\>'

_text是内核代码段的起始地址,也就是 startup_64 函数

(1)
反汇编整个函数:

dis startup_64


查看函数text_poke源码,所在文件,以及行数:

 dis -s text_poke
 -s  displays the filename and line number of the source code thatis associated with the specified text location, followed by asource code listing if it is available on the host machine.The line associated with the text location will be marked withan asterisk; depending upon gdb's internal "listsize" variable,several lines will precede the marked location. If a "count"argument is entered, it specifies the number of source codelines to be displayed after the marked location; otherwisethe remaining source code of the containing function will bedisplayed.

显示了函数text_poke在内核源码中哪个文件,行数,以及函数源码:

我与源码进行对比,内核版本3.10.0:

//arch/x86/kernel/alternative.c

(2)
分别从startup_64函数开始反汇编 一条指令,两条指令,三条指令

(3)
从startup_64函数指定的偏移位置开始反汇编

(4)
从指定内存地址开始反汇编

2.rd

 displays the contents of memory, with the output formatted in several different manners.
Enter "help rd" for details.

显示内存的内容,并以几种不同的方式格式化输出。
(1)
我用castone反汇编出来的三条跳转指令为例,包括其地址,操作码,操作数,和机器码。

分别从对应的内存地址读取32位,64位,16位内容进行对比机器码,经过对比机器码一样。

 -8  display output in 8-bit values.-16  display output in 16-bit values.-32  display output in 32-bit values (default on 32-bit machines).-64  display output in 64-bit values (default on 64-bit machines).


(2)
rd读取jiffies全局变量,显示其地址和值:

Read jiffies in hexadecimal and decimal format:


(3)

Read Linux version


3.struct

查看结构体成员:


查看结构体成员以及其各个成员的相对偏移位置:

 -o  show member offsets when displaying structure definitions;if used with an address or symbol argument, each member will be preceded by its virtual address.


(2)
查看packet套接字:

把指定地址的内容以 struct sock结构体解析打印:

include/linux/socket.h
#define AF_PACKET   17  /* Packet family        */
#define PF_PACKET   AF_PACKET

查看结构体成员以及其各个成员的绝对虚拟地址位置:

4.mod

查看已经加载的模块信息:

5.set



6.task

查看指定任务的task_struct和thread_thread信息


7.ps

查看活跃的进程:

查看用户态进程:

 -u  restrict the output to only user tasks.


查看内核态进程:

 -k  restrict the output to only kernel threads.


查看线程组中的线程组领导者:

 -G  display only the thread group leader in a thread group.Display only the thread group leader in the crash session:

查看进程的资源限制:

 -r  display resource limits (rlimits) of selected, or all, tasks.


查看进程的子进程:

 -c  display the children of selected, or all, tasks.


查看进程的父进程:

8.p

查看全局变量的值:

(1)

  Print the contents of jiffies


(2)

 Print the contents of the vm_area_struct "init_mm"


(3)

 If a per-cpu symbol is entered as a argument, its data type and all of its per-cpu addresses are displayed:

 To display the contents a per-cpu symbol for CPU 1, appenda cpu-specifier:

(4)打印TCP缓冲区参数


可以看到通过crash和/proc/sys/看到的全局变量值是一样的。

总结

通过help查看crash支持的命令:

对于每个命令的使用和说明可以用help查看:

参考资料

https://www.jianshu.com/p/ad03152a0a53
https://blog.csdn.net/KingOfMyHeart/article/details/98240185

Linux crash调试(一)相关推荐

  1. Linux内核调试方法总结【转】

    转自:http://my.oschina.net/fgq611/blog/113249 内核开发比用户空间开发更难的一个因素就是内核调试艰难.内核错误往往会导致系统宕机,很难保留出错时的现场.调试内核 ...

  2. Linux内核调试方法总结

    [转]Linux内核调试方法总结 目录[-] 一  调试前的准备 二  内核中的bug 三  内核调试配置选项 1  内核配置 2  调试原子操作 四  引发bug并打印信息 1  BUG()和BUG ...

  3. centos7 kdump、crash调试内核

    文章目录 前言 一.kdump 1.1 kdump定义 1.2 原理架构图 1.3 kdump配置 二.crash 2.1 crash简介 2.2 crash调试 vmcore 总结 参考资料 前言 ...

  4. Linux内核调试方法【转】

    转自:http://www.cnblogs.com/shineshqw/articles/2359114.html kdb:只能在汇编代码级进行调试: 优点是不需要两台机器进行调试. gdb:在调试模 ...

  5. 开源项目-基于Intel VT技术的Linux内核调试器

    本开源项目将硬件虚拟化技术应用在内核调试器上,使内核调试器成为VMM,将操作系统置于虚拟机中运行,即操作系统成为GuestOS,以这样的一种形式进行调试,最主要的好处就是调试器对操作系统完全透明.如下 ...

  6. linux 内核调试前准备(简单记录,以后补充)

    系统环境:centous7 (redhat的体系) 需要安装的软件:crash kdump kernel-debuginfo TODO: 1.自行编译内核生成 kernel-debuginfo 2.在 ...

  7. Linux内核调试 - 一般人儿我都不告诉他(一)【转】

    转自:http://www.cnblogs.com/armlinux/archive/2011/04/14/2396821.html 悄悄地进入Linux内核调试(一) 本文基址:http://blo ...

  8. linux内核调试技术 kprobe使用与实现

    Linux kprobes调试技术是内核开发者们专门为了便于跟踪内核函数执行状态所设计的一种轻量级内核调试技术.利用kprobes技术,内核开发人员可以在内核的绝大多数指定函数中动态的插入探测点来收集 ...

  9. 基于IntelVt技术的Linux内核调试器 - 2

    4 基于IntelVt技术的Linux内核调试器- 调试器设计与实现(2):调试核心 4.1反汇编引擎 如果说调试框架是一个调试器的灵魂,那么接口与反汇编引擎就是一个调试器的身体.我们在调试过程中是要 ...

最新文章

  1. Git 高级用法小抄
  2. t-SNE algorithm(t-分布邻域嵌入算法)
  3. 又发现一个关于R文件丢失的问题
  4. Android跨进程通信一 Messenger
  5. sap 事务代码跳过权限检查
  6. PM2.5检测 -- PMS7003 串口测试
  7. 什么是protobuf
  8. hbuilderx写Ajax,Hbuilder怎么使用ajax?求指教啊
  9. STM32工作笔记0097---OEM厂是什么意思
  10. 中南大学 10科学计算和 MATLAB 语言 矩阵变换
  11. IIS7下MP4视频无法加载解决方法
  12. 简易版的等待/唤醒方法(sleep,wait,await,park区别)适合面试回答
  13. MQ队列管理器_PMTS命令
  14. RS485通讯协议的应用
  15. ps色彩范围调暗图片局部
  16. 大数据时代个人隐私权保护机制构建与完善
  17. 核心交换机和普通交换机有何区别?
  18. 2018走出架构误区
  19. 惊爆:江民公司官方网站今日被黑
  20. MongoDB被黑记录

热门文章

  1. 电脑c盘数据迁移的方法
  2. 微信重磅功能更新!加好友按人数收费,视频号付费订阅、微信版“知乎”来了...
  3. 官方:2056名广西考生未按规定上传“软考报考材料”,逾期将取消资格
  4. 【联机对战】一张图看懂联机对战服务
  5. python计算矩阵对角线之和_Python练习实例38 | 求3*3矩阵主对角线元素之和
  6. android系统system镜像解包打包制作过程
  7. 西门子PLC远程监控与数据采集方案
  8. 云计算与大数据技术应用 第三章
  9. cc1101初始化c语言程序,STC89C52单片机驱动CC1101无线模块的接收C语言程序
  10. Noise2Noise摘要