blob: 75562c785036a006fbde23417e3eebc4183e4c12 [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 BL1_ELF "${OUT_DIR}/trusted-firmware-a/qemu/release/bl1/bl1.elf"
default_var BL2_ELF "${OUT_DIR}/trusted-firmware-a/qemu/release/bl2/bl2.elf"
default_var BL31_ELF "${OUT_DIR}/trusted-firmware-a/qemu/release/bl31/bl31.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: -${OPTARG}" 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 -e "s|##ELF_PATH##|${KERNEL_ELF}|g" \
-e "s|##BL1_ELF_PATH##|${BL1_ELF}|g" \
-e "s|##BL2_ELF_PATH##|${BL2_ELF}|g" \
-e "s|##BL31_ELF_PATH##|${BL31_ELF}|g" \
"${INPUT}" > "${OUTPUT}"
exec "${GDB}" -ex "source ${OUTPUT}"