-
Notifications
You must be signed in to change notification settings - Fork 9
/
xkdb_builder
executable file
·70 lines (55 loc) · 2.08 KB
/
xkdb_builder
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
##### SET ARCHITECTURE [x86 or ARM] #####
SYSARCH="x86" #
#########################################
##### SET SEMESTER [semesterYear] ######
SEM="spring2021" #
#########################################
if [ $# -eq 1 ] && [ "$1" == "--help" ]; then
echo "To run the build tool: ./xkdb_builder [xinu_dir] [xkdb_dir]"
echo "To update XKDB: ./xkdb_builder [xkdb_dir] --pull"
exit 1
fi
if [ $# -ne 2 ]; then
echo "usage: ./xkdb_builder [xinu_dir] [xkdb_dir]"
echo "To update xkdb, run ./xkdb_builder [xkdb_dir] --pull"
exit 1
fi
if [ "$SYSARCH" != "x86" ] && [ "$SYSARCH" != "ARM" ]; then
echo "Incorrect Architecture! Must be either x86 or ARM!"
exit 1
fi
if [ "$2" == "--pull" ]; then
echo "Updating XKDB in directory $1!"
cd $1
git pull
echo "XKDB has been updated!"
exit 1
fi
XINU_DIR=$1/xinu-$SEM
XKDB_DIR=$2
if [ "$SYSARCH" == "x86" ]; then
touch $XINU_DIR/system/i386-stub.c
cp $XKDB_DIR/stub/i386-stub.c $XINU_DIR/system/i386-stub.c
elif [ "$SYSARCH" == "ARM" ]; then
touch $XINU_DIR/system/arm-stub.c
cp $XKDB_DIR/stub/arm-stub.c $XINU_DIR/system/arm-stub.c
fi
cp $XINU_DIR/system/initialize.c $XINU_DIR/system/.initialize.c.bkp
sed -i '/local\tprocess startup(void);\t\/\* Process to finish startup tasks\t\*/a \
\
// XKDB extern declarations \
extern void set_debug_traps(); \
extern void breakpoint();' $XINU_DIR/system/initialize.c
cp $XINU_DIR/system/initialize.c $XINU_DIR/system/.initialize.c.bkp2
sed -i '/readylist = newqueue();/a \
\
set_debug_traps();\
breakpoint();' $XINU_DIR/system/initialize.c
cp $XINU_DIR/compile/Makefile $XINU_DIR/compile/.Makefile.bkp
sed -i '/CFLAGS = -march=i586 -m32 -fno-builtin -fno-stack-protector -nostdlib -c -Wall -O0 ${DEFS} ${INCLUDE}/c\CFLAGS = -g -march=i586 -m32 -fno-builtin -fno-stack-protector -nostdlib -c -Wall -O0 ${DEFS} ${INCLUDE}' $XINU_DIR/compile/Makefile
cd $XINU_DIR/compile
make clean
make rebuild
make
echo -e "XKDB has been setup fully! When you want to debug, open a new terminal window, get on to the same xinu instance ($(uname -a)), and then run gdb -x ~/.xkdb."