0

I want to use Shiny on a large-ish C++ code base, but I'd rather not add the required PROFILE_FUNC() calls to my source. I figure it's easy enough to write a script that for each source file, regex-searches for function definitions, adds a macro call just after the opening bracket and pipes the result to g++; but that seems an awfully obvious source-code instrumentation case, so much so I find it hard to believe no-one has come up with a better solution already.

Unfortunately, searching around I could only find references to LLVM / clang instrumentation and the odd research tool, which look like overly complicated solutions to my comparatively simple problem. In fact, there seems to be no straightforward way to perform simple automated code edits to C/C++ code just prior to compilation.

Is that so? Or am I missing something?

Update: I forgot to mention this "C++ code base" is a native application I am porting to Android. So I can use neither gprof (which isn't available on Android), Valgrind (which requires an older version of the NDK than what i'm using) nor the android-ndk-profiler (which is for dynamic libraries loaded by Android Activities, either Java or native, not plain executables). Hence my looking into Shiny.

Update 2: Despite previous claims I actually managed to build Valgrind on Android NDK r8e, so I settled on using it instead of Shiny. However I still think the original question is valid: isn't there any straightforward tool for effecting simple compile-time edits to C / C++ source files – some sort of macro preprocessor on steroids?

Community
  • 1
  • 1
xperroni
  • 2,606
  • 1
  • 23
  • 29
  • gprof is available on android - with the platform source - for example on Mac OS /prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin/arm-eabi-gprof – gheese Jul 17 '13 at 08:30
  • The gprof post-mortem tool, yes. But without the gprof lib to link to the executable and generate the profile dump, what good is it? – xperroni Jul 17 '13 at 12:29

2 Answers2

0

You can consider gprof or valgrind. If memory serves, gprof uses instrumentation and valgrind is a sampling-based profiler. Neither of them requires you to annotate source code.

Marc Claesen
  • 16,778
  • 6
  • 27
  • 62
  • Problem is, this code is actually a native C++ application I am porting to Android. As far as I know gprof isn't available under Android, and Valgrind requires NDK r6 (I'm using r8e). – xperroni Jul 11 '13 at 18:31
0

You can use the android ndk profiler to profile C/C++ code More info here

http://code.google.com/p/android-ndk-profiler/

You use gprof to analyse the results

gheese
  • 1,170
  • 1
  • 11
  • 17
  • Unfortunately, android ndk profiler only lets you profile native *libraries*, not plain executables. See details here: http://code.google.com/p/android-ndk-profiler/issues/detail?id=1&can=1&q=executable – xperroni Jul 16 '13 at 00:21