Profiling on Android with the pg option

I am using the latest version of NDK android-ndk-r8b
I have some files that were created using the Android compiler from NDK. i686-android-linux-gcc
And now I want to profile these files.
I tried rebuilding it with the -pg option, but I got an error message:

 /tmp/ccixJFcx.o: In function `main': test1.C:(.text+0x17): undefined reference to `mcount' collect2: ld returned 1 exit status 

I want to try using i686-android-linux-gprof , but without successfully compiling with the -pg option -pg I cannot do this.

For example, let the sources of test1.C be:

 int main() { return 0; } 

I can compile the file using standard gcc using the following options:
-g -O2 -m32 -Wa,--32 -Wl,-melf_i386 -pg And use this file with i686-android-linux-gprof

But I can not use the pg key with i686-android-linux-gcc , does anyone know why? And how can I use it, maybe I should use some additional libraries / compilation options during the NDK recovery process?

+4
source share
2 answers

There seems to be no mcount function.
I downloaded Android Sources, there is no mcount function, only 1 call from it, so I think it provides this error.

I found the same problem in Android issues.

0
source

You should add some changes to your Android.mk:

 #include android-ndk-profiler.mk LOCAL_CFLAGS := -pg LOCAL_STATIC_LIBRARIES := andprof LOCAL_LDLIBS += -llog 

See http://code.google.com/p/android-ndk-profiler/wiki/Usage for more details.

PS It seems that the x86 runtime just does not contain mcount . Define it elsewhere in your code:

 #if !( defined(_M_ARM) || defined(__arm__) ) int mcount = 0; #endif 
+3
source

Source: https://habr.com/ru/post/1434779/


All Articles