From 8b0814e89daa0097f903b6f0d75f8835b911b990 Mon Sep 17 00:00:00 2001 From: Richard Cartwright Date: Tue, 6 Apr 2021 14:31:19 +0100 Subject: [PATCH] feature: pass debug messages on to someone else to handle --- binding.gyp | 2 +- src/segfault-handler.cpp | 28 ++++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/binding.gyp b/binding.gyp index fb2a629..3c59de7 100644 --- a/binding.gyp +++ b/binding.gyp @@ -1,6 +1,6 @@ { "variables": { - "BUILD_WITH_LIBEXEC": "ExceptionRecord->ExceptionAddress; + code = (long)exceptionInfo->ExceptionRecord->ExceptionCode; + + switch (code) { + case DBG_PRINTEXCEPTION_WIDE_C: + case DBG_PRINTEXCEPTION_C: + // fprintf(stderr, "Debug exception %lx.\n", code); + return EXCEPTION_CONTINUE_SEARCH; + case kVCThreadNameException: + // fprintf(stderr, "Setting thread name %lx.\n", code); + return EXCEPTION_CONTINUE_SEARCH; + default: + break; + } #else address = (long)si->si_addr; + code = 0; #endif // Write the header line n = SNPRINTF( sbuff, BUFF_SIZE, - "PID %d received SIGSEGV for address: 0x%lx\n", + "PID %d received SIGSEGV for address: 0x%lx code: 0x%lx\n", pid, - address + address, + code ); + if (code == DBG_PRINTEXCEPTION_C || code == DBG_PRINTEXCEPTION_WIDE_C) { + + } + if(fd > 0) { if (WRITE(fd, sbuff, n) != n) { fprintf(stderr, "NodeSegfaultHandlerNative: Error writing to file\n");