forked from wdlkmpx/unace1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmtrace.sh
executable file
·66 lines (54 loc) · 1.24 KB
/
mtrace.sh
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
62
63
64
65
66
#!/bin/sh
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <https://unlicense.org>
if [ "$(uname -s)" != "Linux" ] ; then
echo "This only runs on Linux (requires the GNU C Library)"
exit
else
echo -e "\nInfo: this only works with the GNU C Library\n"
fi
#-------------------
app="src/unace1"
app_args='x tests/zdir.ace'
app_cleanup='rm -rf zman'
#make_clean='make clean'
configure_opts='--prefix=/usr'
#-------------------
appbn=$(basename $app)
export CFLAGS="-D${appbn}_TRACE -ggdb3"
#if defined(appbn_TRACE) && defined(__GLIBC__)
#include <mcheck.h>
#endif
#int main(int argc, char * argv[])
#{
#if defined(appbn_TRACE) && defined(__GLIBC__)
# mtrace();
#endif
#}
export MALLOC_TRACE=$(pwd)/mtrace.txt
if ! command -v mtrace >/dev/null 2>&1 ; then
printf "mtrace is missing\n";
exit
fi
if ! test -f configure ; then
if test -f autogen.sh ; then
./autogen.sh
fi
fi
if test -f configure ; then
./configure ${configure_opts}
fi
if test -f Makefile ; then
${make_clean}
make
fi
if ! test -f ${app} ; then
echo "$app not found"
exit 1
fi
${app} ${app_args}
${app_cleanup}
mtrace ${app} mtrace.txt > mtrace-out.txt;
if [ $? -eq 0 ] ; then
printf "see mtrace-out.txt\n";
fi