diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2016-04-16 03:05:14 +0200 |
---|---|---|
committer | Jan Vorlicek <janvorli@microsoft.com> | 2016-04-16 03:05:14 +0200 |
commit | f21291a702a4247b1dd1c3219eaf5319e94df061 (patch) | |
tree | 0234f3bd9470b53ef40f9a685d10b455134ce5c9 /src | |
parent | 71f8969056232b6c01d57e5ad4d9dc53c6bc0e99 (diff) | |
parent | 06ff0ff180dc0aa512481e5e4885b1f16e785a81 (diff) | |
download | coreclr-f21291a702a4247b1dd1c3219eaf5319e94df061.tar.gz coreclr-f21291a702a4247b1dd1c3219eaf5319e94df061.tar.bz2 coreclr-f21291a702a4247b1dd1c3219eaf5319e94df061.zip |
Merge pull request #4357 from krytarowski/netbsd-support-63
NetBSD: Add support for PAL_IsDebuggerPresent()
Diffstat (limited to 'src')
-rw-r--r-- | src/pal/src/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/pal/src/init/pal.cpp | 32 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt index e8e1655b3b..15dab11b94 100644 --- a/src/pal/src/CMakeLists.txt +++ b/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/src/pal/src/init/pal.cpp b/src/pal/src/init/pal.cpp index 0357ad9a55..afbee79385 100644 --- a/src/pal/src/init/pal.cpp +++ b/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,31 @@ PAL_IsDebuggerPresent() return ((info.kp_proc.p_flag & P_TRACED) != 0); return FALSE; +#elif defined(__NetBSD__) + int traced; + kvm_t *kd; + int cnt; + + struct kinfo_proc *info; + + kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, "kvm_open"); + if (kd == NULL) + return FALSE; + + info = kvm_getprocs(kd, KERN_PROC_PID, getpid(), &cnt); + if (info == NULL || cnt < 1) + { + kvm_close(kd); + return FALSE; + } + + traced = info->kp_proc.p_slflag & PSL_TRACED; + kvm_close(kd); + + if (traced != 0) + return TRUE; + else + return FALSE; #else return FALSE; #endif |