Extend HostSignalHandler's SIGSEGV debugger path

The function now returns from a segmentation fault when a debugger is present, this allows the entire context to be intact which can allow the debugger to correctly pick up variables from all stack frames while it could not extrapolate most variables when trapped inside the signal handler without the values of all registers.
This commit is contained in:
PixelyIon 2022-05-07 18:34:56 +05:30
parent 4149ab1067
commit c910e29168

View File

@ -162,8 +162,16 @@ namespace skyline::nce {
return false; return false;
}()}; }()};
if (runningUnderDebugger) if (runningUnderDebugger) {
/* Variables for debugger, these are meant to be read and utilized by the debugger to break in user code with all registers intact */
void *pc{reinterpret_cast<void *>(ctx->uc_mcontext.pc)}; // Use 'p pc' to get the value of this and 'breakpoint set -t current -a ${value of pc}' to break in user code
bool shouldReturn{true}; // Set this to false to throw an exception instead of returning
raise(SIGTRAP); // Notify the debugger if we've got a SIGSEGV as the debugger doesn't catch them by default as they might be hooked raise(SIGTRAP); // Notify the debugger if we've got a SIGSEGV as the debugger doesn't catch them by default as they might be hooked
if (shouldReturn)
return;
}
} }
signal::ExceptionalSignalHandler(signal, info, ctx); // Delegate throwing a host exception to the exceptional signal handler signal::ExceptionalSignalHandler(signal, info, ctx); // Delegate throwing a host exception to the exceptional signal handler