From d337d5212e55734a58c775d49d319a1fefb0e22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Thu, 14 Jun 2018 11:32:54 +0200 Subject: [PATCH] Symbols analyzer script --- code/symbols.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 code/symbols.sh diff --git a/code/symbols.sh b/code/symbols.sh new file mode 100755 index 00000000..4156a116 --- /dev/null +++ b/code/symbols.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# ------------------------------------------------------------------------------ +# CONFIGURATION +# ------------------------------------------------------------------------------ + +ENVIRONMENT="wemos-d1mini-relayshield" +READELF="xtensa-lx106-elf-readelf" +NUMBER=20 + +# ------------------------------------------------------------------------------ +# END CONFIGURATION - DO NOT EDIT FURTHER +# ------------------------------------------------------------------------------ + +# remove default trace file +rm -rf $FILE + +function help { + echo + echo "Syntax: $0 [-e ] [-n ]" + echo +} + +# get environment from command line +while [[ $# -gt 1 ]]; do + + key="$1" + + case $key in + -e) + ENVIRONMENT="$2" + shift + ;; + -n) + NUMBER="$2" + shift + ;; + esac + + shift # past argument or value + +done + +# check environment folder +if [ $ENVIRONMENT == "" ]; then + echo "No environment defined" + help + exit 1 +fi +ELF=.pioenvs/$ENVIRONMENT/firmware.elf +if [ ! -f $ELF ]; then + echo "Could not find ELF file for the selected environment: $ELF" + exit 2 +fi + +$READELF -s $ELF | head -3 | tail -1 +$READELF -s $ELF | sort -r -k3 -n | head -$NUMBER