使用 KGDB 调试 Kernel On Red Hat Linux
1. KGDB 简介
2. KGDB 调试原理

3. KGDB 安装与配置
3.1 调试环境准备
3.1.1 通过物理串口线进行调试
3.1.2 通过网络接口进行调试
KGDB 也支持使用以太网接口作为调试器的连接端口。在对Linux内核应用补丁包时,需应用eth.patch补丁文件。配置内核时在Kernel hacking中选择 KGDB 调试项,配置 KGDB 调试端口为以太网接口,例如:
[*] KGDB : kernel debugging with remote gdbMethod for KGDB communication ( KGDB : On ethernet) --->( ) KGDB : On generic serial port (8250)(X) KGDB : On ethernet
另外使用eth0网口作为调试端口时,grub.list的配置如下:
title 2.6.7 KGDBroot (hd0,0)kernel /boot/vmlinuz-2.6.7- KGDB ro root=/dev/hda1 KGDB wait KGDB oe=@192.168.5.13/,@192.168. 6.13/
其他的过程与使用串口作为连接端口时的设置过程相同。
注意:尽管可以使用以太网口作为 KGDB 的调试端口,使用串口作为连接端口更加简单易行, KGDB 项目组推荐使用串口作为调试端口。
3.1.3 通过 VMware Workstation 搭建调试环境


[root@localhost ~]# stty ispeed 115200 ospeed 115200 -F /dev/ttyS1
[root@BendSha_RHEL5_5_x64 ~]# stty ispeed 115200 ospeed 115200 -F /dev/ttyS1
[root@localhost ~]# echo "this message come from bendsha">/dev/ttyS1[root@localhost ~]# echo "hoho">/dev/ttyS1
[root@BendSha_RHEL5_5_x64 ~]# cat /dev/ttyS1this message come from bendshahoho
3.2 安装与配置
3.2.1 内核的配置与编译
[root@localhost ~]# wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.bz2--2016-11-07 07:18:03-- ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.32.tar.bz2=> `linux-2.6.32.tar.bz2'Resolving ftp.kernel.org... 199.204.44.194, 198.145.20.140, 149.20.4.69Connecting to ftp.kernel.org|199.204.44.194|:21... connected.Logging in as anonymous ... Logged in!==> SYST ... done. ==> PWD ... done.==> TYPE I ... done. ==> CWD /pub/linux/kernel/v2.6 ... done.==> SIZE linux-2.6.32.tar.bz2 ... 64424138==> PASV ... done. ==> RETR linux-2.6.32.tar.bz2 ... done.Length: 64424138 (61M)0% [ ] 172,280 18.6K/s eta 54m 6s
[root@localhost linux-2.6.32]# make menuconfigscripts/kconfig/mconf arch/x86/Kconfig


