| 1020 | |
| 1021 | #ifdef HAVE_BACKTRACE |
| 1022 | static void *getMcontextEip(ucontext_t *uc) { |
| 1023 | #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6) |
| 1024 | /* OSX < 10.6 */ |
| 1025 | #if defined(__x86_64__) |
| 1026 | return (void*) uc->uc_mcontext->__ss.__rip; |
| 1027 | #elif defined(__i386__) |
| 1028 | return (void*) uc->uc_mcontext->__ss.__eip; |
| 1029 | #else |
| 1030 | return (void*) uc->uc_mcontext->__ss.__srr0; |
| 1031 | #endif |
| 1032 | #elif defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6) |
| 1033 | /* OSX >= 10.6 */ |
| 1034 | #if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__) |
| 1035 | return (void*) uc->uc_mcontext->__ss.__rip; |
| 1036 | #elif defined(__i386__) |
| 1037 | return (void*) uc->uc_mcontext->__ss.__eip; |
| 1038 | #else |
| 1039 | /* OSX ARM64 */ |
| 1040 | return (void*) arm_thread_state64_get_pc(uc->uc_mcontext->__ss); |
| 1041 | #endif |
| 1042 | #elif defined(__linux__) |
| 1043 | /* Linux */ |
| 1044 | #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__)) |
| 1045 | return (void*) uc->uc_mcontext.gregs[14]; /* Linux 32 */ |
| 1046 | #elif defined(__X86_64__) || defined(__x86_64__) |
| 1047 | return (void*) uc->uc_mcontext.gregs[16]; /* Linux 64 */ |
| 1048 | #elif defined(__ia64__) /* Linux IA64 */ |
| 1049 | return (void*) uc->uc_mcontext.sc_ip; |
| 1050 | #elif defined(__arm__) /* Linux ARM */ |
| 1051 | return (void*) uc->uc_mcontext.arm_pc; |
| 1052 | #elif defined(__aarch64__) /* Linux AArch64 */ |
| 1053 | return (void*) uc->uc_mcontext.pc; |
| 1054 | #endif |
| 1055 | #elif defined(__FreeBSD__) |
| 1056 | /* FreeBSD */ |
| 1057 | #if defined(__i386__) |
| 1058 | return (void*) uc->uc_mcontext.mc_eip; |
| 1059 | #elif defined(__x86_64__) |
| 1060 | return (void*) uc->uc_mcontext.mc_rip; |
| 1061 | #endif |
| 1062 | #elif defined(__OpenBSD__) |
| 1063 | /* OpenBSD */ |
| 1064 | #if defined(__i386__) |
| 1065 | return (void*) uc->sc_eip; |
| 1066 | #elif defined(__x86_64__) |
| 1067 | return (void*) uc->sc_rip; |
| 1068 | #endif |
| 1069 | #elif defined(__NetBSD__) |
| 1070 | #if defined(__i386__) |
| 1071 | return (void*) uc->uc_mcontext.__gregs[_REG_EIP]; |
| 1072 | #elif defined(__x86_64__) |
| 1073 | return (void*) uc->uc_mcontext.__gregs[_REG_RIP]; |
| 1074 | #endif |
| 1075 | #elif defined(__DragonFly__) |
| 1076 | return (void*) uc->uc_mcontext.mc_rip; |
| 1077 | #else |
| 1078 | return NULL; |
| 1079 | #endif |
no outgoing calls
no test coverage detected