static void handleSignal()

in src/backward.h [4019:4062]


    static void handleSignal(int, siginfo_t* info, void* _ctx)
    {
        ucontext_t* uctx = static_cast<ucontext_t*>(_ctx);

        StackTrace st;
        void* error_addr = nullptr;
#    ifdef REG_RIP // x86_64
        error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.gregs[REG_RIP]);
#    elif defined(REG_EIP) // x86_32
        error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.gregs[REG_EIP]);
#    elif defined(__arm__)
        error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.arm_pc);
#    elif defined(__aarch64__)
        error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.pc);
#    elif defined(__mips__)
        error_addr = reinterpret_cast<void*>(reinterpret_cast<struct sigcontext*>(&uctx->uc_mcontext)->sc_pc);
#    elif defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__)
        error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.regs->nip);
#    elif defined(__s390x__)
        error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.psw.addr);
#    elif defined(__APPLE__) && defined(__x86_64__)
        error_addr = reinterpret_cast<void*>(uctx->uc_mcontext->__ss.__rip);
#    elif defined(__APPLE__)
        error_addr = reinterpret_cast<void*>(uctx->uc_mcontext->__ss.__eip);
#    else
#        warning ":/ sorry, ain't know no nothing none not of your architecture!"
#    endif
        if (error_addr) {
            st.load_from(error_addr, 32);
        }
        else {
            st.load_here(32);
        }

        Printer printer;
        printer.address = true;
        printer.print(st, stderr);

#    if _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
        psiginfo(info, nullptr);
#    else
        (void)info;
#    endif
    }