File: gprof_generate.sh.cmake

package info (click to toggle)
freerdp2 2.0.0~git20190204.1.2693389a+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 22,772 kB
  • sloc: ansic: 307,908; xml: 1,676; sh: 770; perl: 231; makefile: 158; python: 65
file content (56 lines) | stat: -rwxr-xr-x 1,402 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
#
# This script tries to pull gprof profiling information generated by aFreeRDP
# from the target using adb and generating human readable profiling data from
# it.
#
# Any arguments supplied to the script will be appended to adb.
#
# Requirements:
#  - ANDROID_SDK is set to the android SDK directory or adb is in path.
#

if [ -d $ANDROID_SDK ]; then
	ADB=$ANDROID_SDK/platform-tools/adb
else
	ADB=`which adb`
fi

GCC=@CMAKE_C_COMPILER@
GPROF=${GCC/gcc/gprof}
LIB=@CMAKE_BINARY_DIR@/client/Android/FreeRDPCore/jni/armeabi-v7a/libfreerdp-android.so

if [ ! -f $LIB ]; then
	echo "Missing libfreerdp-android.so"
	echo "Please build the project first."
	exit -1
fi

if [ ! -f $GPROF ]; then
	echo "gprof could not be found at $GPROF."
	echo "Please assure, that you are using a GCC based android toolchain."
	exit -2
fi

if [ ! -f $ADB ] || [ ! -x $ADB ]; then
	echo "adb could not be found."
	echo "assure, that either ANDROID_SDK is set to the path of your android SDK"
	echo "or that adb is in path."
	exit -3
fi

# Do the acutal work in a temporary directory.
SRC=`mktemp -d`
cd $SRC
$ADB $@ pull /sdcard/gmon.out
if [ ! -f gmon.out ]; then
	echo "Could not pull profiling information from device!"
	RC=-4
else
	echo "Pulled profiling information from device, starting conversion..."
	$GPROF $LIB -PprofCount -QprofCount -P__gnu_mcount_nc -Q__gnu_mcount_nc
	RC=0
fi
rm -rf $SRC

exit $RC