-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcreate_clone.sh
More file actions
executable file
·63 lines (49 loc) · 1.43 KB
/
create_clone.sh
File metadata and controls
executable file
·63 lines (49 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
if [ $# -ne 4 ]; then
echo "usage: create_clone.sh <orig_dir> <clone_dir> <top> <step_in_million>"
exit -1
fi
ROOT_DIR=$PWD
PIN_BIN=${ROOT_DIR}/pin/pin
TARGET=${ROOT_DIR}/obj-intel64/MAPProfiler.so
ORIG_DIR=${ROOT_DIR}/$1
CLONE_DIR=${ROOT_DIR}/$2
TOP_PERC=$3
INTERVAL=$4
#check if original directory exists
if [ ! -d "${ORIG_DIR}" ]; then
echo "Directory ${ORIG_DIR} does not exists"
exit -1
fi
#check for bin file
if [ ! -f "${ORIG_DIR}/cmd.bin" ]; then
echo "Original binary file name ${ORIG_DIR}/cmd.bin does not exists"
exit -1
fi
cd ${ORIG_DIR}
#check for bin file
ORIG_BIN=${ORIG_DIR}/$(cat ${ORIG_DIR}/cmd.bin)
if [ ! -f "${ORIG_BIN}" ]; then
echo "Original binary file ${ORIG_BIN} does not exists"
exit -1
fi
#check for argument file
ARG_FILE=${ORIG_DIR}/cmd.param
if [ ! -f "${ARG_FILE}" ]; then
echo "Argument file ${ARG_FILE} does not exists"
exit -1
fi
CLONE_OUT_DIR=${CLONE_DIR}/${INTERVAL}M
rm -rf ${CLONE_OUT_DIR}
mkdir ${CLONE_OUT_DIR}
echo "" > ${CLONE_OUT_DIR}/cmd.param
echo "genCode.out" > ${CLONE_OUT_DIR}/cmd.bin
PIN_CMD="${PIN_BIN} -t ${TARGET} -out ${CLONE_OUT_DIR}/genCode.cpp -top ${TOP_PERC} -stat ${CLONE_OUT_DIR}/cloneStat.log -step ${INTERVAL}000000 -maxinst 3000000000 -- ${ORIG_BIN} $(cat ${ARG_FILE})"
INPUT_FILE=${ORIG_DIR}/cmd.input
if [ ! -f "${INPUT_FILE}" ]; then
${PIN_CMD}
else
cat $(cat ${INPUT_FILE}) | ${PIN_CMD}
fi
cd ${CLONE_OUT_DIR}
g++ genCode.cpp -o genCode.out -O0 -mavx -g