diff options
Diffstat (limited to 'src/misc')
| -rw-r--r-- | src/misc/bochs-2.2.6-big-endian.patch | 63 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-build.sh | 40 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-gdbstub-ENN.patch | 29 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-jitter.patch | 61 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-ms-extensions.patch | 14 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-page-fault-segv.patch | 79 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-paranoia.patch | 19 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-solaris-link.patch | 11 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-solaris-tty.patch | 31 | ||||
| -rw-r--r-- | src/misc/bochs-2.2.6-triple-fault.patch | 57 | ||||
| -rw-r--r-- | src/misc/gcc-3.3.6-cross-howto | 39 | ||||
| -rw-r--r-- | src/misc/gdb-macros | 120 |
12 files changed, 563 insertions, 0 deletions
diff --git a/src/misc/bochs-2.2.6-big-endian.patch b/src/misc/bochs-2.2.6-big-endian.patch new file mode 100644 index 0000000..420f69b --- /dev/null +++ b/src/misc/bochs-2.2.6-big-endian.patch @@ -0,0 +1,63 @@ +diff -urp bochs-2.2.6/gdbstub.cc bochs-2.2.6.orig/gdbstub.cc +--- bochs-2.2.6.orig/gdbstub.cc 2006-01-17 09:15:29.000000000 -0800 ++++ bochs-2.2.6/gdbstub.cc 2006-04-03 13:47:39.000000000 -0700 +@@ -672,35 +672,36 @@ + + case 'g': + #if !BX_SUPPORT_X86_64 +- registers[0] = EAX; +- registers[1] = ECX; +- registers[2] = EDX; +- registers[3] = EBX; +- registers[4] = ESP; +- registers[5] = EBP; +- registers[6] = ESI; +- registers[7] = EDI; ++ WriteHostDWordToLittleEndian(registers + 0, EAX); ++ WriteHostDWordToLittleEndian(registers + 1, ECX); ++ WriteHostDWordToLittleEndian(registers + 2, EDX); ++ WriteHostDWordToLittleEndian(registers + 3, EBX); ++ WriteHostDWordToLittleEndian(registers + 4, ESP); ++ WriteHostDWordToLittleEndian(registers + 5, EBP); ++ WriteHostDWordToLittleEndian(registers + 6, ESI); ++ WriteHostDWordToLittleEndian(registers + 7, EDI); + if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT) + { +- registers[8] = EIP + 1; ++ WriteHostDWordToLittleEndian(registers + 8, EIP + 1); + } + else + { +- registers[8] = EIP; ++ WriteHostDWordToLittleEndian(registers + 8, EIP); + } +- registers[9] = BX_CPU_THIS_PTR read_eflags(); +- registers[10] = +- BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value; +- registers[11] = +- BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value; +- registers[12] = +- BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value; +- registers[13] = +- BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value; +- registers[14] = +- BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value; +- registers[15] = +- BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value; ++ WriteHostDWordToLittleEndian(registers + 9, ++ BX_CPU_THIS_PTR read_eflags()); ++ WriteHostDWordToLittleEndian(registers + 10, ++ BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value); ++ WriteHostDWordToLittleEndian(registers + 11, ++ BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value); ++ WriteHostDWordToLittleEndian(registers + 12, ++ BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value); ++ WriteHostDWordToLittleEndian(registers + 13, ++ BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value); ++ WriteHostDWordToLittleEndian(registers + 14, ++ BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value); ++ WriteHostDWordToLittleEndian(registers + 15, ++ BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value); + mem2hex((char *)registers, obuf, NUMREGSBYTES); + #else + #define PUTREG(buf, val, len) do { \ diff --git a/src/misc/bochs-2.2.6-build.sh b/src/misc/bochs-2.2.6-build.sh new file mode 100644 index 0000000..a8a44e3 --- /dev/null +++ b/src/misc/bochs-2.2.6-build.sh @@ -0,0 +1,40 @@ +#! /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.2.6.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.2.6 +tar xzf $SRCDIR/bochs-2.2.6.tar.gz +cd bochs-2.2.6 +cat $PINTOSDIR/src/misc/bochs-2.2.6-ms-extensions.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.2.6-big-endian.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.2.6-jitter.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.2.6-triple-fault.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.2.6-solaris-tty.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.2.6-page-fault-segv.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.2.6-paranoia.patch | patch -p1 +cat $PINTOSDIR/src/misc/bochs-2.2.6-gdbstub-ENN.patch | patch -p1 +if test "`uname -s`" = "SunOS"; then + cat $PINTOSDIR/src/misc/bochs-2.2.6-solaris-link.patch | patch -p1 +fi +CFGOPTS="--with-x --with-x11 --with-term --with-nogui --prefix=$DSTDIR" +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/src/misc/bochs-2.2.6-gdbstub-ENN.patch b/src/misc/bochs-2.2.6-gdbstub-ENN.patch new file mode 100644 index 0000000..88a8145 --- /dev/null +++ b/src/misc/bochs-2.2.6-gdbstub-ENN.patch @@ -0,0 +1,29 @@ +--- bochs-2.2.6/gdbstub.cc 2006-01-17 12:15:29.000000000 -0500 ++++ bochs-2.2.6-patched/gdbstub.cc 2007-02-06 23:04:51.095523904 -0500 +@@ -515,7 +515,7 @@ + } + else + { +- put_reply("ENN"); ++ put_reply("Eff"); + } + } + break; +@@ -761,7 +761,7 @@ + } + else + { +- put_reply("ENN"); ++ put_reply("Eff"); + } + break; + +@@ -782,7 +782,7 @@ + } + else + { +- put_reply("ENN"); ++ put_reply("Eff"); + } + break; + diff --git a/src/misc/bochs-2.2.6-jitter.patch b/src/misc/bochs-2.2.6-jitter.patch new file mode 100644 index 0000000..48917e0 --- /dev/null +++ b/src/misc/bochs-2.2.6-jitter.patch @@ -0,0 +1,61 @@ +diff -urp bochs-2.2.6/iodev/pit82c54.cc bochs-2.2.6.orig/iodev/pit82c54.cc +--- bochs-2.2.6.orig/iodev/pit82c54.cc 2006-01-08 12:39:08.000000000 -0800 ++++ bochs-2.2.6/iodev/pit82c54.cc 2006-04-03 14:00:27.000000000 -0700 +@@ -28,6 +28,7 @@ + + #include "iodev.h" + #include "pit82c54.h" ++#include <stdlib.h> + #define LOG_THIS this-> + + +@@ -359,7 +360,13 @@ + 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 -urp bochs-2.2.6/main.cc bochs-2.2.6.orig/main.cc +--- bochs-2.2.6.orig/main.cc 2006-01-22 04:31:15.000000000 -0800 ++++ bochs-2.2.6/main.cc 2006-04-03 14:00:54.000000000 -0700 +@@ -105,6 +105,7 @@ + #endif + + char *bochsrc_filename = NULL; ++int jitter = 0; + + void bx_print_header () + { +@@ -459,6 +460,13 @@ + else if (!strcmp ("-q", argv[arg])) { + SIM->get_param_enum(BXP_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]; +diff -up /home/blp/cs140/bochs-2.2.6/bochs.h\~ /home/blp/cs140/bochs-2.2.6/bochs.h +--- bochs-2.2.6/bochs.h.orig 2006-01-28 08:16:02.000000000 -0800 ++++ bochs-2.2.6/bochs.h 2006-04-03 14:03:54.000000000 -0700 +@@ -698,4 +698,6 @@ int bx_init_hardware (); + + #endif + ++extern int jitter; ++ + #endif /* BX_BOCHS_H */ diff --git a/src/misc/bochs-2.2.6-ms-extensions.patch b/src/misc/bochs-2.2.6-ms-extensions.patch new file mode 100644 index 0000000..a6e50a0 --- /dev/null +++ b/src/misc/bochs-2.2.6-ms-extensions.patch @@ -0,0 +1,14 @@ +diff -urp orig/bochs-2.1.1/gui/Makefile.in bochs-2.1.1/gui/Makefile.in +--- orig/bochs-2.1.1/gui/Makefile.in 2003-11-28 07:07:28.000000000 -0800 ++++ bochs-2.1.1/gui/Makefile.in 2004-09-13 15:05:09.402039000 -0700 +@@ -44,7 +44,7 @@ SHELL = /bin/sh + @SET_MAKE@ + + CXX = @CXX@ +-CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@ @GUI_CXXFLAGS@ ++CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@ @GUI_CXXFLAGS@ -fms-extensions + LOCAL_CXXFLAGS = + LDFLAGS = @LDFLAGS@ + LIBS = @LIBS@ + + diff --git a/src/misc/bochs-2.2.6-page-fault-segv.patch b/src/misc/bochs-2.2.6-page-fault-segv.patch new file mode 100644 index 0000000..7c61a37 --- /dev/null +++ b/src/misc/bochs-2.2.6-page-fault-segv.patch @@ -0,0 +1,79 @@ +Index: bochs-2.2.6/cpu/exception.cc +diff -u bochs-2.2.6/cpu/exception.cc\~ bochs-2.2.6/cpu/exception.cc +--- bochs-2.2.6/cpu/exception.cc~ 2006-09-28 15:51:39.000000000 -0700 ++++ bochs-2.2.6/cpu/exception.cc 2006-12-08 11:14:33.000000000 -0800 +@@ -1033,6 +1033,10 @@ void BX_CPU_C::exception(unsigned vector + BX_CPU_THIS_PTR curr_exception[0] = exception_type; + } + ++#if BX_GDBSTUB ++ bx_gdbstub_exception(vector); ++#endif ++ + #if BX_CPU_LEVEL >= 2 + if (!real_mode()) { + BX_CPU_THIS_PTR interrupt(vector, 0, push_error, error_code); +Index: bochs-2.2.6/gdbstub.cc +diff -u bochs-2.2.6/gdbstub.cc\~ bochs-2.2.6/gdbstub.cc +--- bochs-2.2.6/gdbstub.cc~ 2006-09-28 15:51:39.000000000 -0700 ++++ bochs-2.2.6/gdbstub.cc 2006-12-08 11:12:03.000000000 -0800 +@@ -26,6 +26,7 @@ static int last_stop_reason = GDBSTUB_ST + #define GDBSTUB_EXECUTION_BREAKPOINT (0xac1) + #define GDBSTUB_TRACE (0xac2) + #define GDBSTUB_USER_BREAK (0xac3) ++#define GDBSTUB_EXCEPTION_0E (0xac4) + + static int listen_socket_fd; + static int socket_fd; +@@ -271,6 +272,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; +@@ -452,6 +459,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); +@@ -476,10 +487,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; + } +Index: bochs-2.2.6/bochs.h +diff -u bochs-2.2.6/bochs.h\~ bochs-2.2.6/bochs.h +--- bochs-2.2.6/bochs.h~ 2006-09-28 15:51:39.000000000 -0700 ++++ bochs-2.2.6/bochs.h 2006-12-08 11:14:19.000000000 -0800 +@@ -375,6 +375,7 @@ BOCHSAPI extern logfunc_t *genlog; + // defines for GDB stub + void bx_gdbstub_init(int argc, char* argv[]); + 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/src/misc/bochs-2.2.6-paranoia.patch b/src/misc/bochs-2.2.6-paranoia.patch new file mode 100644 index 0000000..ff8d736 --- /dev/null +++ b/src/misc/bochs-2.2.6-paranoia.patch @@ -0,0 +1,19 @@ +Index: bochs-2.2.6/iodev/hdimage.h +diff -u bochs-2.2.6/iodev/hdimage.h\~ bochs-2.2.6/iodev/hdimage.h +--- bochs-2.2.6/iodev/hdimage.h~ 2005-11-06 03:07:01.000000000 -0800 ++++ bochs-2.2.6/iodev/hdimage.h 2006-09-28 15:55:50.000000000 -0700 +@@ -273,14 +273,8 @@ class sparse_image_t : public device_ima + + void panic(const char * message); + off_t +-#ifndef PARANOID +- sparse_image_t:: +-#endif + get_physical_offset(); + void +-#ifndef PARANOID +- sparse_image_t:: +-#endif + set_virtual_page(Bit32u new_virtual_page); + void read_header(); + ssize_t read_page_fragment(Bit32u read_virtual_page, Bit32u read_page_offset, size_t read_size, void * buf); diff --git a/src/misc/bochs-2.2.6-solaris-link.patch b/src/misc/bochs-2.2.6-solaris-link.patch new file mode 100644 index 0000000..5afef49 --- /dev/null +++ b/src/misc/bochs-2.2.6-solaris-link.patch @@ -0,0 +1,11 @@ +--- 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 diff --git a/src/misc/bochs-2.2.6-solaris-tty.patch b/src/misc/bochs-2.2.6-solaris-tty.patch new file mode 100644 index 0000000..a9725dc --- /dev/null +++ b/src/misc/bochs-2.2.6-solaris-tty.patch @@ -0,0 +1,31 @@ +--- 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 --git a/src/misc/bochs-2.2.6-triple-fault.patch b/src/misc/bochs-2.2.6-triple-fault.patch new file mode 100644 index 0000000..f6d0871 --- /dev/null +++ b/src/misc/bochs-2.2.6-triple-fault.patch @@ -0,0 +1,57 @@ +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; diff --git a/src/misc/gcc-3.3.6-cross-howto b/src/misc/gcc-3.3.6-cross-howto new file mode 100644 index 0000000..ad25173 --- /dev/null +++ b/src/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/src/misc/gdb-macros b/src/misc/gdb-macros new file mode 100644 index 0000000..a0d0e54 --- /dev/null +++ b/src/misc/gdb-macros @@ -0,0 +1,120 @@ +# +# 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 <gback@cs.vt.edu>, 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 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 + +define debugpintos + target remote localhost:1234 +end +document debugpintos + Attach debugger to pintos process +end |
