blob: 2555d1397490e2c17c8ff4292aa68b3ceeeb601b [file] [log] [blame]
#!/usr/bin/env bash
# Copyright 2020 The Android KVM Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
source "$(dirname "${BASH_SOURCE[0]}")/../common.inc"
default_var GDB "${TOOLCHAINS_GDB_BIN}"
default_var KERNEL_ELF "${LINUX_OUT_ELF}"
default_var VERBOSE 0
function usage() {
cat <<EOF
Usage: $0 [-h] [-v] [-e GDB] [-k KERNEL_ELF]
-h output this help text
-v print invoked command
-e GDB binary
-k kernel ELF file (vmlinux for Linux)
EOF
}
while getopts ":e:k:vh" OPT; do
case "${OPT}" in
e) GDB="${OPTARG}" ;;
k) KERNEL_ELF="${OPTARG}" ;;
v) VERBOSE=1 ;;
h)
usage
exit 0
;;
\?)
echo "Invalid option: ${!OPTIND}" 1>&2
usage 1>&2
exit 1
;;
:)
echo "Invalid option: -${OPTARG} requires an argument" 1>&2
usage 1>&2
exit 1
;;
esac
done
shift $((OPTIND -1))
if [ $# -ne 0 ]; then
echo "Unrecognized options: $@" 1>&2
usage 1>&2
exit 1
fi
INPUT="$(dirname "${BASH_SOURCE[0]}")/aarch64.gdb"
OUTPUT=$(mktemp)
[ "${VERBOSE}" -eq 1 ] && set -x
sed "s|##ELF_PATH##|${KERNEL_ELF}|g" "${INPUT}" > "${OUTPUT}"
exec "${GDB}" -ex "source ${OUTPUT}"