MCPcopy Create free account
hub / github.com/defold/defold / InstallHandler

Function InstallHandler

engine/crash/src/backtrace_android.cpp:244–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242 }
243
244 void InstallHandler()
245 {
246 // Somewhat hacky to do this here, but this is a nice platform specific file and saves adding
247 // additional layers of platform initialization.
248 char fp[PROP_VALUE_MAX];
249 __system_property_get("ro.build.fingerprint", fp);
250 dmStrlCpy(g_AppState.m_AndroidBuildFingerprint, fp, sizeof(g_AppState.m_AndroidBuildFingerprint));
251
252 void *lib = dlopen("libunwind.so", RTLD_LAZY | RTLD_LOCAL);
253 if (lib)
254 {
255 // The libunwind usage here is quite a bit of hackery and assumptions
256 // made by peering at the source code and generated dynamic libraries.
257 unw_init_local = (unw_init_local_t) dlsym(lib, "_Uarm_init_local");
258 unw_step = (unw_step_t) dlsym(lib, "_Uarm_step");
259 unw_get_reg = (unw_get_reg_t) dlsym(lib, "_Uarm_get_reg");
260
261 // clear handler if not complete.
262 if (!unw_step || !unw_get_reg)
263 {
264 unw_init_local = 0;
265 }
266 }
267 else
268 {
269 lib = dlopen("libcorkscrew.so", RTLD_LAZY | RTLD_LOCAL);
270 if (lib)
271 {
272 acquire_my_map_info_list = (acquire_my_map_info_list_fn) dlsym(lib, "acquire_my_map_info_list");
273 release_my_map_info_list = (release_my_map_info_list_fn) dlsym(lib, "release_my_map_info_list");
274 unwind_backtrace_signal_arch = (unwind_backtrace_signal_arch_fn) dlsym(lib, "unwind_backtrace_signal_arch");
275
276 if (!acquire_my_map_info_list || !release_my_map_info_list)
277 {
278 unwind_backtrace_signal_arch = 0;
279 }
280 }
281 }
282
283 stack_t stack;
284 memset(&stack, 0, sizeof(stack));
285 stack.ss_size = SIGSTKSZ;
286 stack.ss_sp = malloc(stack.ss_size);
287 stack.ss_flags = 0;
288 sigaltstack(&stack, NULL);
289
290 InstallOnSignal(SIGSEGV);
291 InstallOnSignal(SIGBUS);
292 InstallOnSignal(SIGTRAP);
293 InstallOnSignal(SIGILL);
294 }
295}

Callers

nothing calls this directly

Calls 3

dmStrlCpyFunction · 0.85
mallocFunction · 0.85
InstallOnSignalFunction · 0.70

Tested by

no test coverage detected