我一直在破解 Xen 块驱动程序后端,并且在通过串行方式使用 kgdb 进行调试时遇到了一些困难。这是我的设置。我将 MacOS X 作为主机操作系统运行。我有两个 VirtualBox 虚拟机,称它们为开发和测试。VirtualBox 被配置为给他们每个人一个连接到命名主机管道的 COM1 端口。然后我用它socat -d -d ./test-com1 ./dev-com1
来连接两个端口。执行此操作后,我已验证我可以通过执行echo hi > /dev/[ttyS0|hvc0]
或使用 socat 将文本纯文本从一个 VM 发送到另一个 VM。我还可以通过在 dev 上使用 socat 在启动期间从测试中获得控制台输出。
这是我的测试内核的 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
}
这是来自开发:
user@jimmy:~/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
这是来自测试:
root@sqtest:~# 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
root@sqtest:~# 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
在测试之后):
user@jimmy:~/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 报告的选项有关,但我希望对这些事情了解更多的人可以指出问题,以便我理解。
谢谢!