我刚刚开始使用 Pintos 项目,在运行 Ubuntu 的家用计算机上工作。
我能够从src/threads/
目录编译项目,并且初始测试pintos run alarm-multiple
似乎工作正常(注意它默认运行 qemu):
$:~/workspace/pintos/src/threads/build$ pintos run alarm-multiple
qemu -hda /tmp/ODhMQLwBNh.dsk -m 4 -net none -serial stdio
Could not access KVM kernel module: No such file or directory
failed to initialize KVM: No such file or directory
Back to tcg accelerator.
PiLo hda1
Loading..........
Kernel command line: run alarm-multiple
Pintos booting with 4,096 kB RAM...
383 pages available in kernel pool.
383 pages available in user pool.
Calibrating timer... 111,206,400 loops/s.
Boot complete.
Executing 'alarm-multiple':
(alarm-multiple) begin
(alarm-multiple) Creating 5 threads to sleep 7 times each.
...
(alarm-multiple) thread 4: duration=50, iteration=7, product=350
(alarm-multiple) end
Execution of 'alarm-multiple' complete.
然而,当我用 bochs 模拟器运行这个测试时,我一点击就感到恐慌printf()
,这似乎是首先从read_command_line()
.
品脱:
$:~/workspace/pintos/src/threads/build$ pintos --gdb --bochs -- run alarm-multiple
squish-pty bochs -q
========================================================================
Bochs x86 Emulator 2.2.6
Build from CVS snapshot on January 29, 2006
========================================================================
00000000000i[ ] reading configuration from bochsrc.txt
00000000000e[ ] user_shortcut: old-style syntax detected
00000000000i[ ] Enabled gdbstub
00000000000i[ ] installing x module as the Bochs GUI
00000000000i[ ] using log file bochsout.txt
Waiting for gdb connection on localhost:1234
PiLo hda1
Loading..........
Kernel command lineTriple fault: stopping for gdb
pintos-gdb:
$:~/workspace/pintos/src/threads/build$ pintos-gdb kernel.o
*** /usr/class/cs140/pintos/pintos/src/misc/gdb-macros does not exist ***
*** Pintos GDB macros will not be available ***
GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04
Copyright (C) 2012 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 "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.launchpad.net/gdb-linaro/>...
Reading symbols from /home/ozhu/workspace/pintos/src/threads/build/kernel.o...done.
(gdb) target remote localhost:1234
Remote debugging using localhost:1234
warning: unrecognized item "ENN" in "qSupported" response
0x0000fff0 in ?? ()
qTStatus: Target returns error code 'NN'.
(gdb) break schedule
Breakpoint 1 at 0xc0020e7b: file ../../threads/thread.c, line 557.
qTStatus: Target returns error code 'NN'.
(gdb) c
Continuing.
qTStatus: Target returns error code 'NN'.
Program received signal SIGTRAP, Trace/breakpoint trap.
0xc0026a16 in __vprintf (format=<optimized out>, args=0xc000efa8 "\265\033", output=0xc002a094 <vprintf_helper>, aux=0xc000ef6c) at ../../lib/stdio.c:296
296 s = "(null)";
(gdb) bt
#0 0xc0026a16 in __vprintf (format=<optimized out>, args=0xc000efa8 "\265\033", output=0xc002a094 <vprintf_helper>, aux=0xc000ef6c) at ../../lib/stdio.c:296
#1 0xc002a160 in vprintf (format=0xc002e99b " %s", args=0xc000efa4 ">}") at ../../lib/kernel/console.c:131
#2 0xc0026377 in printf (format=0xc002e99b " %s") at ../../lib/stdio.c:85
#3 0xc00202a7 in read_command_line () at ../../threads/init.c:218
#4 main () at ../../threads/init.c:85
(gdb)
正如你所看到的,只要我c
在 gdb 中运行(继续)命令,pintos 就会在调用read_command_line()
时崩溃printf()
。
我认为我没有对基线 Pintos 代码进行任何重大更改。什么可能让 bochs 在这个函数调用中感到恐慌?用 qemu 运行同样的测试似乎没有这个问题。