[compiler-rt] b35e636 - [Sanitizers] PGO implements enable/disable SIGKILL on callers on FreeBSD.
David Carlier via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 28 14:54:10 PDT 2021
Author: David Carlier
Date: 2021-08-28T22:53:16+01:00
New Revision: b35e636e40b549cd31566c9468dfbb97380ba068
URL: https://github.com/llvm/llvm-project/commit/b35e636e40b549cd31566c9468dfbb97380ba068
DIFF: https://github.com/llvm/llvm-project/commit/b35e636e40b549cd31566c9468dfbb97380ba068.diff
LOG: [Sanitizers] PGO implements enable/disable SIGKILL on callers on FreeBSD.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D108867
Added:
Modified:
compiler-rt/lib/profile/InstrProfilingUtil.c
Removed:
################################################################################
diff --git a/compiler-rt/lib/profile/InstrProfilingUtil.c b/compiler-rt/lib/profile/InstrProfilingUtil.c
index 062727faf7e7d..76b88432b0f1c 100644
--- a/compiler-rt/lib/profile/InstrProfilingUtil.c
+++ b/compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -38,6 +38,11 @@
#include <zircon/syscalls.h>
#endif
+#if defined(__FreeBSD__)
+#include <signal.h>
+#include <sys/procctl.h>
+#endif
+
#include "InstrProfiling.h"
#include "InstrProfilingUtil.h"
@@ -326,6 +331,11 @@ COMPILER_RT_VISIBILITY int lprofSuspendSigKill() {
if (prctl(PR_GET_PDEATHSIG, &PDeachSig) == 0 && PDeachSig == SIGKILL)
prctl(PR_SET_PDEATHSIG, 0);
return (PDeachSig == SIGKILL);
+#elif defined(__FreeBSD__)
+ int PDeachSig = 0, PDisableSig = 0;
+ if (procctl(P_PID, 0, PROC_PDEATHSIG_STATUS, &PDeachSig) == 0 &&
+ PDeachSig == SIGKILL)
+ procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &PDisableSig);
#else
return 0;
#endif
@@ -334,6 +344,9 @@ COMPILER_RT_VISIBILITY int lprofSuspendSigKill() {
COMPILER_RT_VISIBILITY void lprofRestoreSigKill() {
#if defined(__linux__)
prctl(PR_SET_PDEATHSIG, SIGKILL);
+#elif defined(__FreeBSD__)
+ int PEnableSig = SIGKILL;
+ procctl(P_PID, 0, PROC_PDEATHSIG_CTL, &PEnableSig);
#endif
}
More information about the llvm-commits
mailing list