summaryrefslogtreecommitdiffstats
path: root/pintos-progos/misc
diff options
context:
space:
mode:
Diffstat (limited to 'pintos-progos/misc')
-rw-r--r--pintos-progos/misc/0001-bochs-2.3.7-jitter.patch78
-rw-r--r--pintos-progos/misc/0002-bochs-2.3.7-triple-fault.patch87
-rw-r--r--pintos-progos/misc/0003-bochs-2.3.7-page-fault-segv.patch93
-rwxr-xr-xpintos-progos/misc/bochs-2.3.7-build.sh42
-rw-r--r--pintos-progos/misc/bochs-2.3.7-gcc43.patch12
-rw-r--r--pintos-progos/misc/bochs-2.3.7-linux3x.patch11
-rw-r--r--pintos-progos/misc/bochs-2.3.7-typos.patch24
-rw-r--r--pintos-progos/misc/gcc-3.3.6-cross-howto39
-rw-r--r--pintos-progos/misc/gdb-macros140
9 files changed, 526 insertions, 0 deletions
diff --git a/pintos-progos/misc/0001-bochs-2.3.7-jitter.patch b/pintos-progos/misc/0001-bochs-2.3.7-jitter.patch
new file mode 100644
index 0000000..44190e3
--- /dev/null
+++ b/pintos-progos/misc/0001-bochs-2.3.7-jitter.patch
@@ -0,0 +1,78 @@
1From 5e6cfa27ba6de331ecc142e7f65b4d1c2112b4e2 Mon Sep 17 00:00:00 2001
2From: Alex Busenius <s9albuse@stud.uni-saarland.de>
3Date: Mon, 27 Apr 2009 15:33:37 +0200
4Subject: bochs-2.3.7 jitter
5
6---
7 bochs.h | 2 ++
8 iodev/pit82c54.cc | 9 ++++++++-
9 main.cc | 8 ++++++++
10 3 files changed, 18 insertions(+), 1 deletions(-)
11
12diff --git a/bochs.h b/bochs.h
13index 2a643cd..75bcd96 100644
14--- a/bochs.h
15+++ b/bochs.h
16@@ -630,4 +630,6 @@ void bx_center_print(FILE *file, const char *line, unsigned maxwidth);
17
18 #endif
19
20+extern int jitter;
21+
22 #endif /* BX_BOCHS_H */
23diff --git a/iodev/pit82c54.cc b/iodev/pit82c54.cc
24index 0d65768..31ac041 100644
25--- a/iodev/pit82c54.cc
26+++ b/iodev/pit82c54.cc
27@@ -28,6 +28,7 @@
28
29 #include "iodev.h"
30 #include "pit82c54.h"
31+#include <stdlib.h>
32 #define LOG_THIS this->
33
34
35@@ -399,7 +400,13 @@ pit_82C54::clock(Bit8u cnum)
36 case 2:
37 if (thisctr.count_written) {
38 if (thisctr.triggerGATE || thisctr.first_pass) {
39- set_count(thisctr, thisctr.inlatch);
40+ unsigned n = thisctr.inlatch;
41+ if (jitter && n > 5) {
42+ n *= (double) rand() / RAND_MAX;
43+ if (n < 5)
44+ n = 5;
45+ }
46+ set_count(thisctr, n);
47 thisctr.next_change_time=(thisctr.count_binary-1) & 0xFFFF;
48 thisctr.null_count=0;
49 if (thisctr.inlatch==1) {
50diff --git a/main.cc b/main.cc
51index ebdf258..09cf661 100644
52--- a/main.cc
53+++ b/main.cc
54@@ -112,6 +112,7 @@ BOCHSAPI BX_MEM_C bx_mem;
55 #endif
56
57 char *bochsrc_filename = NULL;
58+int jitter = 0;
59
60 void bx_print_header ()
61 {
62@@ -541,6 +542,13 @@ int bx_init_main(int argc, char *argv[])
63 else if (!strcmp("-q", argv[arg])) {
64 SIM->get_param_enum(BXPN_BOCHS_START)->set(BX_QUICK_START);
65 }
66+ else if (!strcmp ("-j", argv[arg])) {
67+ if (++arg >= argc) BX_PANIC(("-j must be followed by a number"));
68+ else {
69+ jitter = 1;
70+ srand(atoi(argv[arg]));
71+ }
72+ }
73 else if (!strcmp("-f", argv[arg])) {
74 if (++arg >= argc) BX_PANIC(("-f must be followed by a filename"));
75 else bochsrc_filename = argv[arg];
76--
771.6.2.3
78
diff --git a/pintos-progos/misc/0002-bochs-2.3.7-triple-fault.patch b/pintos-progos/misc/0002-bochs-2.3.7-triple-fault.patch
new file mode 100644
index 0000000..c8698bd
--- /dev/null
+++ b/pintos-progos/misc/0002-bochs-2.3.7-triple-fault.patch
@@ -0,0 +1,87 @@
1From 356b7e781c815c70c992d58360caa42f1776d06b Mon Sep 17 00:00:00 2001
2From: Alex Busenius <s9albuse@stud.uni-saarland.de>
3Date: Mon, 27 Apr 2009 17:09:27 +0200
4Subject: bochs-2.3.7 triple fault
5
6---
7 cpu/cpu.h | 4 ++++
8 cpu/exception.cc | 7 +++++++
9 gdbstub.cc | 11 ++++++++---
10 3 files changed, 19 insertions(+), 3 deletions(-)
11
12diff --git a/cpu/cpu.h b/cpu/cpu.h
13index 7c7b11b..c47133a 100644
14--- a/cpu/cpu.h
15+++ b/cpu/cpu.h
16@@ -903,6 +903,10 @@ public: // for now...
17 #endif
18 Bit8u trace;
19
20+#if BX_GDBSTUB
21+ Bit8u ispanic;
22+#endif
23+
24 // for paging
25 struct {
26 bx_TLB_entry entry[BX_TLB_SIZE] BX_CPP_AlignN(16);
27diff --git a/cpu/exception.cc b/cpu/exception.cc
28index c3e3777..fb3abfc 100644
29--- a/cpu/exception.cc
30+++ b/cpu/exception.cc
31@@ -856,6 +856,13 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code, bx_bool trap)
32 // trap into debugger (similar as done when PANIC occured)
33 bx_debug_break();
34 #endif
35+#if BX_GDBSTUB
36+ if (bx_dbg.gdbstub_enabled) {
37+ fprintf(stderr, "Triple fault: stopping for gdb\n");
38+ BX_CPU_THIS_PTR ispanic = 1;
39+ longjmp(BX_CPU_THIS_PTR jmp_buf_env, 1);
40+ }
41+#endif
42 if (SIM->get_param_bool(BXPN_RESET_ON_TRIPLE_FAULT)->get()) {
43 BX_ERROR(("exception(): 3rd (%d) exception with no resolution, shutdown status is %02xh, resetting", vector, DEV_cmos_get_reg(0x0f)));
44 bx_pc_system.Reset(BX_RESET_SOFTWARE);
45diff --git a/gdbstub.cc b/gdbstub.cc
46index f58f866..bc5ed61 100644
47--- a/gdbstub.cc
48+++ b/gdbstub.cc
49@@ -471,7 +471,12 @@ static void debug_loop(void)
50 }
51
52 stub_trace_flag = 0;
53+ bx_cpu.ispanic = 0;
54 bx_cpu.cpu_loop(0);
55+ if (bx_cpu.ispanic)
56+ {
57+ last_stop_reason = GDBSTUB_EXECUTION_BREAKPOINT;
58+ }
59
60 DEV_vga_refresh();
61
62@@ -502,19 +507,19 @@ static void debug_loop(void)
63
64 BX_INFO(("stepping"));
65 stub_trace_flag = 1;
66+ bx_cpu.ispanic = 0;
67 bx_cpu.cpu_loop(0);
68 DEV_vga_refresh();
69 stub_trace_flag = 0;
70 BX_INFO(("stopped with %x", last_stop_reason));
71 buf[0] = 'S';
72- if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT ||
73- last_stop_reason == GDBSTUB_TRACE)
74+ if (last_stop_reason == GDBSTUB_TRACE && !bx_cpu.ispanic)
75 {
76 write_signal(&buf[1], SIGTRAP);
77 }
78 else
79 {
80- write_signal(&buf[1], SIGTRAP);
81+ write_signal(&buf[1], SIGSEGV);
82 }
83 put_reply(buf);
84 break;
85--
861.6.2.3
87
diff --git a/pintos-progos/misc/0003-bochs-2.3.7-page-fault-segv.patch b/pintos-progos/misc/0003-bochs-2.3.7-page-fault-segv.patch
new file mode 100644
index 0000000..8b6e090
--- /dev/null
+++ b/pintos-progos/misc/0003-bochs-2.3.7-page-fault-segv.patch
@@ -0,0 +1,93 @@
1From 314833401978558db06bbb4f4f76e4dc7b603744 Mon Sep 17 00:00:00 2001
2From: Alex Busenius <s9albuse@stud.uni-saarland.de>
3Date: Mon, 27 Apr 2009 16:33:54 +0200
4Subject: bochs-2.3.7 page fault segv
5
6---
7 bochs.h | 1 +
8 cpu/exception.cc | 4 ++++
9 gdbstub.cc | 17 ++++++++++++++++-
10 3 files changed, 21 insertions(+), 1 deletions(-)
11
12diff --git a/bochs.h b/bochs.h
13index 75bcd96..657c7b8 100644
14--- a/bochs.h
15+++ b/bochs.h
16@@ -433,6 +433,7 @@ BOCHSAPI extern logfunc_t *genlog;
17 void bx_gdbstub_init(void);
18 void bx_gdbstub_break(void);
19 int bx_gdbstub_check(unsigned int eip);
20+void bx_gdbstub_exception(unsigned int nr);
21 #define GDBSTUB_STOP_NO_REASON (0xac0)
22
23 #if BX_SUPPORT_SMP
24diff --git a/cpu/exception.cc b/cpu/exception.cc
25index fb3abfc..8dac5ca 100644
26--- a/cpu/exception.cc
27+++ b/cpu/exception.cc
28@@ -1046,6 +1046,10 @@ void BX_CPU_C::exception(unsigned vector, Bit16u error_code, bx_bool trap)
29
30 BX_CPU_THIS_PTR errorno++;
31
32+#if BX_GDBSTUB
33+ bx_gdbstub_exception(vector);
34+#endif
35+
36 if (real_mode()) {
37 // not INT, no error code pushed
38 BX_CPU_THIS_PTR interrupt(vector, 0, 0, 0);
39diff --git a/gdbstub.cc b/gdbstub.cc
40index bc5ed61..ad59373 100644
41--- a/gdbstub.cc
42+++ b/gdbstub.cc
43@@ -47,6 +47,7 @@ static int last_stop_reason = GDBSTUB_STOP_NO_REASON;
44 #define GDBSTUB_EXECUTION_BREAKPOINT (0xac1)
45 #define GDBSTUB_TRACE (0xac2)
46 #define GDBSTUB_USER_BREAK (0xac3)
47+#define GDBSTUB_EXCEPTION_0E (0xac4)
48
49 static bx_list_c *gdbstub_list;
50 static int listen_socket_fd;
51@@ -323,6 +324,12 @@ int bx_gdbstub_check(unsigned int eip)
52 return GDBSTUB_STOP_NO_REASON;
53 }
54
55+void bx_gdbstub_exception(unsigned int nr)
56+{
57+ if (nr == 0x0e)
58+ last_stop_reason = GDBSTUB_EXCEPTION_0E;
59+}
60+
61 static int remove_breakpoint(unsigned int addr, int len)
62 {
63 unsigned int i;
64@@ -493,6 +500,10 @@ static void debug_loop(void)
65 {
66 write_signal(&buf[1], SIGTRAP);
67 }
68+ else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
69+ {
70+ write_signal(&buf[1], SIGSEGV);
71+ }
72 else
73 {
74 write_signal(&buf[1], 0);
75@@ -517,10 +528,14 @@ static void debug_loop(void)
76 {
77 write_signal(&buf[1], SIGTRAP);
78 }
79- else
80+ else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
81 {
82 write_signal(&buf[1], SIGSEGV);
83 }
84+ else
85+ {
86+ write_signal(&buf[1], 0);
87+ }
88 put_reply(buf);
89 break;
90 }
91--
921.6.2.3
93
diff --git a/pintos-progos/misc/bochs-2.3.7-build.sh b/pintos-progos/misc/bochs-2.3.7-build.sh
new file mode 100755
index 0000000..57e35d1
--- /dev/null
+++ b/pintos-progos/misc/bochs-2.3.7-build.sh
@@ -0,0 +1,42 @@
1#! /bin/sh -e
2
3if test -z "$SRCDIR" || test -z "$PINTOSDIR" || test -z "$DSTDIR"; then
4 echo "usage: env SRCDIR=<srcdir> PINTOSDIR=<srcdir> DSTDIR=<dstdir> sh $0"
5 echo " where <srcdir> contains bochs-2.3.7.tar.gz"
6 echo " and <pintosdir> is the root of the pintos source tree"
7 echo " and <dstdir> is the installation prefix (e.g. /usr/local)"
8 exit 1
9fi
10
11cd /tmp
12mkdir bochs-pintos-$$
13cd bochs-pintos-$$
14mkdir bochs-2.3.7
15tar xzf $SRCDIR/bochs-2.3.7.tar.gz
16cd bochs-2.3.7
17cat $PINTOSDIR/src/misc/0001-bochs-2.3.7-jitter.patch | patch -p1
18cat $PINTOSDIR/src/misc/0002-bochs-2.3.7-triple-fault.patch | patch -p1
19cat $PINTOSDIR/src/misc/0003-bochs-2.3.7-page-fault-segv.patch | patch -p1
20cat $PINTOSDIR/src/misc/bochs-2.3.7-gcc43.patch | patch -p1
21cat $PINTOSDIR/src/misc/bochs-2.3.7-typos.patch | patch -p1
22cat $PINTOSDIR/src/misc/bochs-2.3.7-linux3x.patch | patch -p1
23autoconf
24
25CFGOPTIONAL="--enable-large-pages --enable-mmx --enable-usb --enable-pci --enable-pcidev --enable-acpi --enable-global-pages --enable-show-ips"
26CFGOPTIMIZE="--enable-all-optimizations --enable-guest2host-tlb --enable-repeat-speedups --enable-trace-cache --enable-icache --enable-fast-function-calls --enable-idle-hack "
27CFGOPTS="--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"
28mkdir plain &&
29 cd plain &&
30 ../configure $CFGOPTS --enable-gdb-stub &&
31# make -j3 &&
32 make && echo "done building plain" &&
33 sudo make install &&
34 cd .. &&
35mkdir with-dbg &&
36 cd with-dbg &&
37 ../configure --enable-debugger $CFGOPTS &&
38 # make -j3 &&
39 make && echo "done building with-dbg" &&
40 sudo cp -v bochs $DSTDIR/bin/bochs-dbg &&
41 cd .. &&
42 echo "SUCCESS"
diff --git a/pintos-progos/misc/bochs-2.3.7-gcc43.patch b/pintos-progos/misc/bochs-2.3.7-gcc43.patch
new file mode 100644
index 0000000..4646edf
--- /dev/null
+++ b/pintos-progos/misc/bochs-2.3.7-gcc43.patch
@@ -0,0 +1,12 @@
1--- bochs-2.3.7.orig/bx_debug/symbols.cc 2008/03/30 14:32:14 1.11
2+++ bochs-2.3.7/bx_debug/symbols.cc 2008/06/16 17:09:52 1.12
3@@ -95,6 +95,9 @@
4 #endif
5
6 using namespace std;
7+#ifdef __GNUC__
8+using namespace __gnu_cxx;
9+#endif
10
11 struct symbol_entry_t
12 {
diff --git a/pintos-progos/misc/bochs-2.3.7-linux3x.patch b/pintos-progos/misc/bochs-2.3.7-linux3x.patch
new file mode 100644
index 0000000..1c84060
--- /dev/null
+++ b/pintos-progos/misc/bochs-2.3.7-linux3x.patch
@@ -0,0 +1,11 @@
1--- a/configure.in 2012-01-03 11:12:22.104612131 +0100
2+++ b/configure.in 2012-01-03 11:13:05.507941106 +0100
3@@ -715,7 +715,7 @@ AC_ARG_ENABLE(pcidev,
4 PCIDEV_MODULE_MAKE_ALL="all-kernel24"
5 KERNEL_MODULE_SUFFIX="o"
6 ;;
7- 2.6*)
8+ 2.6*|3*)
9 PCIDEV_MODULE_MAKE_ALL="all-kernel26"
10 KERNEL_MODULE_SUFFIX="ko"
11 ;;
diff --git a/pintos-progos/misc/bochs-2.3.7-typos.patch b/pintos-progos/misc/bochs-2.3.7-typos.patch
new file mode 100644
index 0000000..c9fb168
--- /dev/null
+++ b/pintos-progos/misc/bochs-2.3.7-typos.patch
@@ -0,0 +1,24 @@
1diff -NaurwB bochs-2.3.7.orig/cpu/ia_opcodes.h bochs-2.3.7/cpu/ia_opcodes.h
2--- bochs-2.3.7.orig/cpu/ia_opcodes.h 2008-05-30 22:35:08.000000000 +0200
3+++ bochs-2.3.7/cpu/ia_opcodes.h 2008-06-04 14:56:46.000000000 +0200
4@@ -891,7 +891,7 @@
5 bx_define_opcode(BX_IA_PF2ID_PqQq, BX_CPU_C::PF2ID_PqQq)
6 bx_define_opcode(BX_IA_PF2IW_PqQq, BX_CPU_C::PF2IW_PqQq)
7 bx_define_opcode(BX_IA_PFACC_PqQq, BX_CPU_C::PFACC_PqQq)
8-bx_define_opcode(BX_IA_PFADD_PqQq, BX_CPU_C::BX_PFADD_PqQq)
9+bx_define_opcode(BX_IA_PFADD_PqQq, BX_CPU_C::PFADD_PqQq)
10 bx_define_opcode(BX_IA_PFCMPEQ_PqQq, BX_CPU_C::PFCMPEQ_PqQq)
11 bx_define_opcode(BX_IA_PFCMPGE_PqQq, BX_CPU_C::PFCMPGE_PqQq)
12 bx_define_opcode(BX_IA_PFCMPGT_PqQq, BX_CPU_C::PFCMPGT_PqQq)
13diff -NaurwB bochs-2.3.7.orig/iodev/iodebug.h bochs-2.3.7/iodev/iodebug.h
14--- bochs-2.3.7.orig/iodev/iodebug.h 2008-05-01 22:46:58.000000000 +0200
15+++ bochs-2.3.7/iodev/iodebug.h 2008-06-04 14:45:50.000000000 +0200
16@@ -18,7 +18,7 @@
17 virtual void init(void);
18 virtual void reset (unsigned type) {}
19 static void mem_write(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data);
20- static void mem_read(BX_CPU_C *cpu, bx_phy_addressu addr, unsigned len, void *data);
21+ static void mem_read(BX_CPU_C *cpu, bx_phy_address addr, unsigned len, void *data);
22
23 private:
24 static Bit32u read_handler(void *this_ptr, Bit32u address, unsigned io_len);
diff --git a/pintos-progos/misc/gcc-3.3.6-cross-howto b/pintos-progos/misc/gcc-3.3.6-cross-howto
new file mode 100644
index 0000000..ad25173
--- /dev/null
+++ b/pintos-progos/misc/gcc-3.3.6-cross-howto
@@ -0,0 +1,39 @@
1Here are the commands we used to build and install the SPARC
2cross-compiler:
3
4PINTOSROOT=$HOME/private/pintos
5
6PREFIX=/usr/class/cs140/`uname -m`
7PATH=$PATH:$PREFIX/bin
8TMP=`pwd`
9
10wget ftp://ftp.gnu.org/pub/gnu/binutils/binutils-2.15.tar.bz2
11wget ftp://sources.redhat.com/pub/newlib/newlib-1.13.0.tar.gz
12wget ftp://ftp.gnu.org/pub/gnu/gcc/gcc-3.3.6/gcc-core-3.3.6.tar.bz2
13wget ftp://ftp.gnu.org/pub/gnu/gdb/gdb-6.3.tar.bz2
14
15bzcat binutils-2.15.tar.bz2 | tar x
16tar xzf newlib-1.13.0.tar.gz
17bzcat gcc-core-3.3.6.tar.bz2 | tar x
18bzcat gdb-6.3.tar.bz2 | tar x
19
20cd $TMP/binutils-2.15
21mkdir i386
22cd i386
23../configure --target=i386-elf --prefix=$PREFIX
24make LDFLAGS=-lintl
25make install
26
27cd $TMP/gcc-3.3.6
28mkdir i386
29cd i386
30../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
31make
32make install
33
34cd $TMP/gdb-6.3
35mkdir i386
36cd i386
37../configure --target=i386-elf --prefix=$PREFIX --disable-tui
38make LDFLAGS=-lintl
39make install
diff --git a/pintos-progos/misc/gdb-macros b/pintos-progos/misc/gdb-macros
new file mode 100644
index 0000000..a0b68c3
--- /dev/null
+++ b/pintos-progos/misc/gdb-macros
@@ -0,0 +1,140 @@
1#
2# A set of useful macros that can help debug Pintos.
3#
4# Include with "source" cmd in gdb.
5# Use "help user-defined" for help.
6#
7# Author: Godmar Back <gback@cs.vt.edu>, Feb 2006
8#
9# $Id: gdb-macros,v 1.1 2006-04-07 18:29:34 blp Exp $
10#
11
12# for internal use
13define offsetof
14 set $rc = (char*)&((struct $arg0 *)0)->$arg1 - (char*)0
15end
16
17define list_entry
18 offsetof $arg1 $arg2
19 set $rc = ((struct $arg1 *) ((uint8_t *) ($arg0) - $rc))
20end
21
22# dump a Pintos list
23define dumplist
24 set $list = $arg0
25 set $e = $list->head.next
26 set $i = 0
27 while $e != &(($arg0).tail)
28 list_entry $e $arg1 $arg2
29 set $l = $rc
30 printf "pintos-debug: dumplist #%d: %p ", $i++, $l
31 output *$l
32 set $e = $e->next
33 printf "\n"
34 end
35end
36
37document dumplist
38 Dump the content of a Pintos list,
39 invoke as dumplist name_of_list name_of_struct name_of_elem_in_list_struct
40end
41
42# print a thread's backtrace, given a pointer to the struct thread *
43define btthread
44 if $arg0 == ($esp - ((unsigned)$esp % 4096))
45 bt
46 else
47 set $saveEIP = $eip
48 set $saveESP = $esp
49 set $saveEBP = $ebp
50
51 set $esp = ((struct thread *)$arg0)->stack
52 set $ebp = ((void**)$esp)[2]
53 set $eip = ((void**)$esp)[4]
54
55 bt
56
57 set $eip = $saveEIP
58 set $esp = $saveESP
59 set $ebp = $saveEBP
60 end
61end
62document btthread
63 Show the backtrace of a thread,
64 invoke as btthread pointer_to_struct_thread
65end
66
67# print backtraces associated with all threads in a list
68define btthreadlist
69 set $list = $arg0
70 set $e = $list->head.next
71 while $e != &(($arg0).tail)
72 list_entry $e thread $arg1
73 printf "pintos-debug: dumping backtrace of thread '%s' @%p\n", \
74 ((struct thread*)$rc)->name, $rc
75 btthread $rc
76 set $e = $e->next
77 printf "\n"
78 end
79end
80document btthreadlist
81 Given a list of threads, print each thread's backtrace
82 invoke as btthreadlist name_of_list name_of_elem_in_list_struct
83end
84
85# print backtraces of all threads (based on 'all_list' all threads list)
86define btthreadall
87 btthreadlist all_list allelem
88end
89document btthreadall
90 Print backtraces of all threads
91end
92
93# print a correct backtrace by adjusting $eip
94# this works best right at intr0e_stub
95define btpagefault
96 set $saveeip = $eip
97 set $eip = ((void**)$esp)[1]
98 backtrace
99 set $eip = $saveeip
100end
101document btpagefault
102 Print a backtrace of the current thread after a pagefault
103end
104
105# invoked whenever the program stops
106define hook-stop
107 # stopped at stub #0E = #14 (page fault exception handler stub)
108 if ($eip == intr0e_stub)
109 set $savedeip = ((void**)$esp)[1]
110 # if this was in user mode, the OS should handle it
111 # either handle the page fault or terminate the process
112 if ($savedeip < 0xC0000000)
113 printf "pintos-debug: a page fault exception occurred in user mode\n"
114 printf "pintos-debug: hit 'c' to continue, or 's' to step to intr_handler\n"
115 else
116 # if this was in kernel mode, a stack trace might be useful
117 printf "pintos-debug: a page fault occurred in kernel mode\n"
118 btpagefault
119 end
120 end
121end
122
123# load symbols for a Pintos user program
124define loadusersymbols
125 shell objdump -h $arg0 | awk '/.text/ { print "add-symbol-file $arg0 0x"$4 }' > .loadsymbols
126 source .loadsymbols
127 shell rm -f .loadsymbols
128end
129document loadusersymbols
130 Load the symbols contained in a user program's executable.
131 Example:
132 loadusersymbols tests/userprog/exec-multiple
133end
134
135define debugpintos
136 target remote localhost:1234
137end
138document debugpintos
139 Attach debugger to pintos process
140end