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