1

Write a program using the Android NDK. The program uses a few libraries. All this is very heavy CPU to 90%. How can I find out which of the libraries of most loads the CPU? is there for this special techniques or tools?

EDIT: That's what I got:



[user@localhost HelloNDK]$ ./remotegdb.sh
Package name is org.divenvrsk.android.hellondk
Found running pid: 7726
Device CPU ABIs: armeabi-v7a armeabi
Using app_out directory: /home/user/Dropbox/HelloNDK/obj/local/armeabi-v7a
68 KB/s (5680 bytes in 0.080s)
Pulled /home/user/Dropbox/HelloNDK/obj/local/armeabi-v7a/app_process from device/emulator.
2206 KB/s (278276 bytes in 0.123s)
Pulled /home/user/Dropbox/HelloNDK/obj/local/armeabi-v7a/libc.so from device/emulator.
Running gdbserver :5039 --attach 7726
su: not found
/home/user/android-ndk-r5b/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
/home/user/Dropbox/HelloNDK/libs/armeabi-v7a/gdb.setup
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-elf-linux".
Warning: /home/user/Dropbox/HelloNDK/jni/sox/flac/src/share/include: No such file or directory.
Warning: /home/user/Dropbox/HelloNDK/jni/sox/flac/src/metaflac/include: No such file or directory.
Warning: /home/user/Dropbox/HelloNDK/jni/sox/src/../libpng-1.5.2/include: No such file or directory.
Warning: /home/user/Dropbox/HelloNDK/jni/sox/work/../libpng-1.5.2/include: No such file or directory.
/home/user/Dropbox/HelloNDK/obj/local/armeabi-v7a/gdb.setup:3: Error in sourced command file:
Remote communication error: Connection reset by peer.
(gdb) 

What to do next in order to determine the load certain libraries?

Kyborg2011
  • 608
  • 3
  • 11
  • 29
  • Can you use the debugger (NDK-GDB) and take some [stackshots?](http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024) Ten of those will give you a very good idea of what's going on. – Mike Dunlavey Jun 27 '11 at 18:04
  • I get this:[user@localhost HelloNDK]$ ../../android-ndk-r5b/ndk-gdb --adb=../../android-sdk-linux_86/tools/adb ERROR: Could not setup network redirection to gdbserver? Maybe using --port= to use a different TCP port might help? – Kyborg2011 Jun 28 '11 at 09:43
  • What should I do? Where to find the port? – Kyborg2011 Jun 28 '11 at 09:43
  • Some links: [1](http://groups.google.com/group/android-ndk/browse_thread/thread/79c49630e94e32cf/467364a4a26fa878?pli=1), [2](http://stackoverflow.com/questions/3675045/ndk-gdb-with-multiple-so-libs), [3](http://blog.sephiroth.it/2010/12/14/how-to-debug-native-code-with-android/), etc. I just googled NDK-GDB. – Mike Dunlavey Jun 28 '11 at 12:43
  • I've updated the question. Take a look, please: what to do next? – Kyborg2011 Jun 30 '11 at 11:40
  • That's just gdb telling you about itself. (Get familiar with the gdb commands.) Can you start the program, and then while it's running, hit Ctrl-C to pause it, and then do `bt` to show the stack? Then repeat several times. I'm ignorant on Android, but that is the way find what is taking time in _any_ software. – Mike Dunlavey Jun 30 '11 at 12:19
  • Have you eclipse running? yes Mike Dunlavey, I do not understand fully. Where do I press Ctrl + C??? I do not know how to stop an Android application. – Kyborg2011 Jun 30 '11 at 18:39

2 Answers2

2

ndk-gdb and android-ndk-profiler would help you to get profile information.

Kazuki Sakamoto
  • 13,929
  • 2
  • 34
  • 96
1

I propose you to use Intel VTune Amplifier. This profiler allows you to collect hotspots with stacks on Android devices without root or any OS modification. Here is simple guide: http://software.intel.com/en-us/articles/using-intel-vtune-amplifier-on-non-rooted-android-devices

Ilya Kryukov
  • 461
  • 1
  • 5
  • 11