]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - src/debug.sh
400d2143c4c14d7bd182743b6aa96eaa5aaf8c92
[dragonblocks_alpha.git] / src / debug.sh
1 #! /bin/bash
2 if ! make -j$(nproc); then
3         exit 1
4 fi
5
6 DEBUG_DIR=/tmp/dragonblocks_alpha_debug_$$/
7 mkdir $DEBUG_DIR
8
9 echo "singleplayer" > $DEBUG_DIR/name
10
11 COMMON="set confirm off
12 handle SIGTERM nostop print pass
13 handle SIGPIPE nostop noprint pass
14 set height 0
15 set \$_exitcode=1
16 define hook-stop
17     if \$_exitcode == 0
18         quit
19     end
20 end
21 "
22
23 echo "$COMMON
24 run ::1 4000 < $DEBUG_DIR/name
25 " > $DEBUG_DIR/client_script
26
27 echo "$COMMON
28 run 4000
29 " > $DEBUG_DIR/server_script
30
31 konsole -e bash -c "
32         echo \$\$ > $DEBUG_DIR/server_pid
33         exec gdb --command $DEBUG_DIR/server_script ./DragonblocksServer
34 " & sleep 0.5
35
36 gdb --command $DEBUG_DIR/client_script ./Dragonblocks
37
38 kill `cat $DEBUG_DIR/server_pid`
39
40 rm -rf $DEBUG_DIR