mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-13 20:12:26 +00:00
This is cleaner as it removes yet another .gitignore rule and allows for one command per arch. This was prompted by the recent Docker patch creating files as root, which then breaks future host runs. Also separate all arguments by newlines. This: - makes it much easier to minimize when reporting QEMU bugs - shows the full command on the screen despite line wrapping being turned off by one of the annoying emulators, to be investigated. The commands are not yet pristine, because: - there are some leading spaces - options not sorted but it is already a huge improvement, and those operations are now be easy from Vim. The general strategy is: - end every variable containing a command with a newline - when expanding such variables, don't add an extra newline
95 lines
1.9 KiB
Bash
Executable File
95 lines
1.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eu
|
|
. common
|
|
set -- ${cli_rungdb:-} "$@"
|
|
after=
|
|
before=
|
|
gem5=false
|
|
lx_symbols="-ex 'lx-symbols ../kernel_module-1.0/' \\
|
|
"
|
|
kgdb=false
|
|
while getopts A:a:b:gkL OPT; do
|
|
case "$OPT" in
|
|
A)
|
|
after="$OPTARG"
|
|
;;
|
|
a)
|
|
arch="$OPTARG"
|
|
;;
|
|
b)
|
|
before="$OPTARG"
|
|
;;
|
|
g)
|
|
gem5=true
|
|
;;
|
|
k)
|
|
kgdb=true
|
|
;;
|
|
L)
|
|
lx_symbols=
|
|
;;
|
|
?)
|
|
exit 2
|
|
;;
|
|
esac
|
|
done
|
|
shift "$(($OPTIND - 1))"
|
|
if [ "$#" -gt 0 ]; then
|
|
brk="-ex 'break ${1}' \\
|
|
"
|
|
shift
|
|
else
|
|
brk=
|
|
fi
|
|
if "$gem5"; then
|
|
port=7000
|
|
else
|
|
port=1234
|
|
fi
|
|
set_common_vars "$arch" "$gem5"
|
|
gdb="${host_dir}/usr/bin/${arch}-linux-gdb \\
|
|
${before}"
|
|
cd "${build_dir}/linux-custom/"
|
|
if "$kgdb"; then
|
|
cmd="\
|
|
${gdb} \
|
|
-q \\
|
|
-ex 'add-auto-load-safe-path $(pwd)' \\
|
|
-ex 'file vmlinux' \\
|
|
-ex 'target remote localhost:${port}' \\
|
|
"
|
|
else
|
|
# ## lx-symbols
|
|
#
|
|
# ### lx-symbols after continue
|
|
#
|
|
# lx symbols must be run after continue.
|
|
#
|
|
# running it immediately after the connect on the bootloader leads to failure,
|
|
# likely because kernel structure on which it depends are not yet available.
|
|
#
|
|
# With this setup, continue runs, and lx-symbols only runs when a break happens,
|
|
# either by hitting the breakpoint, or by entering Ctrl + C.
|
|
#
|
|
# Sure, if the user sets a break on a raw address of the bootloader,
|
|
# problems will still arise, but let's think about that some other time.
|
|
#
|
|
# ### lx-symbols autoload
|
|
#
|
|
# The lx-symbols commands gets loaded through the file vmlinux-gdb.py
|
|
# which gets put on the kernel build root when python debugging scripts are enabled.
|
|
cmd="\
|
|
${gdb} \
|
|
-q \\
|
|
-ex 'add-auto-load-safe-path $(pwd)' \\
|
|
-ex 'file vmlinux' \\
|
|
-ex 'target remote localhost:${port}' \\
|
|
${brk} \
|
|
-ex 'continue' \\
|
|
${lx_symbols} \
|
|
"
|
|
fi
|
|
cmd="$cmd $after"
|
|
echo "$cmd" | tee "${out_arch_dir}/rungdb.sh"
|
|
eval "$cmd"
|