forked from amosbird/ldb_toolchain_gen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ldb_gperf
executable file
·46 lines (38 loc) · 1.05 KB
/
ldb_gperf
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
#!/usr/bin/env bash
set -e
LIBDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )/../lib" &> /dev/null && pwd )
loader=""
if [ "$(arch)" = "x86_64" ]; then
loader=$LIBDIR/ld-linux-x86-64.so.2
elif [ "$(arch)" = "aarch64" ]; then
loader=$LIBDIR/ld-linux-aarch64.so.1
else
echo "Unknown architecture: $(arch)"
exit 1
fi
if [ -z "$1" ]; then
echo "Usage: $0 <program> <perf_file> [perf_signal]"
exit 1
fi
if [ -z "$2" ]; then
echo "Usage: $0 <program> <perf_file> [perf_signal]"
exit 1
fi
if [ -n "$3" ]; then
num=$3
if [ ! -z "${num##*[!0-9]*}" ]
then
if [ $num -lt 65 ] && [ $num -gt 0 ]
then
SIG="CPUPROFILESIGNAL=$3"
fi
fi
if [ -z $SIG ]
then
echo "Usage: $0 <program> <perf_file> [perf_signal]"
echo "perf_signal should be >= 1 and <= 64"
exit 1
fi
fi
prog=$(realpath "$1")
exec env LD_LIBRARY_PATH="$LIBDIR" LD_PRELOAD="$LIBDIR/libunwind.so:$LIBDIR/libprofiler.so" CPUPROFILE="$2" $SIG "$loader" --library-path "$LIBDIR" --inhibit-cache "$prog"