免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1003 | 回复: 0
打印 上一主题 下一主题

写篇文档给想要使用kgdb调试kernel或者driver module的新手 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-10-20 15:47 |只看该作者 |倒序浏览

Who may read this document?
===========================
1. People who familiar with gdb but not never use kgdb
2. People who like to debug kernel or driver module using the gdb way.
Why to Using KGDB
=================
1. Want to debug kernel
2. Want to debug driver module
What’s hardware you needed to use KGDB
=======================================
1. Target system with have serial port
2. Host system with have serial port
3. Serial line
How to Debug Kernel using KGDB
==============================
1. Download kgdb patch for your kernel at
http://kgdb.linsyssoft.com/downloads

2. Host: cd /path/to/kernel/source/
3. Host: patch –p1 –i /path/to/patch/file
4. Host: make menuconfig, to confirm you choose kgdb support in KERNEL_HACKING
5. Host: make dep;make bzImage
6. Copy built bzImage to your target system.
7. Target: boot your target using the built bzImage with gdb gdbttyS=x gdbbaud=38400
you may add these parameters to your grub menu. Here ‘x’ is the index of your serial port used to connect your host such as 0,1 or 2.
8. Host: cd /path/to/kernel/source
9. Host: gdb vmlinux
10. Host gdb: set remotebaud 38400
11. Host gdb: target remote /dev/ttySx. Here ‘x’ is the index of your serial port used to connect your target.
How to Debug Driver Module using KGDB
=====================================
1. Host: build your driver module with –g option.
2. Copy your driver.o to your target system.
3. Reboot target with kernel build in kgdb.
4. Host gdb: Set breakpoint before kernel call module’s initialization function so we can debug module’s initialization function.
Kernel call module’s initialization in kernel/module.c: sys_init_module():mod->init().
5. Target: load your driver module using insmod and will stop at breakpoint set by 4.
6. Host gdb: p/x module_list
7. Host gdb: add-symbol-file /path/to/your/driver/module/sourcecode address
where address is the value of module_list+sizeof(module_list).
This command loads symbol file of your module so you can debug it.
8. As 7 have add the symbol file of your module, so you can set breakpoints to your source code such as module’s init function and enjoy the debugging.


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/16013/showart_187982.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP