Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • y2-rhymansaib/pintos_student
1 result
Select Git revision
Show changes
Showing
with 14 additions and 307 deletions
--- bochs-2.2.6.orig/Makefile.in 2006-04-03 16:34:51.170387000 -0700
+++ bochs-2.2.6/Makefile.in 2006-04-03 16:34:57.480303000 -0700
@@ -93,7 +93,7 @@
CFLAGS = @CFLAGS@ @GUI_CFLAGS@ $(MCH_CFLAGS) $(FLA_FLAGS) @DEFINE_PLUGIN_PATH@ -DBX_SHARE_PATH='"$(sharedir)"'
CXXFLAGS = @CXXFLAGS@ @GUI_CXXFLAGS@ $(MCH_CFLAGS) $(FLA_FLAGS) @DEFINE_PLUGIN_PATH@ -DBX_SHARE_PATH='"$(sharedir)"'
-LDFLAGS = @LDFLAGS@
+LDFLAGS = @LDFLAGS@ -lsocket
LIBS = @LIBS@
# To compile with readline:
# linux needs just -lreadline
--- bochs-2.2.6/iodev/serial.cc 2005-07-11 09:24:47.000000000 -0700
+++ bochs-2.2.6.patch/iodev/serial.cc 2006-05-28 16:41:33.278938000 -0700
@@ -245,8 +245,13 @@
BX_SER_THIS s[i].io_mode = BX_SER_MODE_TERM;
BX_DEBUG(("com%d tty_id: %d", i+1, BX_SER_THIS s[i].tty_id));
tcgetattr(BX_SER_THIS s[i].tty_id, &BX_SER_THIS s[i].term_orig);
- bcopy((caddr_t) &BX_SER_THIS s[i].term_orig, (caddr_t) &BX_SER_THIS s[i].term_new, sizeof(struct termios));
- cfmakeraw(&BX_SER_THIS s[i].term_new);
+ memcpy((caddr_t) &BX_SER_THIS s[i].term_new, (caddr_t) &BX_SER_THIS s[i].term_orig, sizeof(struct termios));
+ BX_SER_THIS s[i].term_new.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
+ |INLCR|IGNCR|ICRNL|IXON);
+ BX_SER_THIS s[i].term_new.c_oflag &= ~OPOST;
+ BX_SER_THIS s[i].term_new.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+ BX_SER_THIS s[i].term_new.c_cflag &= ~(CSIZE|PARENB);
+ BX_SER_THIS s[i].term_new.c_cflag |= CS8;
BX_SER_THIS s[i].term_new.c_oflag |= OPOST | ONLCR; // Enable NL to CR-NL translation
#ifndef TRUE_CTLC
// ctl-C will exit Bochs, or trap to the debugger
--- bochs-2.2.6/iodev/serial.h 2005-07-10 09:51:09.000000000 -0700
+++ bochs-2.2.6.patch/iodev/serial.h 2006-05-28 16:39:03.757839000 -0700
@@ -40,7 +40,7 @@
#define SERIAL_ENABLE
#endif
-#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__APPLE__)
+#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__APPLE__) || defined(__sun__)
#define SERIAL_ENABLE
extern "C" {
#include <termios.h>
diff -u bochs-2.2.6.orig/cpu/exception.cc bochs-2.2.6/cpu/exception.cc
--- bochs-2.2.6.orig/cpu/exception.cc
+++ bochs-2.2.6/cpu/exception.cc
@@ -841,6 +841,13 @@ void BX_CPU_C::exception(unsigned vector
BX_CPU_THIS_PTR errorno++;
if (BX_CPU_THIS_PTR errorno >= 3) {
+#if BX_GDBSTUB
+ if (bx_dbg.gdbstub_enabled) {
+ fprintf(stderr, "Triple fault: stopping for gdb\n");
+ BX_CPU_THIS_PTR ispanic = 1;
+ longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1);
+ }
+#endif
#if BX_RESET_ON_TRIPLE_FAULT
BX_ERROR(("exception(): 3rd (%d) exception with no resolution, shutdown status is %02xh, resetting", vector, DEV_cmos_get_reg(0x0f)));
debug(BX_CPU_THIS_PTR prev_eip);
@@ -860,6 +867,13 @@ void BX_CPU_C::exception(unsigned vector
/* if 1st was a double fault (software INT?), then shutdown */
if ( (BX_CPU_THIS_PTR errorno==2) && (BX_CPU_THIS_PTR curr_exception[0]==BX_ET_DOUBLE_FAULT) ) {
+#if BX_GDBSTUB
+ if (bx_dbg.gdbstub_enabled) {
+ fprintf(stderr, "Triple fault: stopping for gdb\n");
+ BX_CPU_THIS_PTR ispanic = 1;
+ longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1);
+ }
+#endif
#if BX_RESET_ON_TRIPLE_FAULT
BX_INFO(("exception(): triple fault encountered, shutdown status is %02xh, resetting", DEV_cmos_get_reg(0x0f)));
debug(BX_CPU_THIS_PTR prev_eip);
diff -u bochs-2.2.6.orig/gdbstub.cc bochs-2.2.6/gdbstub.cc
--- bochs-2.2.6.orig/gdbstub.cc
+++ bochs-2.2.6/gdbstub.cc
@@ -466,19 +466,19 @@ static void debug_loop(void)
BX_INFO (("stepping"));
stub_trace_flag = 1;
+ bx_cpu.ispanic = 0;
bx_cpu.cpu_loop(-1);
DEV_vga_refresh();
stub_trace_flag = 0;
BX_INFO (("stopped with %x", last_stop_reason));
buf[0] = 'S';
- if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT ||
- last_stop_reason == GDBSTUB_TRACE)
+ if (last_stop_reason == GDBSTUB_TRACE && !bx_cpu.ispanic)
{
write_signal(&buf[1], SIGTRAP);
}
else
{
- write_signal(&buf[1], SIGTRAP);
+ write_signal(&buf[1], SIGSEGV);
}
put_reply(buf);
break;
#! /bin/sh -e
if test -z "$SRCDIR" || test -z "$PINTOSDIR" || test -z "$DSTDIR"; then
echo "usage: env SRCDIR=<srcdir> PINTOSDIR=<srcdir> DSTDIR=<dstdir> sh $0"
echo " where <srcdir> contains bochs-2.6.2.tar.gz"
echo " and <pintosdir> is the root of the pintos source tree"
echo " and <dstdir> is the installation prefix (e.g. /usr/local)"
exit 1
fi
cd /tmp
mkdir $$
cd $$
mkdir bochs-2.6.2
tar xzf $SRCDIR/bochs-2.6.2.tar.gz
cd bochs-2.6.2
cat $PINTOSDIR/src/misc/bochs-2.6.2-jitter-plus-segv.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.6.2-xrandr-pkgconfig.patch | patch -p1
CFGOPTS="--with-x --with-x11 --with-term --with-nogui --prefix=$DSTDIR --enable-cpu-level=6"
mkdir plain &&
cd plain &&
../configure $CFGOPTS --enable-gdb-stub &&
make &&
make install &&
cd ..
mkdir with-dbg &&
cd with-dbg &&
../configure --enable-debugger $CFGOPTS &&
make &&
cp bochs $DSTDIR/bin/bochs-dbg &&
cd ..
diff --git a/bochs.h b/bochs.h
index c2d6c6b..d37cf12 100644
--- a/bochs.h
+++ b/bochs.h
@@ -392,6 +392,7 @@ BOCHSAPI extern logfunc_t *genlog;
void bx_gdbstub_init(void);
void bx_gdbstub_break(void);
int bx_gdbstub_check(unsigned int eip);
+void bx_gdbstub_exception(unsigned int nr);
#define GDBSTUB_STOP_NO_REASON (0xac0)
#if BX_SUPPORT_SMP
@@ -589,4 +590,6 @@ BX_CPP_INLINE Bit64u bx_bswap64(Bit64u val64)
#define CopyHostQWordLittleEndian(hostAddrDst, hostAddrSrc) \
(* (Bit64u *)(hostAddrDst)) = (* (Bit64u *)(hostAddrSrc));
+extern int jitter;
+
#endif /* BX_BOCHS_H */
diff --git a/cpu/exception.cc b/cpu/exception.cc
index db38d1b..b2c5f29 100644
--- a/cpu/exception.cc
+++ b/cpu/exception.cc
@@ -914,6 +914,10 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code)
BX_CPU_THIS_PTR last_exception_type = exception_type;
+#if BX_GDBSTUB
+ bx_gdbstub_exception(vector);
+#endif
+
if (real_mode()) {
push_error = 0; // not INT, no error code pushed
error_code = 0;
diff --git a/gdbstub.cc b/gdbstub.cc
index da600b4..577938d 100644
--- a/gdbstub.cc
+++ b/gdbstub.cc
@@ -49,6 +49,7 @@ static int last_stop_reason = GDBSTUB_STOP_NO_REASON;
#define GDBSTUB_EXECUTION_BREAKPOINT (0xac1)
#define GDBSTUB_TRACE (0xac2)
#define GDBSTUB_USER_BREAK (0xac3)
+#define GDBSTUB_EXCEPTION_0E (0xac4)
static bx_list_c *gdbstub_list;
static int listen_socket_fd;
@@ -317,6 +318,12 @@ int bx_gdbstub_check(unsigned int eip)
return GDBSTUB_STOP_NO_REASON;
}
+void bx_gdbstub_exception(unsigned int nr)
+{
+ if (nr == 0x0e)
+ last_stop_reason = GDBSTUB_EXCEPTION_0E;
+}
+
static int remove_breakpoint(unsigned addr, int len)
{
if (len != 1)
@@ -487,6 +494,10 @@ static void debug_loop(void)
{
write_signal(&buf[1], SIGTRAP);
}
+ else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
+ {
+ write_signal(&buf[1], SIGSEGV);
+ }
else
{
write_signal(&buf[1], 0);
@@ -514,6 +525,10 @@ static void debug_loop(void)
{
write_signal(&buf[1], SIGTRAP);
}
+ else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
+ {
+ write_signal(&buf[1], SIGSEGV);
+ }
else
{
write_signal(&buf[1], SIGTRAP);
diff --git a/iodev/pit82c54.cc b/iodev/pit82c54.cc
index 09dcd8e..7e335d4 100644
--- a/iodev/pit82c54.cc
+++ b/iodev/pit82c54.cc
@@ -49,6 +49,7 @@
#include "iodev.h"
#include "pit82c54.h"
+#include <stdlib.h>
#define LOG_THIS this->
@@ -410,7 +411,14 @@ void BX_CPP_AttrRegparmN(1) pit_82C54::clock(Bit8u cnum)
case 2:
if (thisctr.count_written) {
if (thisctr.triggerGATE || thisctr.first_pass) {
- set_count(thisctr, thisctr.inlatch);
+ //set_count(thisctr, thisctr.inlatch);
+ unsigned n = thisctr.inlatch;
+ if (jitter && n > 5) {
+ n *= (double) rand() / RAND_MAX;
+ if (n < 5)
+ n = 5;
+ }
+ set_count(thisctr, n);
thisctr.next_change_time=(thisctr.count_binary-1) & 0xFFFF;
thisctr.null_count=0;
if (thisctr.inlatch==1) {
diff --git a/main.cc b/main.cc
index 0f11e31..008f05f 100644
--- a/main.cc
+++ b/main.cc
@@ -101,6 +101,7 @@ BOCHSAPI BX_CPU_C bx_cpu;
BOCHSAPI BX_MEM_C bx_mem;
char *bochsrc_filename = NULL;
+int jitter = 0;
void bx_print_header()
{
@@ -639,6 +640,13 @@ int bx_init_main(int argc, char *argv[])
else SIM->get_param_string(BXPN_DEBUGGER_LOG_FILENAME)->set(argv[arg]);
}
#endif
+ else if (!strcmp ("-j", argv[arg])) {
+ if (++arg >= argc) BX_PANIC(("-j must be followed by a number"));
+ else {
+ jitter = 1;
+ srand (atoi (argv[arg]));
+ }
+ }
else if (!strcmp("-f", argv[arg])) {
if (++arg >= argc) BX_PANIC(("-f must be followed by a filename"));
else bochsrc_filename = argv[arg];
diff -Naur bochs-2.6.2.orig/configure bochs-2.6.2/configure
--- bochs-2.6.2.orig/configure 2014-01-06 16:39:03.000000000 -0800
+++ bochs-2.6.2/configure 2014-01-06 16:39:23.000000000 -0800
@@ -24202,8 +24202,8 @@
fi
if test "$PKGCONFIG" != not_found; then
- X_CFLAGS="`pkg-config --cflags x11`"
- X_LIBS="`pkg-config --libs x11` $XPM_LIB -lXrandr"
+ X_CFLAGS="`pkg-config --cflags x11 xrandr`"
+ X_LIBS="`pkg-config --libs x11 xrandr` $XPM_LIB"
else
X_LIBS="$X_LIBS -lX11 $XPM_LIB -lXrandr"
fi
......@@ -37,3 +37,4 @@ cd i386
../configure --target=i386-elf --prefix=$PREFIX --disable-tui
make LDFLAGS=-lintl
make install
......@@ -138,3 +138,15 @@ end
document debugpintos
Attach debugger to pintos process
end
define show-mem-bitmap
printf "Kernel :\n"
x/12x kernel_pool.used_map.bits
printf "User :\n"
x/12x user_pool.used_map.bits
printf "Swap :\n"
x/32x swap.used_map.bits
end
document debugpintos
Print memory bitmap info
end
......@@ -51,7 +51,7 @@ $(foreach test,$(TESTS),$(eval $(test).output: TEST = $(test)))
# Prevent an environment variable VERBOSE from surprising us.
VERBOSE =
TESTCMD = pintos -v -k -T $(TIMEOUT)
TESTCMD = ../../utils/pintos -v -k -T $(TIMEOUT)
TESTCMD += $(SIMULATOR)
TESTCMD += $(PINTOSOPTS)
ifeq ($(filter userprog, $(KERNEL_SUBDIRS)), userprog)
......
/* Test program for lib/kernel/list.c.
Attempts to test the list functionality that is not
sufficiently tested elsewhere in Pintos.
This is not a test we will run on your submitted projects.
It is here for completeness.
*/
#undef NDEBUG
#include <debug.h>
#include <list.h>
......
/* Test program for printf() in lib/stdio.c.
Attempts to test printf() functionality that is not
sufficiently tested elsewhere in Pintos.
This is not a test we will run on your submitted projects.
It is here for completeness.
*/
#undef NDEBUG
#include <limits.h>
#include <stdarg.h>
......
/* Test program for sorting and searching in lib/stdlib.c.
Attempts to test the sorting and searching functionality that
is not sufficiently tested elsewhere in Pintos.
This is not a test we will run on your submitted projects.
It is here for completeness.
*/
#undef NDEBUG
#include <debug.h>
#include <limits.h>
......
File mode changed from 100755 to 100644