changelog
[platform/upstream/freerdp.git] / scripts / gprof_generate.sh.cmake
1 #!/bin/bash
2 #
3 # This script tries to pull gprof profiling information generated by aFreeRDP
4 # from the target using adb and generating human readable profiling data from
5 # it.
6 #
7 # Any arguments supplied to the script will be appended to adb.
8 #
9 # Requirements:
10 #  - ANDROID_SDK is set to the android SDK directory or adb is in path.
11 #
12
13 if [ -d $ANDROID_SDK ]; then
14         ADB=$ANDROID_SDK/platform-tools/adb
15 else
16         ADB=`which adb`
17 fi
18
19 GCC=@CMAKE_C_COMPILER@
20 GPROF=${GCC/gcc/gprof}
21 LIB=@CMAKE_BINARY_DIR@/client/Android/FreeRDPCore/jni/armeabi-v7a/libfreerdp-android.so
22
23 if [ ! -f $LIB ]; then
24         echo "Missing libfreerdp-android.so"
25         echo "Please build the project first."
26         exit -1
27 fi
28
29 if [ ! -f $GPROF ]; then
30         echo "gprof could not be found at $GPROF."
31         echo "Please assure, that you are using a GCC based android toolchain."
32         exit -2
33 fi
34
35 if [ ! -f $ADB ] || [ ! -x $ADB ]; then
36         echo "adb could not be found."
37         echo "assure, that either ANDROID_SDK is set to the path of your android SDK"
38         echo "or that adb is in path."
39         exit -3
40 fi
41
42 # Do the acutal work in a temporary directory.
43 SRC=`mktemp -d`
44 cd $SRC
45 $ADB $@ pull /sdcard/gmon.out
46 if [ ! -f gmon.out ]; then
47         echo "Could not pull profiling information from device!"
48         RC=-4
49 else
50         echo "Pulled profiling information from device, starting conversion..."
51         $GPROF $LIB -PprofCount -QprofCount -P__gnu_mcount_nc -Q__gnu_mcount_nc
52         RC=0
53 fi
54 rm -rf $SRC
55
56 exit $RC