How to unwind the stack to get backtrace for the specified stack pointer (SP)?

前端 未结 2 1425
离开以前
离开以前 2020-12-08 13:42

I\'m writing this for Android (ARM only), but I believe the principle is the same for generic Linux as well.

I\'m trying to capture the stack trace from within the s

2条回答
  •  爱一瞬间的悲伤
    2020-12-08 14:31

    First, you need to read the section on "async signal safe" functions:

    http://man7.org/linux/man-pages/man7/signal.7.html

    That's the entire set of functions that are safe to call in a signal handler. About the worst thing you can do is to call anything that calls malloc()/free() under the hood - or do it yourself.

    Second, get it working outside of a signal handler first.

    Third, these are probably apropos:

    How to get C++ backtrace on Android

    Android NDK: getting the backtrace

提交回复
热议问题