Skip to content

Instantly share code, notes, and snippets.

@gabrielesvelto
Last active December 22, 2020 10:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielesvelto/b3c0939726dbb3950022a7f013fce98c to your computer and use it in GitHub Desktop.
Save gabrielesvelto/b3c0939726dbb3950022a7f013fce98c to your computer and use it in GitHub Desktop.
#!/bin/bash
MINIDUMP_PATH="${1}"
MINIDUMP_STACKWALK=$(which minidump_stackwalk)
if [ -z "$MINIDUMP_STACKWALK" ]; then
if [ -f "$HOME/.mozbuild/minidump_stackwalk/minidump_stackwalk" ]; then
MINIDUMP_STACKWALK="$HOME/.mozbuild/minidump_stackwalk/minidump_stackwalk"
else
printf "You need the minidump_stackwalk executable in your PATH or under ~/.mozbuild in order to run this script\n"
exit 1
fi
fi
"${MINIDUMP_STACKWALK}" "${MINIDUMP_PATH}" . 2>/dev/null \
| grep 'WARNING: No symbols' \
| grep -v '\(deleted\)' \
| while read line; do
module_name=$(echo "$line" | cut -d' ' -f5)
debugfile_name=$(echo "$line" | cut -d',' -f2 | cut -b2-)
module_name_lowercase=$(echo "$line" | cut -d' ' -f5 | tr '[:upper:]' '[:lower:]')
debugfile_name_lowercase=$(echo "$line" | cut -d',' -f2 | cut -b2- | tr '[:upper:]' '[:lower:]')
module_id=$(echo "$line" | cut -d',' -f3 | cut -b2-34)
symbol_name=""
if [[ $module_name_lowercase =~ .*\.dll ]]; then
symbol_name="${module_name_lowercase%%.dll}.sym"
debugfile_name="$debugfile_name_lowercase"
elif [[ $module_name_lowercase =~ .*\.exe ]]; then
symbol_name="${module_name%%.exe}.sym"
debugfile_name="$debugfile_name_lowercase"
else
symbol_name="${module_name}.sym"
fi
mkdir -p "${debugfile_name}/${module_id}" && \
wget -q -c -O "${debugfile_name}/${module_id}/${symbol_name}.gz" "https://symbols.mozilla.org/${debugfile_name}/${module_id}/${symbol_name}"
if [ $? -eq 0 ]; then
gzip -f -k -d "${debugfile_name}/${module_id}/${symbol_name}.gz"
else
printf "ERROR: Could not find symbol for ${module_name} ${module_id}\n"
fi
done
"${MINIDUMP_STACKWALK}" "${MINIDUMP_PATH}" . 2>/dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment