Skip to content

Commit

Permalink
WIP: Test app for capture signal handling
Browse files Browse the repository at this point in the history
Aggressively check and replace the handler for SIGSEGV every frame
  • Loading branch information
mikes-lunarg committed Sep 17, 2024
1 parent 4c63e84 commit 53c8bc2
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cube/cube.c
Original file line number Diff line number Diff line change
Expand Up @@ -2997,11 +2997,36 @@ static void demo_run_directfb(struct demo *demo) {
}
}
#elif defined(VK_USE_PLATFORM_ANDROID_KHR)
static void SignalHandler(int id, siginfo_t *info, void *data) {
__android_log_print(ANDROID_LOG_INFO, "gfxrecon", "cube: App signal handler abort()");
abort();
}

static void demo_run(struct demo *demo) {
if (!demo->prepared) return;

demo_draw(demo);
demo->curFrame++;

struct sigaction current_sa = {};
int result = sigaction(SIGSEGV, NULL, &current_sa);
if (result == 0) {
if (current_sa.sa_sigaction != SignalHandler) {
struct sigaction sa = {};
sa.sa_flags = SA_SIGINFO;
sigemptyset(&sa.sa_mask);
sa.sa_sigaction = SignalHandler;

result = sigaction(SIGSEGV, &sa, NULL);
if (result) {
__android_log_print(ANDROID_LOG_INFO, "gfxrecon", "cube: Error installing app signal handler %d", result);
} else {
__android_log_print(ANDROID_LOG_INFO, "gfxrecon", "cube: Installing app signal handler %d", result);
}
}
} else {
__android_log_print(ANDROID_LOG_INFO, "gfxrecon", "cube: Error retreiving signal handler %d", result);
}
}
#elif defined(VK_USE_PLATFORM_METAL_EXT)
static void demo_run(struct demo *demo) {
Expand Down

0 comments on commit 53c8bc2

Please sign in to comment.