-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathled-memory-game-cross-debug
executable file
·62 lines (45 loc) · 1.2 KB
/
led-memory-game-cross-debug
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
#!/usr/bin/env sh
USAGE="Usage: $0 [-p PORT] REMOTE [GDBOPTS]"
GDB=../bin/aarch64-buildroot-linux-gnu-gdb
GAMENAME=led-memory-game
GAMEVER=0.0.1
BUILDFILE=../../build/$GAMENAME-$GAMEVER/$GAMENAME
STAGINGDIR=../../staging
DEBUGSETUP=../etc/led-memory-game-debugsetup.gdbinit
REMOTEPORT=7654
STARTDIR=$(pwd)
main() {
REMOTE="$1"
shift || err_msg "$USAGE"
simple_connect_test
#shellcheck disable=2164
cd "$(dirname "$0")"
[ -e $GDB ] || err_msg "Coldn't find $GDB"
[ -e $BUILDFILE ] || err_msg "Couldn't find $BUILDFILE"
[ -e $DEBUGSETUP ] || err_msg "Couldn't find $DEBUGSETUP"
[ -d $STAGINGDIR ] || err_msg "Couldn't find $STAGINGDIR"
$GDB $BUILDFILE -q -ex "set sy $STAGINGDIR" -ex "tar rem $REMOTE:$REMOTEPORT" -x "$DEBUGSETUP" "$@"
}
simple_connect_test() {
command -v nc 1>/dev/null || return # oof
timeout 3 nc -z $REMOTE $REMOTEPORT || err_msg "Couldn't find remote. Run the debug server on the target? idk"
}
check_opts() {
while getopts ":p:h" opt; do
case "${opt}" in
p)
REMOTEPORT=${OPTARG} ;;
h)
printf "%s\n" "$USAGE" && exit ;;
*)
err_msg "$USAGE" ;;
esac
done
shift $((OPTIND-1))
( main "$@" )
}
err_msg() {
printf "%s\n" "$1" >&2
exit 1
}
check_opts "$@"