Files
linux-kernel-module-cheat/rungdb-user
Ciro Santilli 1cb056a995 common: simplify set_common_vars, rename to common_setup
Don't pass all arguments explicitly, just use existing vars.

Prefix all common_setup inputs and outputs with common_ to avoid name conflicts.
2018-08-09 06:59:52 +01:00

46 lines
1005 B
Bash
Executable File

#!/usr/bin/env bash
set -eu
. "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/common"
set -- ${cli_rungdb_user:-} "$@"
usage="$0 <exec-relative-path> [<brk-symbol>]"
gem5_opt=
while getopts a:gh OPT; do
case "$OPT" in
a)
common_arch="$OPTARG"
;;
g)
common_gem5=true
gem5_opt=-g
;;
h)
echo "$usage"
exit 0
;;
?)
exit 2
;;
esac
done
shift "$(($OPTIND - 1))"
executable_rel="$1"
shift
if [ "$#" -gt 0 ]; then
brk="'$1'"
shift
else
brk=
fi
common_setup
executable="${common_build_dir}/${executable_rel}"
addr="$("${common_root_dir}/runtc" readelf -h "$executable" | awk '/Entry/{ print $NF }' )"
ex="-ex \"add-symbol-file $executable $addr\""
# -X or else lx-symbols throws for arm:
# gdb.MemoryError: Cannot access memory at address 0xbf0040cc
# TODO understand better.
#
# Also, lx-symbols overrides the add-symbol-file commands.
cmd="./rungdb -a '${common_arch}' -b '${ex}' ${gem5_opt} -X ${brk}"
echo "$cmd"
eval "$cmd"