0

I am new to android/ ndk. is it possible to get the stack trace when one particular function is invoked. something like:

  int myfunction ()
  {
     //print stacktrace here. 
  }

Kindly help me out.

Whoami
  • 13,930
  • 19
  • 84
  • 140
  • Do you mean the Java stack trace that brought you to this method, or the native stack trace? The former is easier, the latter is fairly tricky and the end result will be in terms of hex addresses, as opposed to function names. You can then resolve addresses to names on your build machine, as long as you keep the archive of .so files with symbols in them. – Seva Alekseyev Feb 12 '14 at 14:20
  • As far as I know the Android NDK does not provide the `backtrace` function or alternatives which would conveniently solve that problem (see here http://linux.die.net/man/3/backtrace). Here is a related question: http://stackoverflow.com/questions/8115192/android-ndk-getting-the-backtrace – tiguchi Feb 12 '14 at 14:38
  • Thanks for the reply, i was pointing out native stack trace. – Whoami Feb 12 '14 at 14:40
  • 1
    Another related Q&A: http://stackoverflow.com/questions/21308625/how-to-print-stack-trace-with-symbolic-function-names-on-android/21313310#21313310 – fadden Feb 12 '14 at 15:37
  • @fadden: don't you think this Q is [duplicate](http://stackoverflow.com/questions/21308625/how-to-print-stack-trace-with-symbolic-function-names-on-android)? – Alex Cohn Feb 12 '14 at 22:40

0 Answers0