| 1128 | |
| 1129 | #ifdef HAVE_BACKTRACE |
| 1130 | static void *getMcontextEip(ucontext_t *uc) { |
| 1131 | #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6) |
| 1132 | /* OSX < 10.6 */ |
| 1133 | #if defined(__x86_64__) |
| 1134 | return (void*) uc->uc_mcontext->__ss.__rip; |
| 1135 | #elif defined(__i386__) |
| 1136 | return (void*) uc->uc_mcontext->__ss.__eip; |
| 1137 | #else |
| 1138 | return (void*) uc->uc_mcontext->__ss.__srr0; |
| 1139 | #endif |
| 1140 | #elif defined(__APPLE__) && defined(MAC_OS_X_VERSION_10_6) |
| 1141 | /* OSX >= 10.6 */ |
| 1142 | #if defined(_STRUCT_X86_THREAD_STATE64) && !defined(__i386__) |
| 1143 | return (void*) uc->uc_mcontext->__ss.__rip; |
| 1144 | #elif defined(__i386__) |
| 1145 | return (void*) uc->uc_mcontext->__ss.__eip; |
| 1146 | #else |
| 1147 | /* OSX ARM64 */ |
| 1148 | return (void*) arm_thread_state64_get_pc(uc->uc_mcontext->__ss); |
| 1149 | #endif |
| 1150 | #elif defined(__linux__) |
| 1151 | /* Linux */ |
| 1152 | #if defined(__i386__) || ((defined(__X86_64__) || defined(__x86_64__)) && defined(__ILP32__)) |
| 1153 | return (void*) uc->uc_mcontext.gregs[14]; /* Linux 32 */ |
| 1154 | #elif defined(__X86_64__) || defined(__x86_64__) |
| 1155 | return (void*) uc->uc_mcontext.gregs[16]; /* Linux 64 */ |
| 1156 | #elif defined(__ia64__) /* Linux IA64 */ |
| 1157 | return (void*) uc->uc_mcontext.sc_ip; |
| 1158 | #elif defined(__arm__) /* Linux ARM */ |
| 1159 | return (void*) uc->uc_mcontext.arm_pc; |
| 1160 | #elif defined(__aarch64__) /* Linux AArch64 */ |
| 1161 | return (void*) uc->uc_mcontext.pc; |
| 1162 | #endif |
| 1163 | #elif defined(__FreeBSD__) |
| 1164 | /* FreeBSD */ |
| 1165 | #if defined(__i386__) |
| 1166 | return (void*) uc->uc_mcontext.mc_eip; |
| 1167 | #elif defined(__x86_64__) |
| 1168 | return (void*) uc->uc_mcontext.mc_rip; |
| 1169 | #endif |
| 1170 | #elif defined(__OpenBSD__) |
| 1171 | /* OpenBSD */ |
| 1172 | #if defined(__i386__) |
| 1173 | return (void*) uc->sc_eip; |
| 1174 | #elif defined(__x86_64__) |
| 1175 | return (void*) uc->sc_rip; |
| 1176 | #endif |
| 1177 | #elif defined(__NetBSD__) |
| 1178 | #if defined(__i386__) |
| 1179 | return (void*) uc->uc_mcontext.__gregs[_REG_EIP]; |
| 1180 | #elif defined(__x86_64__) |
| 1181 | return (void*) uc->uc_mcontext.__gregs[_REG_RIP]; |
| 1182 | #endif |
| 1183 | #elif defined(__DragonFly__) |
| 1184 | return (void*) uc->uc_mcontext.mc_rip; |
| 1185 | #else |
| 1186 | return NULL; |
| 1187 | #endif |
no outgoing calls
no test coverage detected