我刚开始使用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()
首次调用的。
pintos:
$:~/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)
正如您所看到的,只要我在gdb中运行c
(继续)命令,当调用read_command_line()
时,pintos会在调用printf()
时崩溃。
我不相信我对基线Pintos代码做了任何重大更改。什么可能让bochs在这个函数调用时恐慌?使用qemu运行相同的测试似乎没有这个问题。