2012-06-05 34 views
2

我一直在對Xen塊驅動程序後端進行黑客攻擊,並且在使用kgdb進行串口調試時遇到了一些困難。這是我的設置。我將MacOS X作爲主機操作系統運行。我有兩個VirtualBox虛擬機,稱它們爲開發和測試。 VirtualBox配置爲給每個人一個COM1端口連接到一個命名的主機管道。然後我使用socat -d -d ./test-com1 ./dev-com1來連接這兩個端口。這樣做後,我已驗證,我可以通過執行echo hi > /dev/[ttyS0|hvc0]或使用socat從一個VM發送純文本到另一個VM。我也可以通過在開發環境中使用socat來獲得控制檯輸出在測試期間的測試結果。如何在Xen中調試Linux dom0內核

下面是測試內核我的GRUB項:

menuentry 'Debian GNU/Linux, with Linux 3.3.6-xen-ljx-g6304e82 and XEN 4.1.2' --class debian --class gnu-linux --class gnu --class os --class xen { 
     insmod part_msdos 
     insmod ext2 
     set root='(hd0,msdos1)' 
     search --no-floppy --fs-uuid --set 0c98efb4-f40e-4f0e-a2d3-2ed39b0a5070 
     echo 'Loading Linux 3.3.6-xen-ljx-g6304e82 ...' 
     multiboot  /boot/xen-4.1.2.gz placeholder loglvl=all guest_loglvl=all com1=115200,8n1,0x3f8,4 console=com1,vga 
     module /boot/vmlinuz-3.3.6-xen-ljx-g6304e82 placeholder root=UUID=0c98efb4-f40e-4f0e-a2d3-2ed39b0a5070 ro console=hvc0 console=tty0 earlyprintk=xen nopat quiet 
     echo 'Loading initial ramdisk ...' 
     module /boot/initrd.img-3.3.6-xen-ljx-g6304e82 
} 

這是從開發:

[email protected]:~/workspace/linux-3.3.6$ stty -F /dev/ttyS0 -a 
speed 38400 baud; rows 0; columns 0; line = 0; 
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 0; time = 10; 
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts 
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8 
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke 

這是測試:

[email protected]:~# stty -F /dev/tty0 -a 
speed 38400 baud; rows 25; columns 80; line = 0; 
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; 
-parenb -parodd cs8 -hupcl -cstopb cread -clocal -crtscts 
ignbrk -brkint ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff -iuclc -ixany -imaxbel -iutf8 
-opost -olcuc -ocrnl -onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 
-isig -icanon -iexten -echo -echoe -echok -echonl -noflsh -xcase -tostop -echoprt -echoctl -echoke 
[email protected]:~# stty -F /dev/hvc0 -a 
speed 38400 baud; rows 0; columns 0; line = 0; 
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; 
-parenb -parodd cs8 hupcl -cstopb cread -clocal -crtscts 
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc -ixany -imaxbel -iutf8 
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke 

一個例子開發會議(後在測試上做echo hvc0,38400 > /sys/module/kgdboc/parameters/kgdboc; echo g > /proc/sysrq-trigger):

[email protected]:~/workspace/linux-3.3.6$ gdb vmlinux 
GNU gdb (GDB) 7.0.1-debian 
Copyright (C) 2009 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
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 "i486-linux-gnu". 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>... 
Reading symbols from /home/paton/workspace/linux-3.3.6/vmlinux...done. 
(gdb) set remotebaud 38400 
(gdb) target remote /dev/ttyS0 
Remote debugging using /dev/ttyS0 
Ignoring packet error, continuing... 
warning: unrecognized item "timeout" in "qSupported" response 
Ignoring packet error, continuing... 

當我使用tty0而不是上面的hvc0時,會發生同樣的事情。

雖然串行TTY設置不同,但在沒有Xen的情況下使用我的內核時,我已能夠成功連接調試器。我有一種感覺,它與STTY報道的選項有關,但我希望有人對這些事情有更多的瞭解,可以指出問題,所以我明白了。

謝謝!

+0

我非常困惑哪些部分是通過Xen完成的,哪些部分是通過VirtualBox完成的。您可以使用本機OS X串行工具直接與Xen盒進行通信,並在稍後與VirtualBox進行對抗? – sarnold

+0

我不確定。我是內核調試的新手。你是否建議有一種方法可以在不使用gdb的情況下連接到內核,只需通過串行發送命令? –

+0

人,也許這是一個額外的混亂部分;我主要使用串口作爲_console_來獲取恐慌消息,並且不想在運行的內核上使用'gdb'。我只是試圖提出一些方法來減少移動部件的數量 - VB,Xen,GDB,在多臺機器和多個操作系統上,嘗試一次調試是很多的。 – sarnold

回答