MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / handleSignal

Method handleSignal

src/backward.h:4264–4313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4262 bool loaded() const { return _loaded; }
4263
4264 static void handleSignal(int, siginfo_t* info, void* _ctx)
4265 {
4266 ucontext_t* uctx = static_cast<ucontext_t*>(_ctx);
4267
4268 StackTrace st;
4269 void* error_addr = nullptr;
4270# ifdef REG_RIP // x86_64
4271 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.gregs[REG_RIP]);
4272# elif defined(REG_EIP) // x86_32
4273 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.gregs[REG_EIP]);
4274# elif defined(__arm__)
4275 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.arm_pc);
4276# elif defined(__aarch64__)
4277# if defined(__APPLE__)
4278 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext->__ss.__pc);
4279# else
4280 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.pc);
4281# endif
4282# elif defined(__mips__)
4283 error_addr = reinterpret_cast<void*>(reinterpret_cast<struct sigcontext*>(&uctx->uc_mcontext)->sc_pc);
4284# elif defined(__ppc__) || defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__)
4285 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.regs->nip);
4286# elif defined(__riscv)
4287 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.__gregs[REG_PC]);
4288# elif defined(__s390x__)
4289 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.psw.addr);
4290# elif defined(__APPLE__) && defined(__x86_64__)
4291 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext->__ss.__rip);
4292# elif defined(__APPLE__)
4293 error_addr = reinterpret_cast<void*>(uctx->uc_mcontext->__ss.__eip);
4294# else
4295# warning ":/ sorry, ain't know no nothing none not of your architecture!"
4296# endif
4297 if (error_addr) {
4298 st.load_from(error_addr, 32, reinterpret_cast<void*>(uctx), info->si_addr);
4299 }
4300 else {
4301 st.load_here(32, reinterpret_cast<void*>(uctx), info->si_addr);
4302 }
4303
4304 Printer printer;
4305 printer.address = true;
4306 printer.print(st, stderr);
4307
4308# if _XOPEN_SOURCE >= 700 || _POSIX_C_SOURCE >= 200809L
4309 psiginfo(info, nullptr);
4310# else
4311 (void)info;
4312# endif
4313 }
4314
4315private:
4316 details::handle<char*> _stack_content;

Callers

nothing calls this directly

Calls 3

printMethod · 0.80
load_fromMethod · 0.45
load_hereMethod · 0.45

Tested by

no test coverage detected