在Android中获取堆栈跟踪

时间:2019-04-16 19:19:12

标签: android-ndk

我正在为Qt Framework开发的C ++应用程序添加backtrace选项(在应用程序崩溃期间调用),并且我使用的是此示例中的代码:https://github.com/JPNaude/dev_notes/wiki/Produce-a-stacktrace-when-something-goes-wrong-in-your-application,这是源代码

void crit_err_hdlr(int sig_num, siginfo_t * info, void * ucontext) {
    void *             array[50];
    void *             caller_address;
    char **            messages;
    int                size, i;
    sig_ucontext_t *   uc;

    uc = (sig_ucontext_t *)ucontext;

    /* Get the address at the time the signal was raised */
    #if defined(__i386__) // gcc specific
    caller_address = (void *) uc->uc_mcontext.eip; // EIP: x86 specific
    #elif defined(__x86_64__) // gcc specific
    caller_address = (void *) uc->uc_mcontext.rip; // RIP: x86_64 specific
    #else
    #error Unsupported architecture. // TODO: Add support for other arch.
    #endif
    ....

如您所见,该示例尚未完成,缺少了ARM体系结构。对于ARM 32位和ARM 64位,caller_address是什么?我需要用它来构建Android版本。

0 个答案:

没有答案