pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

coreclr-git: Add support for checking if a process it traced



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Fri Apr 15 13:05:55 2016 +0200
Changeset:	b555187486d582db142b36cebd88b5578d31b780

Modified Files:
	coreclr-git/distinfo
Added Files:
	coreclr-git/patches/patch-src_pal_src_CMakeLists.txt
	coreclr-git/patches/patch-src_pal_src_init_pal.cpp

Log Message:
coreclr-git: Add support for checking if a process it traced

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=b555187486d582db142b36cebd88b5578d31b780

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 coreclr-git/distinfo                               |  2 +
 .../patches/patch-src_pal_src_CMakeLists.txt       | 21 +++++++++
 coreclr-git/patches/patch-src_pal_src_init_pal.cpp | 52 ++++++++++++++++++++++
 3 files changed, 75 insertions(+)

diffs:
diff --git a/coreclr-git/distinfo b/coreclr-git/distinfo
index c9e89d8..4294732 100644
--- a/coreclr-git/distinfo
+++ b/coreclr-git/distinfo
@@ -3,8 +3,10 @@ $NetBSD$
 SHA1 (patch-src_ToolBox_SOS_Strike_strike.h) = 3c92ad66bb589d01957da754534d25ad7fba91c1
 SHA1 (patch-src_coreclr_hosts_unixcoreruncommon_coreruncommon.cpp) = 146372d15f157088d450d4cd37cd2aac590e6d06
 SHA1 (patch-src_pal_inc_pal.h) = 7d3ef148af8b1b24067ba4cb5efc12581ebc6881
+SHA1 (patch-src_pal_src_CMakeLists.txt) = de3994c6630ef6c16e2286e76910477f72cd2179
 SHA1 (patch-src_pal_src_cruntime_printf.cpp) = 8a86c57e1fe3953d158e1860f04bd19d7df1fe08
 SHA1 (patch-src_pal_src_cruntime_printfcpp.cpp) = 4d1ba5fea45402259c67428506f39d9c3128ecbd
 SHA1 (patch-src_pal_src_cruntime_silent__printf.cpp) = 0922321ad05a90cc3b87b1e2663ff4d0b2e4717e
+SHA1 (patch-src_pal_src_init_pal.cpp) = feaf0e6cc704d9a11e66cc6ad3adaca6a0b01f47
 SHA1 (patch-src_pal_src_safecrt_output.inl) = ceb1951e8a7e0839fa1c0f5d07fd6c4087afd5df
 SHA1 (patch-src_pal_src_safecrt_safecrt__output__l.c) = 5a17a2525ab434336cfef369980562d1ecdcd953
diff --git a/coreclr-git/patches/patch-src_pal_src_CMakeLists.txt b/coreclr-git/patches/patch-src_pal_src_CMakeLists.txt
new file mode 100644
index 0000000..90e847f
--- /dev/null
+++ b/coreclr-git/patches/patch-src_pal_src_CMakeLists.txt
@@ -0,0 +1,21 @@
+$NetBSD$
+
+--- src/pal/src/CMakeLists.txt.orig	2016-04-15 10:25:33.594972569 +0000
++++ src/pal/src/CMakeLists.txt
+@@ -271,13 +271,16 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux)
+ endif(CMAKE_SYSTEM_NAME STREQUAL Linux)
+ 
+ if(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
++  add_definitions(-D_KMEMUSER)
+   find_library(UNWIND unwind)
+   find_library(INTL intl)
++  find_library(KVM kvm)
+   target_link_libraries(coreclrpal
+     pthread
+     rt
+     ${UNWIND}
+     ${INTL}
++    ${KVM}
+   )
+ endif(CMAKE_SYSTEM_NAME STREQUAL NetBSD)
+ 
diff --git a/coreclr-git/patches/patch-src_pal_src_init_pal.cpp b/coreclr-git/patches/patch-src_pal_src_init_pal.cpp
new file mode 100644
index 0000000..21fed37
--- /dev/null
+++ b/coreclr-git/patches/patch-src_pal_src_init_pal.cpp
@@ -0,0 +1,52 @@
+$NetBSD$
+
+--- src/pal/src/init/pal.cpp.orig	2016-04-08 23:29:23.000000000 +0000
++++ src/pal/src/init/pal.cpp
+@@ -72,6 +72,13 @@ int CacheLineSize;
+ #include <mach-o/dyld.h>
+ #endif // __APPLE__
+ 
++#ifdef __NetBSD__
++#include <sys/cdefs.h>
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <kvm.h>
++#endif
++
+ using namespace CorUnix;
+ 
+ //
+@@ -706,6 +713,33 @@ PAL_IsDebuggerPresent()
+         return ((info.kp_proc.p_flag & P_TRACED) != 0);
+ 
+     return FALSE;
++#elif defined(__NetBSD__)
++    int traced = -1;
++    kvm_t *kd;
++    int cnt;
++
++    struct kinfo_proc *info;
++    size_t size = sizeof(info);
++
++    kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open");
++    if (kd == NULL)
++        goto fin;
++
++    info = kvm_getprocs(kd, KERN_PROC_PID, getpid(), &cnt);
++    if (info == NULL)
++        goto fin2;
++
++    traced = info->kp_proc.p_slflag & PSL_TRACED; 
++    kvm_close(kd);
++
++    if (traced != 0)
++        return TRUE;
++    else
++        return FALSE;
++fin2:
++    kvm_close(kd);
++fin:
++    return FALSE;
+ #else
+     return FALSE;
+ #endif


Home | Main Index | Thread Index | Old Index