歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Unix知識 >> BSD >> 配置VMWare遠程調試FreeBSD9.2內核源代碼

配置VMWare遠程調試FreeBSD9.2內核源代碼

日期:2017/2/28 14:31:59   编辑:BSD

要學習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同步簡易教程 http://www.linuxidc.com/Linux/2013-07/86849.htm

FreeBSD8.2系統安裝Salt http://www.linuxidc.com/Linux/2013-02/80024.htm

制作FreeBSD系統定制安裝ISO http://www.linuxidc.com/Linux/2012-12/76350.htm

FreeBSD搭建NAT並在單網卡上配置多個VLAN http://www.linuxidc.com/Linux/2012-12/75507.htm

Copyright © Linux教程網 All Rights Reserved