Diagnostic: log syscall dispatch traps and forced signals

This commit is contained in:
maxjivi05 committed 2026-12-03 07:12:46 -05:00
1 parent 75eba86428
commit b160011cd9
1 file changed
+35
+35
View File
@@ -0,0 +1,35 @@
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/SeccompEmulator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/SeccompEmulator.cpp
index 1dc85de..be763fc 100644
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/SeccompEmulator.cpp
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/Seccomp/SeccompEmulator.cpp
@@ -6,6 +6,7 @@ $end_info$
*/
#include <stdio.h>
+#include <sys/syscall.h>
#include <unistd.h>
#include "LinuxSyscalls/Seccomp/BPFEmitter.h"
#include "LinuxSyscalls/Seccomp/SeccompEmulator.h"
@@ -365,7 +366,9 @@ SeccompEmulator::ExecuteSyscallUserDispatch(FEXCore::Core::CpuStateFrame* Frame,
if (SUD.Selector) {
uint8_t State {};
- if (FaultSafeUserMemAccess::CopyFromUser(&State, reinterpret_cast<const void*>(SUD.Selector), sizeof(State))) {
+ const bool SelFault = FaultSafeUserMemAccess::CopyFromUser(&State, reinterpret_cast<const void*>(SUD.Selector), sizeof(State));
+ if (SelFault || State != 0) ::dprintf(2, "DDSUD %d/%ld nr=%lu rip=%#lx off=%#lx len=%#lx sel=%#lx fault=%d state=%u\n", ::getpid(), ::syscall(SYS_gettid), SyscallNumber, PostSyscallRIP, SUD.Offset, SUD.Length, SUD.Selector, SelFault, State);
+ if (SelFault) {
ForceExitSignal(Thread, SIGSEGV);
return {true, SyscallNumber};
}
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
index a3cc742..d90d201 100644
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
@@ -1126,6 +1126,7 @@ void SignalDelegator::PrepareForcedGuestSignal(FEX::HLE::ThreadStateObject* Thre
GuestSigAction Action {};
RegisterGuestSignalHandler(Signal, nullptr, &Action);
const bool Ignored = Action.sigaction_handler.handler == SIG_IGN;
+ ::dprintf(2, "DDFORCE %d/%ld sig=%d blocked=%d ignored=%d handler=%p mask=%#lx\n", ::getpid(), ::syscall(SYS_gettid), Signal, Blocked, Ignored, reinterpret_cast<void*>(Action.sigaction_handler.handler), static_cast<unsigned long>(Thread->SignalInfo.CurrentSignalMask.Val));
if (!Blocked && !Ignored) {
return;