我一直在攻击Xen块驱动程序后端,并且在使用kgdb over serial进行调试时遇到了一些困难。这是我的设置。我正在运行MacOS X作为主机操作系统。我有两个VirtualBox VM,称它们为dev和test。 VirtualBox配置为为每个端口提供连接到命名主机管道的COM1端口。然后我使用socat -d -d ./test-com1 ./dev-com1
连接两个端口。我在执行此操作后已经验证,我可以通过执行echo hi > /dev/[ttyS0|hvc0]
或使用socat将文本纯文本从一个VM发送到另一个VM。我还可以通过在开发时使用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
}
这是来自dev:
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报道的选项有关,但我希望有更多了解这些事情的人可以指出问题所以我理解。
谢谢!
答案 0 :(得分:1)
原来你不能这样做。但是,这里有一个Linux补丁:
http://lists.xen.org/archives/html/xen-devel/2012-06/msg00326.html
这是针对3.2内核的。我在同一个帖子中发布了一个3.3。此补丁启用了对hvc进行kgdb调试。