diff options
author | kamil <kamil@pkgsrc.org> | 2020-02-14 00:50:51 +0000 |
---|---|---|
committer | kamil <kamil@pkgsrc.org> | 2020-02-14 00:50:51 +0000 |
commit | 8e9929db05d1297e636a13ad967f0e08069e1a73 (patch) | |
tree | a6d12f43ab43531e3297830013d2311ae3f9806a /lang/mono6/patches | |
parent | a0097f08b71c85d1e2c9f8600bb965690ddfc4b1 (diff) | |
download | pkgsrc-8e9929db05d1297e636a13ad967f0e08069e1a73.tar.gz |
mono6: Fix build on NetBSD
Switch from kvm(3) calls to sysctl(3) ones to detect whether a current
process is debugged.
Diffstat (limited to 'lang/mono6/patches')
-rw-r--r-- | lang/mono6/patches/patch-mono_utils_mono-utils-debug.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/lang/mono6/patches/patch-mono_utils_mono-utils-debug.c b/lang/mono6/patches/patch-mono_utils_mono-utils-debug.c index 32f7bffbde6..056ee497a83 100644 --- a/lang/mono6/patches/patch-mono_utils_mono-utils-debug.c +++ b/lang/mono6/patches/patch-mono_utils_mono-utils-debug.c @@ -1,4 +1,4 @@ -$NetBSD: patch-mono_utils_mono-utils-debug.c,v 1.2 2020/02/12 15:25:16 ryoon Exp $ +$NetBSD: patch-mono_utils_mono-utils-debug.c,v 1.3 2020/02/14 00:50:51 kamil Exp $ Learn to use kinfo_proc2 on netbsd @@ -13,15 +13,34 @@ Learn to use kinfo_proc2 on netbsd #endif #if defined (_AIX) #include <procinfo.h> -@@ -78,8 +80,9 @@ mono_is_usermode_native_debugger_present - if (!kd) +@@ -74,14 +76,23 @@ mono_is_usermode_native_debugger_present + + #elif defined (__NetBSD__) + +- kvm_t * const kd = kvm_open (NULL, NULL, NULL, KVM_NO_FILES, "kvm_open"); +- if (!kd) ++ struct kinfo_proc2 p; ++ size_t len = sizeof(p); ++ int name[] = { ++ [0] = CTL_KERN, ++ [1] = KERN_PROC2, ++ [2] = KERN_PROC_PID, ++ [3] = getpid(), ++ [4] = (int)(sizeof(struct kinfo_proc2)), ++ [5] = 1 ++ }; ++ ++ const size_t namelen = __arraycount(name); ++ ++ if (sysctl(name, namelen, &p, &len, NULL, 0) == -1) return FALSE; - int count = 0; +- int count = 0; - struct kinfo_proc const * const info = kvm_getprocs (kd, KERN_PROC_PID, getpid (), &count); - gboolean const traced = info && count > 0 && (info->kp_proc.p_slflag & PSL_TRACED); -+ int nproc; -+ struct kinfo_proc2 const * const info = kvm_getproc2 (kd, KERN_PROC_PID, getpid (), sizeof(struct kinfo_proc2), &count); -+ gboolean const traced = info && count > 0 && (info->p_flag & P_TRACED); - kvm_close (kd); - return traced; +- kvm_close (kd); +- return traced; ++ ++ return (p.p_flag & P_TRACED) ? TRUE : FALSE; + + #elif defined (_AIX) |