Blame scripts/gprof_generate.sh.cmake

Packit Service fa4841
#!/bin/bash
Packit Service fa4841
#
Packit Service fa4841
# This script tries to pull gprof profiling information generated by aFreeRDP
Packit Service fa4841
# from the target using adb and generating human readable profiling data from
Packit Service fa4841
# it.
Packit Service fa4841
#
Packit Service fa4841
# Any arguments supplied to the script will be appended to adb.
Packit Service fa4841
#
Packit Service fa4841
# Requirements:
Packit Service fa4841
#  - ANDROID_SDK is set to the android SDK directory or adb is in path.
Packit Service fa4841
#
Packit Service fa4841
Packit Service fa4841
if [ -d $ANDROID_SDK ]; then
Packit Service fa4841
	ADB=$ANDROID_SDK/platform-tools/adb
Packit Service fa4841
else
Packit Service fa4841
	ADB=`which adb`
Packit Service fa4841
fi
Packit Service fa4841
Packit Service fa4841
GCC=@CMAKE_C_COMPILER@
Packit Service fa4841
GPROF=${GCC/gcc/gprof}
Packit Service fa4841
LIB=@CMAKE_BINARY_DIR@/client/Android/FreeRDPCore/jni/armeabi-v7a/libfreerdp-android.so
Packit Service fa4841
Packit Service fa4841
if [ ! -f $LIB ]; then
Packit Service fa4841
	echo "Missing libfreerdp-android.so"
Packit Service fa4841
	echo "Please build the project first."
Packit Service fa4841
	exit -1
Packit Service fa4841
fi
Packit Service fa4841
Packit Service fa4841
if [ ! -f $GPROF ]; then
Packit Service fa4841
	echo "gprof could not be found at $GPROF."
Packit Service fa4841
	echo "Please assure, that you are using a GCC based android toolchain."
Packit Service fa4841
	exit -2
Packit Service fa4841
fi
Packit Service fa4841
Packit Service fa4841
if [ ! -f $ADB ] || [ ! -x $ADB ]; then
Packit Service fa4841
	echo "adb could not be found."
Packit Service fa4841
	echo "assure, that either ANDROID_SDK is set to the path of your android SDK"
Packit Service fa4841
	echo "or that adb is in path."
Packit Service fa4841
	exit -3
Packit Service fa4841
fi
Packit Service fa4841
Packit Service fa4841
# Do the acutal work in a temporary directory.
Packit Service fa4841
SRC=`mktemp -d`
Packit Service fa4841
cd $SRC
Packit Service fa4841
$ADB $@ pull /sdcard/gmon.out
Packit Service fa4841
if [ ! -f gmon.out ]; then
Packit Service fa4841
	echo "Could not pull profiling information from device!"
Packit Service fa4841
	RC=-4
Packit Service fa4841
else
Packit Service fa4841
	echo "Pulled profiling information from device, starting conversion..."
Packit Service fa4841
	$GPROF $LIB -PprofCount -QprofCount -P__gnu_mcount_nc -Q__gnu_mcount_nc
Packit Service fa4841
	RC=0
Packit Service fa4841
fi
Packit Service fa4841
rm -rf $SRC
Packit Service fa4841
Packit Service fa4841
exit $RC