aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorklaar36 <klas.arvidsson@liu.se>2017-05-19 15:05:06 +0200
committerklaar36 <klas.arvidsson@liu.se>2017-05-19 15:05:06 +0200
commit3b39301d34d7a000325a42bbcfe880b53ac26154 (patch)
tree9f5a239bf47da78358645c2ad1136972121cece7 /src
parent6fea0f8ce4ba0d08a414a1650c829afbef285f70 (diff)
downloadpintos-rs-3b39301d34d7a000325a42bbcfe880b53ac26154.tar.gz
imported misc scripts
Diffstat (limited to 'src')
-rwxr-xr-xsrc/utils/debugpintos7
-rw-r--r--src/utils/gdb-macros120
-rwxr-xr-xsrc/utils/mkdtemp7
-rwxr-xr-xsrc/utils/pintos-check-forever79
-rwxr-xr-xsrc/utils/pintos-pfs-test55
-rwxr-xr-xsrc/utils/set-svn-ignore16
6 files changed, 284 insertions, 0 deletions
diff --git a/src/utils/debugpintos b/src/utils/debugpintos
new file mode 100755
index 0000000..8dfdc77
--- /dev/null
+++ b/src/utils/debugpintos
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+if command -v mapsocket >/dev/null 2>&1; then
+ exec mapsocket -m 1234 dynamic spintos --gdb "$@"
+else
+ exec pintos --gdb "$@"
+fi
diff --git a/src/utils/gdb-macros b/src/utils/gdb-macros
new file mode 100644
index 0000000..a0d0e54
--- /dev/null
+++ b/src/utils/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
diff --git a/src/utils/mkdtemp b/src/utils/mkdtemp
new file mode 100755
index 0000000..b4cb2a1
--- /dev/null
+++ b/src/utils/mkdtemp
@@ -0,0 +1,7 @@
+#!/usr/bin/python
+
+import tempfile
+from os.path import expanduser
+
+home = expanduser("~")
+tempfile.mkdtemp(prefix='TDIU16', dir=home)
diff --git a/src/utils/pintos-check-forever b/src/utils/pintos-check-forever
new file mode 100755
index 0000000..d8223e2
--- /dev/null
+++ b/src/utils/pintos-check-forever
@@ -0,0 +1,79 @@
+#!/bin/bash
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ printf "Usage: $0 [-a]\nRun with -a to abort on first error.\n";
+ exit;
+fi
+
+PWD=`pwd`;
+DIR=`basename $PWD`;
+ABORT_ON_FAIL="false"
+FAIL="true"
+
+for i in $*; do
+ if [ "$i" = "-a" ] ; then
+ ABORT_ON_FAIL="true"
+ fi
+done
+
+if [ "_$DIR" != "_userprog" ] ; then
+ printf "You must be in userprog directory\n";
+ exit;
+fi
+
+if expr $(uname -s) : 'Linux.*' > /dev/null; then
+ MAKE=make
+else
+ MAKE=gmake
+fi
+
+let i=1;
+while (true); do
+
+ printf "Test run %2d started ...\n" $i;
+
+ # Clear previous test results
+ find ./build -name '*.allput' -exec rm {} \; ;
+ find ./build -name '*.output' -exec rm {} \; ;
+ find ./build -name '*.errors' -exec rm {} \; ;
+ find ./build -name '*.result' -exec rm {} \; ;
+
+ # Is it failsafe to run several Pintos concurrently?
+ # YES!! tests use different fs.dsk in /tmp !
+ FAIL="false"
+ if ! nice -n 20 ${MAKE} -j8 check > check.tmp 2> check.err ; then
+ cat check.err
+ printf "ERROR: '${MAKE} check' failed.\n"
+ FAIL="true"
+ fi
+
+ if grep FAIL check.tmp ; then
+ FAIL="true"
+ printf "ERROR: 'grep found FAIL in result file'\n"
+ printf "ERROR: 'saving result files...'\n"
+
+ for test in $(grep '^FAIL tests/.*$' check.tmp | sort | uniq | cut -d' ' -f2 ) ; do
+ printf "mv -f build/${test}.allput build/${test}.allput.${i}\n"
+ mv -f build/${test}.allput build/${test}.allput.${i}
+ mv -f build/${test}.output build/${test}.output.${i}
+ mv -f build/${test}.errors build/${test}.errors.${i}
+ mv -f build/${test}.result build/${test}.result.${i}
+ done
+ fi
+
+ printf "Test run %2d DONE.\n" $i;
+
+ if [ "$FAIL" == "true" ] && [ "$ABORT_ON_FAIL" = "true" ] ; then
+ break;
+ fi
+ let ++i;
+done
+
+printf "Completed $i test runs.\n";
+printf "The result of last run is in 'check.tmp'\n";
+printf "The result of failed runs is in respective test result files.\n";
+
+printf "Consider erasing old test failures:\n";
+printf "find ./build -name '*.allput.*' -exec rm {} \;\n"
+printf "find ./build -name '*.output.*' -exec rm {} \;\n"
+printf "find ./build -name '*.errors.*' -exec rm {} \;\n"
+printf "find ./build -name '*.result.*' -exec rm {} \;\n"
diff --git a/src/utils/pintos-pfs-test b/src/utils/pintos-pfs-test
new file mode 100755
index 0000000..4973ee2
--- /dev/null
+++ b/src/utils/pintos-pfs-test
@@ -0,0 +1,55 @@
+#!/bin/bash -
+
+if [ "$1" = "-h" -o "$1" = "--help" ]; then
+ printf "Usage: $0 number_of_runs time_limit_in_seconds\n";
+ exit;
+fi
+
+PWD=`pwd`;
+DIR=`basename $PWD`;
+
+if [ "_$DIR" != "_userprog" ] ; then
+ printf "You must be in userprog directory\n";
+ exit;
+fi
+
+if expr $(uname -s) : 'Linux.*' > /dev/null; then
+ MAKE=make
+else
+ MAKE=gmake
+fi
+
+$MAKE
+$MAKE -C ../examples
+TIMES=$(grep TIMES ../examples/pfs.h)
+EXECS=$(grep -c '^.*exec.*pfs_reader.*$' ../examples/pfs.c)
+
+declare -i COUNT=${1:-1}
+
+TIMEOUT=${2:-180}
+
+declare -i i=0;
+
+while (( i < ${COUNT} )); do
+
+ \rm -f messages;
+
+ pintos -v -k --fs-disk=2 -T ${TIMEOUT} --qemu -p ../examples/pfs -a pfs -p ../examples/pfs_writer -a pfs_writer -p ../examples/pfs_reader -a pfs_reader -g messages -- -f -q run pfs
+
+ COOL=$(grep -c '^cool$' messages)
+ HOT=$(grep -v '^cool$' messages | grep -v -c '^\0*$')
+
+ grep -v '^cool$' messages
+
+ printf "\nSUMMARY ------------------------------------------------------\n"
+ printf "The 'messages' file have ${COOL} lines with the word 'cool'.\n"
+ printf "The 'messages' file have ${HOT} lines with other content.\n"
+ printf "pfs.c executes ${EXECS} 'pfs_reader' processes concurrently.\n"
+ printf "pfs.h contain: ${TIMES}\n"
+ printf "What should be in 'messages' when everything is correct?\n"
+ printf "%s\n" "--------------------------------------------------------------"
+
+ sleep 5
+
+ let ++i;
+done
diff --git a/src/utils/set-svn-ignore b/src/utils/set-svn-ignore
new file mode 100755
index 0000000..dadbc8c
--- /dev/null
+++ b/src/utils/set-svn-ignore
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+# Sets ignore properties in the repository from information in
+# .cvsignore files.
+
+echo cd "$1"
+cd "$1"
+
+for file in `find . -name .cvsignore`; do
+ echo svn propset svn:ignore -F $file `dirname $file` ;
+ svn propset svn:ignore -F $file `dirname $file` ;
+done
+
+echo svn -m "Added ignore properties" commit
+svn -m "Added ignore properties" commit
+