#!/usr/bin/env bash # Full post-mortem of a core dump fetched with `scripts/rdbg.py coredump`: every task's backtrace, # registers and the crashed task's stack, via esp-coredump and GDB in the container. # Usage: scripts/decode_coredump.sh set -euo pipefail source "$(dirname "$0")/_docker.sh" [ $# -eq 2 ] || { echo "Usage: scripts/decode_coredump.sh " >&2; exit 1; } CORE="$(realpath "$1")" ELF="$(ls -t "$ROOT"/.pio/elves/*"$2"*.elf 2>/dev/null | head -1 || true)" [ -n "$ELF" ] || { echo "No archived ELF matches '$2' in .pio/elves/" >&2; exit 1; } echo "using ${ELF#$ROOT/}" >&2 DOCKER_EXTRA=(-v "$(dirname "$CORE"):/core:ro") run_in_container /pio/penv/bin/esp-coredump --chip esp32s3 info_corefile -t raw \ -g /pio/tools/tool-xtensa-esp-elf-gdb/bin/xtensa-esp32s3-elf-gdb \ -c "/core/$(basename "$CORE")" "/work/${ELF#$ROOT/}"