Host机:一个装有Ubuntu12.04-x86-64的主机 linux
Target机:运行在vmware上的 Ubuntu12.04-server-x86-64 的Linux. ui
Target机器配置 spa
0.配置好VMware对外串口, 详情见:http://my.oschina.net/u/139611/blog/110052 .net
1. 下载源码到/usr/src/linux-source-3.2.0下, 解压. debug
2. make menuconfig 调试
3. 进入General setup,把Local version设置一下(-kgdb) server
4. 进入Kernel hacking,选"Compile the kernel with debug info"为* blog
5. 选"KGDB: kernel debugging with remote gdb"为* rem
6. 选"Write protect kernel read-only data structures"为空 (不然在断下来继续执行的时候可能会报错:Cannot remove breakpoints because program is no longer writable) get
7. 进入"KGDB: ... " 选"KGDB: use KGDB over the serial console"为*,选"KGDB: internal test suite“为空,不然kgdboc会注册不了
7. 保存,编译: make -j4 && make modules install && make install
8. 把vmliunux和System.map拷贝到host机器上
9. 修改/boot/grub/grub.cfg中menuentry为kgdb的项,在kernel后面添加参数: kgdboc=ttyS1,115200 kgdbwait
10. 重启,系统进入等待状态。
Host机:
1. 安装好GDB,配好串口等。
2.运行 socat TCP-LISTEN:5555,fork /tmp/ttyS1 & , 连接到vmware对外的串口文件
2. gdb vmlinux
3. 在GDB中:
(gdb) target remote 0:5555
就能够进入调试状态了
4: (gdb) c ,则target进入Linux系统
参考: http://blog.csdn.net/zhy1030/article/details/5096949