[root@localhost linux-2.6.32]# make -j10 bzImage
[root@localhost linux-2.6.32]# make modules
[root@localhost src]# scp -r linux-2.6.32 192.168.117.129:/usr/srcThe authenticity of host '192.168.117.129 (192.168.117.129)' can't be established.RSA key fingerprint is 63:6c:22:cf:a8:55:a9:5a:ea:72:23:1d:56:5f:28:a0.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.117.129' (RSA) to the list of known hosts.root@192.168.117.129's password:
[root@BendSha_RHEL5_5_x64 src]# ln -s linux-2.6.36 linux[root@BendSha_RHEL5_5_x64 src]# cd linux[root@BendSha_RHEL5_5_x64 linux]# make modules_install......INSTALL /lib/firmware/keyspan_pda/xircom_pgs.fwDEPMOD 2.6.32[root@BendSha_RHEL5_5_x64 linux]# make installsh /usr/src/linux-2.6.32/arch/x86/boot/install.sh 2.6.32 arch/x86/boot/bzImage \System.map "/boot"[root@BendSha_RHEL5_5_x64 linux]#
[root@BendSha_RHEL5_5_x64 linux]# cd /boot/[root@BendSha_RHEL5_5_x64 boot]# lsconfig-2.6.18-194.el5 lost+found System.map-2.6.32grub message vmlinuzinitrd-2.6.18-194.el5.img symvers-2.6.18-194.el5.gz vmlinuz-2.6.18-194.el5initrd-2.6.18-194.el5kdump.img System.map vmlinuz-2.6.32initrd-2.6.32.img System.map-2.6.18-194.el5
[root@BendSha_RHEL5_5_x64 boot]# cat grub/grub.conf# grub.conf generated by anaconda## Note that you do not have to rerun grub after making changes to this file# NOTICE: You have a /boot partition. This means that# all kernel and initrd paths are relative to /boot/, eg.# root (hd0,0)# kernel /vmlinuz-version ro root=/dev/sda2# initrd /initrd-version.img#boot=/dev/sdadefault=1timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle CentOS (2.6.32)root (hd0,0)kernel /vmlinuz-2.6.32 ro root=LABEL=/ crashkernel=128M@16Minitrd /initrd-2.6.32.imgtitle Red Hat Enterprise Linux Server (2.6.18-194.el5)root (hd0,0)kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ crashkernel=128M@16Minitrd /initrd-2.6.18-194.el5.img
[root@BendSha_RHEL5_5_x64 grub]# vi grub.conf# grub.conf generated by anaconda## Note that you do not have to rerun grub after making changes to this file# NOTICE: You have a /boot partition. This means that# all kernel and initrd paths are relative to /boot/, eg.# root (hd0,0)# kernel /vmlinuz-version ro root=/dev/sda2# initrd /initrd-version.img#boot=/dev/sdadefault=1timeout=5splashimage=(hd0,0)/grub/splash.xpm.gzhiddenmenutitle CentOS (2.6.32)root (hd0,0)kernel /vmlinuz-2.6.32 ro root=LABEL=/ crashkernel=128M@16M kgdboc=ttyS1,115200initrd /initrd-2.6.32.imgtitle CentOS (2.6.32 kernel debug)root (hd0,0)kernel /vmlinuz-2.6.32 ro root=LABEL=/ crashkernel=128M@16M kgdboc=ttyS1,115200 kgdbwaitinitrd /initrd-2.6.32.imgtitle Red Hat Enterprise Linux Server (2.6.18-194.el5)root (hd0,0)kernel /vmlinuz-2.6.18-194.el5 ro root=LABEL=/ crashkernel=128M@16Minitrd /initrd-2.6.18-194.el5.img:
3.2.2 内核调试
重启Target,通过启动菜单第一项CentOS(2.6.32)进入系统:

