-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·55 lines (41 loc) · 917 Bytes
/
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
#!/bin/bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
IMG="$DIR/build/bootfd.img"
SYM="$DIR/build/kernel"
function tell() { echo "$@"; $@; }
function main() {
# Parse command line
args=
[[ "$1" == "-v" ]] && shift 1 && args="-d int"
# Make the peoject
[[ "$(pwd)" != "$DIR" ]] && tell cd "$DIR"
tell make
[[ "$?" != "0" ]] && exit $?
# Run QEMU
qemu-system-i386 \
-no-shutdown \
-no-reboot \
-serial file:log \
$args -s -S \
-drive file=$IMG,index=0,if=floppy,format=raw \
2>/dev/null &
pid=$!
# Wait a little
sleep 0.5
# Setup GDB script
GDB_SCRIPT=$(mktemp)
cat << EOF > $GDB_SCRIPT
target remote localhost:1234
symbol-file $SYM
break kernel_main
break lbreak
continue
EOF
# Run GDB
echo "QEMU Running with pid=$pid"
gdb -q --command $GDB_SCRIPT
# Kill QEMU
[[ -d /proc/$pid ]] && tell kill -9 $pid
rm $GDB_SCRIPT
}
main $@