Files
mckero 542515d5ad Finish the portability sweep: one firmware resolver, no author paths
The probe scripts, run.sh, trace_run.sh, webui.py and two emulator tests each named the same hardcoded firmware from a source tree that is not in this repository. They now resolve QEMU and the firmware the way tools/uvk5_testenv.py does -- environment, then PATH, then whatever the checkout has -- and skip with a reason when there is nothing.

webui.py's --qemu and --elf lost their author defaults too: a bare qemu-system-arm through PATH, and no firmware until one is uploaded, which the page already reports.
2026-10-01 15:15:31 +08:00

31 lines
760 B
Bash
Executable File

#!/usr/bin/env bash
# Print the emulated firmware's current call stack.
#
# Usage: where.sh [samples]
set -uo pipefail
# shellcheck source=tools/uvk5_elf.sh
. "$(dirname "$0")/uvk5_elf.sh"
ELF=$(uvk5_find_elf) || { echo "SKIP no firmware found; set ELF or put one in assets/firmware" >&2; exit 0; }
SAMPLES="${1:-1}"
SCRIPT=$(mktemp --suffix=.gdb)
trap 'rm -f "$SCRIPT"' EXIT
cat >"$SCRIPT" <<'EOF'
set confirm off
set pagination off
target remote :1234
bt 5
detach
quit
EOF
for _ in $(seq "$SAMPLES"); do
gdb-multiarch -batch -x "$SCRIPT" "$ELF" 2>/dev/null \
| grep '^#' \
| sed 's/ (.*//; s/^#[0-9]* *//; s/0x[0-9a-f]* in //' \
| grep -v 'signal handler' \
| paste -sd' < ' -
[ "$SAMPLES" -gt 1 ] && sleep 1
done