#!/bin/bash if [ -z "$1" ]; then echo "Load an arm ELF binary into an active emacs gud session." echo "usage: $0 []" exit 1 fi ELF=`readlink -f $1` [ -z "$ELF" ] || [ ! -f "$ELF" ] && echo "Binary $1 not found." && exit 1 [ -z "$2" ] || SCRIPT=`readlink -f $2` # This is really for gdb+openocd, but it should also work for ordinary # gdb sessions if you provide a command file that calls "run". CMD=`mktemp` cat<>$CMD file $ELF reset echo - Loading $ELF\n load echo - Done.\\n shell rm $CMD EOF # Run script after upload if specified. Default behaviour is continue. if [ ! -z "$SCRIPT" ]; then cat<>$CMD echo - Executing gdb script $SCRIPT \\n source $SCRIPT echo - Done.\\n EOF else cat<>$CMD echo - Continuing.\\n continue EOF fi # echo "CMD = $CMD, contents:" # cat $CMD # interrupt if running emacsclient -e "(gdb-separate-io-interrupt)" >/dev/null sleep .5 # run the command file emacsclient -e "(gud-call \"source $CMD\")" # run until gdb removes the file echo -n Waiting for gdb load to finish while [ -f $CMD ]; do sleep 1 echo -n . done echo