配置VMWare远程调试FreeBSD9.2内核源代码

要学习FreeBSD内核源码,如果没有一个源码级的调试环境,很难入手,故记录下配置步骤:

###############################################################################

# 先配置好调试机的VMWare,然后复制一台:

点击VM->Clone
选中默认的From current state,点击Next
选中Create a full clone, 点击Next
Virtual Machine name 输入target,将克隆的机器命令为目标机

###############################################################################
# 分别为两个虚拟机增加一个串口,以"Output to named pipe"方式,其中:

调试机选择"this end is the client", "the other end is a virtual machine"
目标机选择"this end is the server", "the other end is a virtual machine"
备注: 两个pipe的名称要相同,并且选中下面的Connect at power on和Yield CPU on poll

###############################################################################
# 编译内核,参考<编译FreeBSD调试版内核>,把kernel.debug文件拷贝到目标机上
# 放到/boot/kernel/目录下,把旧的文件kernel命名为kernel.old
# 把kernel.debug命名为kernel,并使用以下命令去掉其中的调试符号:

strip -x kernel

###############################################################################
# 编辑目标机的/boot/device.hints文件,找到0号串口标志对应的行
# 为其增加0x80标志(旧版是sio,现在是uart),修改后该行如下(0x80|0x10=0x90):

hint.uart.0.flags="0x90"

###############################################################################
# 在调试机上cd到kernel.debug的目录,输入:


cd /usr/src/sys/amd64/compile/KERNELD

kgdb -r /dev/cuau0 kernel.debug

###############################################################################
# 重启目标机,在启动菜单中选择"Escape to loader prompt",会显示出下内容:
Type '?' for a list of commands, 'help' for more detailed help.
OK

# 输入:
boot -d

会出现以下内容:
GDB: debug ports: uart
GDB: current port: uart
KDB: debugger backends: ddb gdb
KDB: current backend: ddb
KDB: enter: Boot flags requested debugger
[ thread pid 0 tid 0 ]
Stopped at kdb_enter+0x3b: movq $0,0xaf0362(%rip)
db>

# 输入:
gdb

配置完毕!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值