From 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 27 Mar 2012 11:51:08 +0200 Subject: reorganize file structure to match the upstream requirements --- misc/0001-bochs-2.3.7-jitter.patch | 78 ++++++++++++++++ misc/0002-bochs-2.3.7-triple-fault.patch | 87 +++++++++++++++++ misc/0003-bochs-2.3.7-page-fault-segv.patch | 93 ++++++++++++++++++ misc/bochs-2.3.7-build.sh | 42 +++++++++ misc/bochs-2.3.7-gcc43.patch | 12 +++ misc/bochs-2.3.7-linux3x.patch | 11 +++ misc/bochs-2.3.7-typos.patch | 24 +++++ misc/gcc-3.3.6-cross-howto | 39 ++++++++ misc/gdb-macros | 140 ++++++++++++++++++++++++++++ 9 files changed, 526 insertions(+) create mode 100644 misc/0001-bochs-2.3.7-jitter.patch create mode 100644 misc/0002-bochs-2.3.7-triple-fault.patch create mode 100644 misc/0003-bochs-2.3.7-page-fault-segv.patch create mode 100755 misc/bochs-2.3.7-build.sh create mode 100644 misc/bochs-2.3.7-gcc43.patch create mode 100644 misc/bochs-2.3.7-linux3x.patch create mode 100644 misc/bochs-2.3.7-typos.patch create mode 100644 misc/gcc-3.3.6-cross-howto create mode 100644 misc/gdb-macros (limited to 'misc') diff --git a/misc/0001-bochs-2.3.7-jitter.patch b/misc/0001-bochs-2.3.7-jitter.patch new file mode 100644 index 0000000..44190e3 --- /dev/null +++ b/misc/0001-bochs-2.3.7-jitter.patch @@ -0,0 +1,78 @@ +From 5e6cfa27ba6de331ecc142e7f65b4d1c2112b4e2 Mon Sep 17 00:00:00 2001 +From: Alex Busenius +Date: Mon, 27 Apr 2009 15:33:37 +0200 +Subject: bochs-2.3.7 jitter + +--- + bochs.h | 2 ++ + iodev/pit82c54.cc | 9 ++++++++- + main.cc | 8 ++++++++ + 3 files changed, 18 insertions(+), 1 deletions(-) + +diff --git a/bochs.h b/bochs.h +index 2a643cd..75bcd96 100644 +--- a/bochs.h ++++ b/bochs.h +@@ -630,4 +630,6 @@ void bx_center_print(FILE *file, const char *line, unsigned maxwidth); + + #endif + ++extern int jitter; ++ + #endif /* BX_BOCHS_H */ +diff --git a/iodev/pit82c54.cc b/iodev/pit82c54.cc +index 0d65768..31ac041 100644 +--- a/iodev/pit82c54.cc ++++ b/iodev/pit82c54.cc +@@ -28,6 +28,7 @@ + + #include "iodev.h" + #include "pit82c54.h" ++#include + #define LOG_THIS this-> + + +@@ -399,7 +400,13 @@ pit_82C54::clock(Bit8u cnum) + case 2: + if (thisctr.count_written) { + if (thisctr.triggerGATE || thisctr.first_pass) { +- 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 ebdf258..09cf661 100644 +--- a/main.cc ++++ b/main.cc +@@ -112,6 +112,7 @@ BOCHSAPI BX_MEM_C bx_mem; + #endif + + char *bochsrc_filename = NULL; ++int jitter = 0; + + void bx_print_header () + { +@@ -541,6 +542,13 @@ int bx_init_main(int argc, char *argv[]) + else if (!strcmp("-q", argv[arg])) { + SIM->get_param_enum(BXPN_BOCHS_START)->set(BX_QUICK_START); + } ++ 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]; +-- +1.6.2.3 + diff --git a/misc/0002-bochs-2.3.7-triple-fault.patch b/misc/0002-bochs-2.3.7-triple-fault.patch new file mode 100644 index 0000000..c8698bd --- /dev/null +++ b/misc/0002-bochs-2.3.7-triple-fault.patch @@ -0,0 +1,87 @@ +From 356b7e781c815c70c992d58360caa42f1776d06b Mon Sep 17 00:00:00 2001 +From: Alex Busenius +Date: Mon, 27 Apr 2009 17:09:27 +0200 +Subject: bochs-2.3.7 triple fault + +--- + cpu/cpu.h | 4 ++++ + cpu/exception.cc | 7 +++++++ + gdbstub.cc | 11 ++++++++--- + 3 files changed, 19 insertions(+), 3 deletions(-) + +diff --git a/cpu/cpu.h b/cpu/cpu.h +index 7c7b11b..c47133a 100644 +--- a/cpu/cpu.h ++++ b/cpu/cpu.h +@@ -903,6 +903,10 @@ public: // for now... + #endif + Bit8u trace; + ++#if BX_GDBSTUB ++ Bit8u ispanic; ++#endif ++ + // for paging + struct { + bx_TLB_entry entry[BX_TLB_SIZE] BX_CPP_AlignN(16); +diff --git a/cpu/exception.cc b/cpu/exception.cc +index c3e3777..fb3abfc 100644 +--- a/cpu/exception.cc ++++ b/cpu/exception.cc +@@ -856,6 +856,13 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code, bx_bool trap) + // trap into debugger (similar as done when PANIC occured) + bx_debug_break(); + #endif ++#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 (SIM->get_param_bool(BXPN_RESET_ON_TRIPLE_FAULT)->get()) { + BX_ERROR(("exception(): 3rd (%d) exception with no resolution, shutdown status is %02xh, resetting", vector, DEV_cmos_get_reg(0x0f))); + bx_pc_system.Reset(BX_RESET_SOFTWARE); +diff --git a/gdbstub.cc b/gdbstub.cc +index f58f866..bc5ed61 100644 +--- a/gdbstub.cc ++++ b/gdbstub.cc +@@ -471,7 +471,12 @@ static void debug_loop(void) + } + + stub_trace_flag = 0; ++ bx_cpu.ispanic = 0; + bx_cpu.cpu_loop(0); ++ if (bx_cpu.ispanic) ++ { ++ last_stop_reason = GDBSTUB_EXECUTION_BREAKPOINT; ++ } + + DEV_vga_refresh(); + +@@ -502,19 +507,19 @@ static void debug_loop(void) + + BX_INFO(("stepping")); + stub_trace_flag = 1; ++ bx_cpu.ispanic = 0; + bx_cpu.cpu_loop(0); + 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; +-- +1.6.2.3 + diff --git a/misc/0003-bochs-2.3.7-page-fault-segv.patch b/misc/0003-bochs-2.3.7-page-fault-segv.patch new file mode 100644 index 0000000..8b6e090 --- /dev/null +++ b/misc/0003-bochs-2.3.7-page-fault-segv.patch @@ -0,0 +1,93 @@ +From 314833401978558db06bbb4f4f76e4dc7b603744 Mon Sep 17 00:00:00 2001 +From: Alex Busenius +Date: Mon, 27 Apr 2009 16:33:54 +0200 +Subject: bochs-2.3.7 page fault segv + +--- + bochs.h | 1 + + cpu/exception.cc | 4 ++++ + gdbstub.cc | 17 ++++++++++++++++- + 3 files changed, 21 insertions(+), 1 deletions(-) + +diff --git a/bochs.h b/bochs.h +index 75bcd96..657c7b8 100644 +--- a/bochs.h ++++ b/bochs.h +@@ -433,6 +433,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 +diff --git a/cpu/exception.cc b/cpu/exception.cc +index fb3abfc..8dac5ca 100644 +--- a/cpu/exception.cc ++++ b/cpu/exception.cc +@@ -1046,6 +1046,10 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code, bx_bool trap) + + BX_CPU_THIS_PTR errorno++; + ++#if BX_GDBSTUB ++ bx_gdbstub_exception(vector); ++#endif ++ + if (real_mode()) { + // not INT, no error code pushed + BX_CPU_THIS_PTR interrupt(vector, 0, 0, 0); +diff --git a/gdbstub.cc b/gdbstub.cc +index bc5ed61..ad59373 100644 +--- a/gdbstub.cc ++++ b/gdbstub.cc +@@ -47,6 +47,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; +@@ -323,6 +324,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 int addr, int len) + { + unsigned int i; +@@ -493,6 +500,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); +@@ -517,10 +528,14 @@ static void debug_loop(void) + { + write_signal(&buf[1], SIGTRAP); + } +- else ++ else if (last_stop_reason == GDBSTUB_EXCEPTION_0E) + { + write_signal(&buf[1], SIGSEGV); + } ++ else ++ { ++ write_signal(&buf[1], 0); ++ } + put_reply(buf); + break; + } +-- +1.6.2.3 + diff --git a/misc/bochs-2.3.7-build.sh b/misc/bochs-2.3.7-build.sh new file mode 100755 index 0000000..57e35d1 --- /dev/null +++ b/misc/bochs-2.3.7-build.sh @@ -0,0 +1,42 @@ +#! /bin/sh -e + +if test -z "$SRCDIR" || test -z "$PINTOSDIR" || test -z "$DSTDIR"; then + echo "usage: env SRCDIR= PINTOSDIR= DSTDIR= sh $0" + echo " where contains bochs-2.3.7.tar.gz" + echo " and is the root of the pintos source tree" + echo " and is the installation prefix (e.g. /usr/local)" + exit 1 +fi + +cd /tmp +mkdir bochs-pintos-$$ +cd bochs-pintos-$$ +mkdir bochs-2.3.7 +tar xzf $SRCDIR/bochs-2.3.7.tar.gz +cd bochs-2.3.7 +cat $PINTOSDIR/src/misc/0001-bochs-2.3.7-jitter.patch | patch -p1 +cat $PINTOSDIR/src/misc/0002-bochs-2.3.7-triple-fault.patch | patch -p1 +cat $PINTOSDIR/src/misc/0003-bochs-2.3.7-page-fault-segv.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.3.7-gcc43.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.3.7-typos.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.3.7-linux3x.patch | patch -p1 +autoconf + +CFGOPTIONAL="--enable-large-pages --enable-mmx --enable-usb --enable-pci --enable-pcidev --enable-acpi --enable-global-pages --enable-show-ips" +CFGOPTIMIZE="--enable-all-optimizations --enable-guest2host-tlb --enable-repeat-speedups --enable-trace-cache --enable-icache --enable-fast-function-calls --enable-idle-hack " +CFGOPTS="--prefix=$DSTDIR --enable-ignore-bad-msr --enable-disasm --enable-logging --enable-fpu --enable-alignment-check --enable-plugins --enable-cpu-level=6 --enable-readline --without-sdl --without-svga --without-wx --with-x --with-x11 --with-term --with-nogui $CFGOPTIONAL" +mkdir plain && + cd plain && + ../configure $CFGOPTS --enable-gdb-stub && +# make -j3 && + make && echo "done building plain" && + sudo make install && + cd .. && +mkdir with-dbg && + cd with-dbg && + ../configure --enable-debugger $CFGOPTS && + # make -j3 && + make && echo "done building with-dbg" && + sudo cp -v bochs $DSTDIR/bin/bochs-dbg && + cd .. && + echo "SUCCESS" diff --git a/misc/bochs-2.3.7-gcc43.patch b/misc/bochs-2.3.7-gcc43.patch new file mode 100644 index 0000000..4646edf --- /dev/null +++ b/misc/bochs-2.3.7-gcc43.patch @@ -0,0 +1,12 @@ +--- bochs-2.3.7.orig/bx_debug/symbols.cc 2008/03/30 14:32:14 1.11 ++++ bochs-2.3.7/bx_debug/symbols.cc 2008/06/16 17:09:52 1.12 +@@ -95,6 +95,9 @@ + #endif + + using namespace std; ++#ifdef __GNUC__ ++using namespace __gnu_cxx; ++#endif + + struct symbol_entry_t + { diff --git a/misc/bochs-2.3.7-linux3x.patch b/misc/bochs-2.3.7-linux3x.patch new file mode 100644 index 0000000..1c84060 --- /dev/null +++ b/misc/bochs-2.3.7-linux3x.patch @@ -0,0 +1,11 @@ +--- a/configure.in 2012-01-03 11:12:22.104612131 +0100 ++++ b/configure.in 2012-01-03 11:13:05.507941106 +0100 +@@ -715,7 +715,7 @@ AC_ARG_ENABLE(pcidev, + PCIDEV_MODULE_MAKE_ALL="all-kernel24" + KERNEL_MODULE_SUFFIX="o" + ;; +- 2.6*) ++ 2.6*|3*) + PCIDEV_MODULE_MAKE_ALL="all-kernel26" + KERNEL_MODULE_SUFFIX="ko" + ;; diff --git a/misc/bochs-2.3.7-typos.patch b/misc/bochs-2.3.7-typos.patch new file mode 100644 index 0000000..c9fb168 --- /dev/null +++ b/misc/bochs-2.3.7-typos.patch @@ -0,0 +1,24 @@ +diff -NaurwB bochs-2.3.7.orig/cpu/ia_opcodes.h bochs-2.3.7/cpu/ia_opcodes.h +--- bochs-2.3.7.orig/cpu/ia_opcodes.h 2008-05-30 22:35:08.000000000 +0200 ++++ bochs-2.3.7/cpu/ia_opcodes.h 2008-06-04 14:56:46.000000000 +0200 +@@ -891,7 +891,7 @@ + bx_define_opcode(BX_IA_PF2ID_PqQq, BX_CPU_C::PF2ID_PqQq) + bx_define_opcode(BX_IA_PF2IW_PqQq, BX_CPU_C::PF2IW_PqQq) + bx_define_opcode(BX_IA_PFACC_PqQq, BX_CPU_C::PFACC_PqQq) +-bx_define_opcode(BX_IA_PFADD_PqQq, BX_CPU_C::BX_PFADD_PqQq) ++bx_define_opcode(BX_IA_PFADD_PqQq, BX_CPU_C::PFADD_PqQq) + bx_define_opcode(BX_IA_PFCMPEQ_PqQq, BX_CPU_C::PFCMPEQ_PqQq) + bx_define_opcode(BX_IA_PFCMPGE_PqQq, BX_CPU_C::PFCMPGE_PqQq) + bx_define_opcode(BX_IA_PFCMPGT_PqQq, BX_CPU_C::PFCMPGT_PqQq) +diff -NaurwB bochs-2.3.7.orig/iodev/iodebug.h bochs-2.3.7/iodev/iodebug.h +--- bochs-2.3.7.orig/iodev/iodebug.h 2008-05-01 22:46:58.000000000 +0200 ++++ bochs-2.3.7/iodev/iodebug.h 2008-06-04 14:45:50.000000000 +0200 +@@ -18,7 +18,7 @@ + virtual void init(void); + virtual void reset (unsigned type) {} + static void mem_write(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data); +- static void mem_read(BX_CPU_C *cpu, bx_phy_addressu addr, unsigned len, void *data); ++ static void mem_read(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data); + + private: + static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len); diff --git a/misc/gcc-3.3.6-cross-howto b/misc/gcc-3.3.6-cross-howto new file mode 100644 index 0000000..ad25173 --- /dev/null +++ b/misc/gcc-3.3.6-cross-howto @@ -0,0 +1,39 @@ +Here are the commands we used to build and install the SPARC +cross-compiler: + +PINTOSROOT=$HOME/private/pintos + +PREFIX=/usr/class/cs140/`uname -m` +PATH=$PATH:$PREFIX/bin +TMP=`pwd` + +wget ftp://ftp.gnu.org/pub/gnu/binutils/binutils-2.15.tar.bz2 +wget ftp://sources.redhat.com/pub/newlib/newlib-1.13.0.tar.gz +wget ftp://ftp.gnu.org/pub/gnu/gcc/gcc-3.3.6/gcc-core-3.3.6.tar.bz2 +wget ftp://ftp.gnu.org/pub/gnu/gdb/gdb-6.3.tar.bz2 + +bzcat binutils-2.15.tar.bz2 | tar x +tar xzf newlib-1.13.0.tar.gz +bzcat gcc-core-3.3.6.tar.bz2 | tar x +bzcat gdb-6.3.tar.bz2 | tar x + +cd $TMP/binutils-2.15 +mkdir i386 +cd i386 +../configure --target=i386-elf --prefix=$PREFIX +make LDFLAGS=-lintl +make install + +cd $TMP/gcc-3.3.6 +mkdir i386 +cd i386 +../configure --target=i386-elf --prefix=$PREFIX --with-gnu-as --with-as=$PREFIX/bin/i386-elf-as --with-gnu-ld --with-ld=$PREFIX/bin/i386-elf-ld --with-headers=$TMP/newlib-1.13.0/newlib/libc/include --with-newlib +make +make install + +cd $TMP/gdb-6.3 +mkdir i386 +cd i386 +../configure --target=i386-elf --prefix=$PREFIX --disable-tui +make LDFLAGS=-lintl +make install diff --git a/misc/gdb-macros b/misc/gdb-macros new file mode 100644 index 0000000..a0b68c3 --- /dev/null +++ b/misc/gdb-macros @@ -0,0 +1,140 @@ +# +# A set of useful macros that can help debug Pintos. +# +# Include with "source" cmd in gdb. +# Use "help user-defined" for help. +# +# Author: Godmar Back , Feb 2006 +# +# $Id: gdb-macros,v 1.1 2006-04-07 18:29:34 blp Exp $ +# + +# for internal use +define offsetof + set $rc = (char*)&((struct $arg0 *)0)->$arg1 - (char*)0 +end + +define list_entry + offsetof $arg1 $arg2 + set $rc = ((struct $arg1 *) ((uint8_t *) ($arg0) - $rc)) +end + +# dump a Pintos list +define dumplist + set $list = $arg0 + set $e = $list->head.next + set $i = 0 + while $e != &(($arg0).tail) + list_entry $e $arg1 $arg2 + set $l = $rc + printf "pintos-debug: dumplist #%d: %p ", $i++, $l + output *$l + set $e = $e->next + printf "\n" + end +end + +document dumplist + Dump the content of a Pintos list, + invoke as dumplist name_of_list name_of_struct name_of_elem_in_list_struct +end + +# print a thread's backtrace, given a pointer to the struct thread * +define btthread + if $arg0 == ($esp - ((unsigned)$esp % 4096)) + bt + else + set $saveEIP = $eip + set $saveESP = $esp + set $saveEBP = $ebp + + set $esp = ((struct thread *)$arg0)->stack + set $ebp = ((void**)$esp)[2] + set $eip = ((void**)$esp)[4] + + bt + + set $eip = $saveEIP + set $esp = $saveESP + set $ebp = $saveEBP + end +end +document btthread + Show the backtrace of a thread, + invoke as btthread pointer_to_struct_thread +end + +# print backtraces associated with all threads in a list +define btthreadlist + set $list = $arg0 + set $e = $list->head.next + while $e != &(($arg0).tail) + list_entry $e thread $arg1 + printf "pintos-debug: dumping backtrace of thread '%s' @%p\n", \ + ((struct thread*)$rc)->name, $rc + btthread $rc + set $e = $e->next + printf "\n" + end +end +document btthreadlist + Given a list of threads, print each thread's backtrace + invoke as btthreadlist name_of_list name_of_elem_in_list_struct +end + +# print backtraces of all threads (based on 'all_list' all threads list) +define btthreadall + btthreadlist all_list allelem +end +document btthreadall + Print backtraces of all threads +end + +# print a correct backtrace by adjusting $eip +# this works best right at intr0e_stub +define btpagefault + set $saveeip = $eip + set $eip = ((void**)$esp)[1] + backtrace + set $eip = $saveeip +end +document btpagefault + Print a backtrace of the current thread after a pagefault +end + +# invoked whenever the program stops +define hook-stop + # stopped at stub #0E = #14 (page fault exception handler stub) + if ($eip == intr0e_stub) + set $savedeip = ((void**)$esp)[1] + # if this was in user mode, the OS should handle it + # either handle the page fault or terminate the process + if ($savedeip < 0xC0000000) + printf "pintos-debug: a page fault exception occurred in user mode\n" + printf "pintos-debug: hit 'c' to continue, or 's' to step to intr_handler\n" + else + # if this was in kernel mode, a stack trace might be useful + printf "pintos-debug: a page fault occurred in kernel mode\n" + btpagefault + end + end +end + +# load symbols for a Pintos user program +define loadusersymbols + shell objdump -h $arg0 | awk '/.text/ { print "add-symbol-file $arg0 0x"$4 }' > .loadsymbols + source .loadsymbols + shell rm -f .loadsymbols +end +document loadusersymbols + Load the symbols contained in a user program's executable. + Example: + loadusersymbols tests/userprog/exec-multiple +end + +define debugpintos + target remote localhost:1234 +end +document debugpintos + Attach debugger to pintos process +end -- cgit v1.2.3