配置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的目录,输入:
 
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
 
配置完毕!

FreeBSD 8上的Rsync同步简易教程

FreeBSD8.2系统安装Salt

制作FreeBSD系统定制安装ISO

FreeBSD搭建NAT并在单网卡上配置多个VLAN

本文永久更新链接地址:

相关内容

    暂无相关文章