linux gdb 调试内核,Linux 内核学习(8)-GDB和bochs配合调试内核

开发环境: Ubuntu 11.10 + gcc 4.6.1 + bochs 2.6

1. http://bochs.sourceforge.net/ 上下载bochs

2.6的源代码包: bochs-2.6.tar.gz

2. 编辑bochs 2.6,加入--enable-gdb-stub选项以支持GDB调试

# ./configure --enable-gdb-stub

# make

# sudo make install

3. 以下为bochs 2.6的配置文件bochsrc-2.6-linux.bxrc,加入了gdbstub配置项

--------------------------------------------------------------------

gdbstub: enabled=1, port=1234, text_base=0, data_base=0,

bss_base=0

config_interface: textconfig

display_library: x

memory: host=32, guest=32

romimage: file=$BXSHARE/BIOS-bochs-latest

vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest-cirrus

boot: floppy

floppy_bootsig_check: disabled=0

floppya: type=1_44, 1_44="Image", status=inserted,

write_protected=0

4. 启动bochs, bochs会提示等待gdb连接

# bochs -qf bochsrc-2.6-linux.bxrc

a4c26d1e5885305701be709a3d33442f.png

5. 启动gdb

steve@steve-virtual-machine:/mnt/hgfs/my_git_project/linux-0.11/src$

gdb tools/system

GNU gdb (Ubuntu/Linaro 7.3-0ubuntu2) 7.3-2011.08

Copyright (C) 2011 Free Software Foundation, Inc.

License GPLv3+: GNU GPL version 3 or later

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 "i686-linux-gnu".

For bug reporting instructions, please see:

...

Reading symbols from

/mnt/hgfs/my_git_project/linux-0.11/src/tools/system...done.

(gdb) break main

Breakpoint 1 at 0x67f0: file init/main.c, line 110.

(gdb) target remote localhost:1234

Remote debugging using localhost:1234

0x0000fff0 in sys_unlink (name=0x0) at

namei.c:712

712 brelse(bh);

(gdb) cont

Continuing.

Breakpoint 1, main () at init/main.c:105

105 { (gdb)

注意在gdb中运行target remote

localhost:1234后,程序停在了0x0000fff0处,因为机器加电后CS:IP就指向0xF000:0xFFF0这个位置.

(gdb) x $cs

0xf000

: 0x00000000

a4c26d1e5885305701be709a3d33442f.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值