使用 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 gdb
- Method for KGDB communication ( KGDB : On ethernet) --->
- ( ) KGDB : On generic serial port (8250)
- (X) KGDB : On ethernet
另外使用eth0网口作为调试端口时,grub.list的配置如下:
- title 2.6.7 KGDB
- root (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/ttyS1
- this message come from bendsha
- hoho
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.69
- Connecting 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 menuconfig
- scripts/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/src
- The 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)? yes
- Warning: 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.fw
- DEPMOD 2.6.32
- [root@BendSha_RHEL5_5_x64 linux]# make install
- sh /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]# ls
- config-2.6.18-194.el5 lost+found System.map-2.6.32
- grub message vmlinuz
- initrd-2.6.18-194.el5.img symvers-2.6.18-194.el5.gz vmlinuz-2.6.18-194.el5
- initrd-2.6.18-194.el5kdump.img System.map vmlinuz-2.6.32
- initrd-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/sda
- default=1
- timeout=5
- splashimage=(hd0,0)/grub/splash.xpm.gz
- hiddenmenu
- title CentOS (2.6.32)
- root (hd0,0)
- kernel /vmlinuz-2.6.32 ro root=LABEL=/ crashkernel=128M@16M
- initrd /initrd-2.6.32.img
- title 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@16M
- initrd /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/sda
- default=1
- timeout=5
- splashimage=(hd0,0)/grub/splash.xpm.gz
- hiddenmenu
- title CentOS (2.6.32)
- root (hd0,0)
- kernel /vmlinuz-2.6.32 ro root=LABEL=/ crashkernel=128M@16M kgdboc=ttyS1,115200
- initrd /initrd-2.6.32.img
- title CentOS (2.6.32 kernel debug)
- root (hd0,0)
- kernel /vmlinuz-2.6.32 ro root=LABEL=/ crashkernel=128M@16M kgdboc=ttyS1,115200 kgdbwait
- initrd /initrd-2.6.32.img
- title 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@16M
- initrd /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 vmlinux
- GNU 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/ttyS1
- Remote debugging using /dev/ttyS1
- kgdb_breakpoint () at kernel/kgdb.c:1721
- 1721 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 ... 
随机推荐
- 计算机缺失缺少mfc110.dll等相关文件的解决办法
			去https://www.microsoft.com/zh-CN/download/details.aspx?id=30679下载 VSU4\vcredist_x64.exe 和VSU4\vcredi ... 
- 自己实现多线程的socket,socketserver源码剖析
			1,IO多路复用 三种多路复用的机制:select.poll.epoll 用的多的两个:select和epoll 简单的说就是:1,select和poll所有平台都支持,epoll只有linux支持2 ... 
- VUE 入门基础(1)
			一,安装 Vue.js 不支持 IE8 及其以下版本,因为 Vue.js 使用了 IE8 不能模拟的 ECMAScript 5 特性. Vue.js 支持所有兼容 ECMAScript 5 的浏览器. ... 
- Winform 五种常用对话框控件的简单使用
			OpenFileDialog(打开文件对话框)FolderBrowserDialog(浏览文件夹对话框)SaveFileDialog(保存文件对话框)ColorDialog(颜色选择对话框)FontD ... 
- Google V8编程详解(二)HelloWorld
			转自http://blog.csdn.net/feiyinzilgd/article/details/8248448 上一章讲到了V8的编译和安装,这一章开始从一个demo着手. 这里选用了官方文档的 ... 
- SQL SELECT SET
			SELECT SET 同时对多个变量同时赋值时 支持 不支持 表达式返回多个值时 将返回的最后一个值赋给变量 出错 表达式未返回值时 变量保持原值 变量被赋null值 
- String类的常用判断方法使用练习
			选取了一些常用的判断方法进行了使用练习,后续跟新其他方法 package StringDemo; // String类的判断方法解析 // 1:boolean equals(); // 判断字符串是否 ... 
- inline(内联)函数
			1,为小操作定义一个函数的好处是: a.可读性会强很多. b.改变一个局部化的实现比更改一个应用中的300个出现要容易得多 c.函数可以被重用,不必为其他的应用重写代码 ... 
- POJ 3624 Charm Bracelet(01背包)
			Charm Bracelet Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 34532 Accepted: 15301 ... 
- HTML之电话: 邮箱:  网址
			<p> 电话: <a href="tel:电话">电话</a> </p> <p> 邮箱: <a href=&quo ... 