[root@localhost src]# cd linux-2.6.32[root@localhost linux-2.6.32]# gdb vmlinuxGNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5)Copyright (C) 2009 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 "x86_64-redhat-linux-gnu".For bug reporting instructions, please see:<http://www.gnu.org/software/gdb/bugs/>...Reading symbols from /usr/src/linux-2.6.32/vmlinux...(no debugging symbols found)...done.(gdb) set remotebaud 115200(gdb) target remote /dev/ttyS1Remote debugging using /dev/ttyS1kgdb_breakpoint () at kernel/kgdb.c:17211721 wmb(); /* Sync point after breakpoint */(gdb)
[root@BendSha_RHEL5_5_x64 grub]# echo g > /proc/sysrq-trigger
使用 KGDB 调试 Kernel On Red Hat Linux的更多相关文章
- Red Hat Linux认证
想系统的学习一下Linux,了解了一些关于Red Hat Linux认证的信息.整理如下. 当前比较常见的是RHCE认证,即Red Hat Certified Engineer.最高级别的是RHCA ...
- Red hat Linux(Centos 5/6)安装R语言
Red hat Linux(Centos 5/6)安装R语言1 wget http://cran.rstudio.com/src/base/R-3/R-3.0.2.tar.gz2 tar xzvf R ...
- Red Hat linux 如何增加swap空间
按步骤介绍 Red Hat linux 如何增加swap空间 方法/步骤 第一步:确保系统中有足够的空间来用做swap交换空间,我使用的是KVM,准备在一个独立的文件系统中添加一个swap交换文件,在 ...
- 分享red hat linux 6上安装oracle11g时遇到的gcc: error trying to exec 'cc1': execvp: No such file or directory的问题处理过程
安装环境:Red Hat Linux 6.5_x64.oracle11g 64bit 报错详情: 安装到68%时弹窗报错: 调用makefile '/test/app/Administrators/p ...
- red hat Linux 使用CentOS yum源更新
red hat linux是商业版软件,没有经过注册是无法使用红帽 yum源更新软件的,使用CentOS源更新操作如下: 1.删除red hat linux 原有的yum 源 rpm -aq | gr ...
- Red Hat Linux 挂载外部资源
在我们安装的Red Hat Linux 中.当中一半机器为最主要的server配置,没有桌面环境.在从U盘上复制文件的时候可就犯难了.在网上查了查才知道.要訪问U盘就必须先将它们挂载到Linux系统的 ...
- FreeBSD 用kgdb调试kernel dump文件
FreeBSD 用kgdb调试kernel dump文件 来自: http://blog.csdn.net/ztz0223/article/details/8600052 kgdb貌似和ddb一样属于 ...
- red hat linux之Samba、DHCP、DNS、FTP、Web的安装与配置
本教程是在red hat linux 6.0环境下简单测试!教程没有图片演示,需要具有一定Linux基础知识,很多地方的配置需要根据自己的情况修改,照打不一定可以配置成功.(其他不足后续修改添加) y ...
- Red Hat Linux 安装 (本地、网络安装)
Red Hat Linux 安装 (本地.网络安装) 650) this.width=650;" onclick='window.open("http://blog.51cto.c ...
随机推荐
- [JSP]Maven+SSM框架(Spring+SpringMVC+MyBatis) - Hello World
来源:http://blog.csdn.net/zhshulin/article/details/37956105?utm_source=tuicool&utm_medium=referral ...
- Nuget版本冲突的问题
有两个类库项目,一个引用了比如Newtonsoft.Json 6.0, 另一个引用了比如Newtonsoft.Json 8.0, 然后另一个exe项目同时引用了这两个类库项目. 那么在编译的时候会报w ...
- python基础知识7——迭代器,生成器,装饰器
迭代器 1.迭代器 迭代器是访问集合元素的一种方式.迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束.迭代器只能往前不会后退,不过这也没什么,因为人们很少在迭代途中往后退.另外,迭代器 ...
- 常用的几个DOS批处理
1.启动ORACLE net start OracleServiceQSJBnet start OracleDBConsoleqsjbnet start OracleOraDb10g_home1TNS ...
- XtraBackup安装
1.从官网下载XtraBackup2.4.4. percona-xtrabackup-24-2.4.4-1.el6.x86_64.rpm 2.安装依赖包 yum -y install perl per ...
- [lucene系列笔记1]lucene6的安装与配置(Windows系统)
lucene是一个java开源的高效全文检索工具包,最近做项目要用到,把学习的过程记录一下. 第一步:下载安装jdk 1.首先从官网下载jdk(下载之前先查看你的电脑是多少位操作系统,如果是32就下载 ...
- Altium Designer PCB双面板制作打印操作步骤
Altium Designer PCB双面板制作打印操作步骤百度知道:http://jingyan.baidu.com/article/335530da83441c19cb41c3db.html?st ...
- mybatis组合模糊+分页查询
//组合模糊查询就是这么简单 <select id="findAllJiemu" parameterType="java.util.Map" result ...
- 我的 C++ style
int g_tennis; // not use as possible int make_world() { ; return size; } ; enum Color { RED, GREEN } ...
- 安全标识符SID技术介绍及查看技巧
说到安全标识符SID就要先说说安全主体(Security Principals),安全主体是一个能够对它分配权限的对象,例如,用户.组和计算机: 对于每一个Windows 200x域中的安全主体都有一 ...