2019.10.25

This commit is contained in:
ultraji
2019-10-25 21:54:25 +08:00
commit e0bd090b2d
136 changed files with 23481 additions and 0 deletions

34
oslab/README.txt Normal file
View File

@@ -0,0 +1,34 @@
# 实验篇
1. shell 脚本问题
*.bxrc 文件中的变量不要用`{}`包起来,例如要用`$OSLAB_PATH`,不要用`${OSLAB_PATH}`。否则会找不到变量。
2. 如何使bochs、gdb调试忽略page fault信号
Created a patch "gdbstub.cc.patch" against bochs (version CVS 20080110)
Bochs always tries to find out the reason of an exception, so that it can generate the right signal for gdb.
If it fails to find a reason, bochs assigns a value GDBSTUB_STOP_NO_REASON (see bochs.h), which causes
debug_loop() (see gdbstub.cc) to generate a signal of number 0.
Signal 0 is problematic to gdb, as gdb doesn't allow us to ignore it.
Somehow when we simulate linux, we get tons of signal 0's that seem to be caused by page faults.
This patch makes bochs send SIGSEGV instead of signal 0, so that we can ignore it in gdb.
gdbstub.cc
debug_loop()
*** gdbstub.cc.orig Thu Oct 18 18:44:38 2007
--- gdbstub.cc Sat Jan 12 17:25:22 2008
*************** static void debug_loop(void)
*** 489,494 ****
--- 489,498 ----
{
write_signal(&buf[1], SIGTRAP);
}
+ else if (last_stop_reason == GDBSTUB_STOP_NO_REASON)
+ {
+ write_signal(&buf[1], SIGSEGV);
+ }
else
{
write_signal(&buf[1], 0);

4
oslab/bochs/.gdbrc Normal file
View File

@@ -0,0 +1,4 @@
break main
target remote localhost:1234
handle SIGSEGV nostop noprint ignore
continue

Binary file not shown.

Binary file not shown.

BIN
oslab/bochs/bochs-gdb Executable file

Binary file not shown.

View File

@@ -0,0 +1,10 @@
romimage: file=$OSLAB_PATH/bochs/BIOS-bochs-latest
megs: 32
vgaromimage: file=$OSLAB_PATH/bochs/VGABIOS-lgpl-latest
floppya: 1_44="$OSLAB_PATH/Image", status=inserted
ata0-master: type=disk, path="$OSLAB_PATH/hdc.img", mode=flat, cylinders=204, heads=16, spt=38
boot: floppy
log: $OSLAB_PATH/bochsout.txt
#parport1: enable=0
cpu: count=1, ips=4000000
gdbstub: enabled=1, port=1234, text_base=0, data_base=0, bss_base=0

8
oslab/bochs/bochsrc.bxrc Normal file
View File

@@ -0,0 +1,8 @@
romimage: file=$OSLAB_PATH/bochs/BIOS-bochs-latest
megs: 32
vgaromimage: file=$OSLAB_PATH/bochs/VGABIOS-lgpl-latest
floppya: 1_44="$OSLAB_PATH/Image", status=inserted
ata0-master: type=disk, path="$OSLAB_PATH/hdc.img", mode=flat, cylinders=204, heads=16, spt=38
boot: floppy
log: $OSLAB_PATH/bochsout.txt
cpu: count=1, ips=4000000

BIN
oslab/hdc.tar.xz Normal file

Binary file not shown.

17
oslab/run.sh Executable file
View File

@@ -0,0 +1,17 @@
#!/bin/sh
export OSLAB_PATH=$(dirname `which $0`)
if [ ! -e "hdc.img" ]; then
tar -xvJf hdc.tar.xz
fi
if [ "$1" ] && [ "$1" = "-m" ]
then
(cd ../linux-0.12; make clean; make; cp Image ../oslab/Image)
elif [ "$1" ] && [ "$1" = "-g" ]
then
$OSLAB_PATH/bochs/bochs-gdb -q -f $OSLAB_PATH/bochs/bochsrc-gdb.bxrc & \
gdb -x $OSLAB_PATH/bochs/.gdbrc ../linux-0.12/tools/system
else
bochs -q -f $OSLAB_PATH/bochs/bochsrc.bxrc
fi