1#!/bin/bash 2 3DYNAMORIO_ROOT=${DYNAMORIO_ROOT:=$HOME/DynamoRIO} 4TS_ROOT=${TS_ROOT:-`dirname $0`} 5TS_VARIANT=-debug 6 7TS_FLAGS=" " 8 9for arg in "$@"; do 10 case $arg in 11 --opt) TS_VARIANT="";; 12 --dbg) TS_VARIANT="-debug";; 13 --) shift; break;; 14 -64) ARCH="amd64"; BITNESS="64";; 15 -32) ARCH="x86"; BITNESS="32";; 16 -*) TS_FLAGS="$TS_FLAGS $arg";; 17 *) break;; 18 esac 19 shift 20done 21 22PROGRAM="$1" 23shift 24PARAMS="$@" 25 26# detect bitness if not given explicitly. 27if [ "$BITNESS" == "" ]; then 28 file_format=`objdump -f $PROGRAM | grep -o 'file format elf.*'` 29 echo $file_format 30 if [ "$file_format" == "file format elf64-x86-64" ]; then 31 BITNESS=64 32 ARCH=amd64 33 else 34 BITNESS=32 35 ARCH=x86 36 fi 37fi 38 39SYMBOLS_FILE="$(mktemp symbols.XXXXXX)" 40nm $PROGRAM > $SYMBOLS_FILE 41TS_FLAGS="$TS_FLAGS --symbols=$SYMBOLS_FILE" 42 43$DYNAMORIO_ROOT/bin$BITNESS/drdeploy \ 44 -client $TS_ROOT/bin/$ARCH-linux-debug-ts_dynamorio.so 0 "$TS_FLAGS" \ 45 $PROGRAM $PARAMS 46rm $SYMBOLS_FILE 47