-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlkhh-kernel-debug
More file actions
executable file
·81 lines (70 loc) · 1.63 KB
/
lkhh-kernel-debug
File metadata and controls
executable file
·81 lines (70 loc) · 1.63 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#! /bin/bash
_rootdir=${_rootdir:-"$(dirname "$(readlink -f "$0")")"}
_ver="0.0.1-dev"
#_author="Wei Peng <me@1pengw.com>"
source "${_rootdir}/_shared_prologue"
#
# parameters
#
declare -i instance=${instance:-1}
declare gdbremote=${_gdbtarget:-":1234"}
#
# getopt processing
#
function my_getopt_cont () {
local n_shift=1 # number of shifts in the outer loop; shift by 1 by default
case "$1" in
-i|--instance)
shift
instance=$1
n_shift=2
;;
-g|--gdbremote)
shift
gdbremote=$1
n_shift=2
;;
esac
return $n_shift
}
my_getopt "i:g:" "instance:,gdbremote:" "my_getopt_cont" "Debug a running kernel instance with GDB." "$(
cat <<END
[-i|--instance=<instance>] [-g|--gdbremote=<gdbremote>]
END
)" "$(
cat <<END
-i --instance Maximal number of kernel instances to prepare (default: $instance).
-g --gdbremote Parameter to GDB's "target remote" command (default: $gdbremote).
END
)" "$@"
ret=$?
eval set -- "$_getopt"
shift $ret
# sanity check
vecho 0 <<END
$(
dumpparam <<END1
$(
for name in instance gdbremote; do
echo "$name=$(echo $(eval "echo \$$name"))"
done
)
END1
)
END
build_dir="$LKHH_ARENA/build/$instance"
[[ -d "$build_dir" ]] || die 1 <<END
ERROR: $build_dir does not exist; consider "lkhh-init -i $instance" first.
END
vmlinux_path="$build_dir/vmlinux"
for i in "$vmlinux_path"; do
[[ -f "$i" ]] || die 1 <<END
ERROR: $i is not an existing regular file.
END
done
vecho 0 <<END
gdb -ex "target remote $gdbremote" "$vmlinux_path" $*
END
pushd "$build_dir"
gdb -ex "target remote $gdbremote" "$vmlinux_path" $*
popd