-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·67 lines (57 loc) · 1.33 KB
/
run.sh
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
#!/bin/bash
# This script launches the kernel under QEMU. run.sh includes support for a
# number of commandline options. See 'run.sh -h' for details.
source config.sh
DEBUG="OFF"
Help()
{
echo "usage: run.sh [-g]"
echo "options:"
echo "g run the kernel in debug mode"
echo "h print this help message"
}
RunDebugSession()
{
echo -e "Open a new terminal and attach a GDB session to begin debugging:"
echo -e "\t\$ cd \$LINUX_OBJ_DIR"
echo -e "\t\$ gdb vmlinux"
echo -e "\t(gdb) target remote localhost:1234"
qemu-system-x86_64 \
-kernel "${LDD3_BIN_DIR}/bzImage" \
-initrd "${LDD3_BIN_DIR}/initramfs-busybox-x86.cpio.gz" \
-nographic \
-append "console=ttyS0,115200 nokaslr" \
-s \
-S \
-enable-kvm
}
RunNormalSession()
{
qemu-system-x86_64 \
-kernel "${LDD3_BIN_DIR}/bzImage" \
-initrd "${LDD3_BIN_DIR}/initramfs-busybox-x86.cpio.gz" \
-nographic \
-append "console=ttyS0,115200" \
-enable-kvm
}
Main()
{
if [ "$DEBUG" = "ON" ]
then
RunDebugSession
else
RunNormalSession
fi
}
while getopts ":hg" flag
do
case "${flag}" in
g) DEBUG="ON";;
h) Help
exit;;
\?) echo "error: invalid option"
Help
exit 1
esac
done
Main