62 lines
1.6 KiB
Plaintext
62 lines
1.6 KiB
Plaintext
$OpenBSD: patch-base_debug_debugger_posix_cc,v 1.2 2011/03/15 11:38:05 robert Exp $
|
|
--- base/debug/debugger_posix.cc.orig Mon Mar 14 11:01:33 2011
|
|
+++ base/debug/debugger_posix.cc Mon Mar 14 17:58:04 2011
|
|
@@ -11,6 +11,9 @@
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/stat.h>
|
|
+#if defined(OS_OPENBSD)
|
|
+#include <sys/param.h>
|
|
+#endif
|
|
#if !defined(OS_NACL)
|
|
#include <sys/sysctl.h>
|
|
#endif
|
|
@@ -50,7 +53,7 @@ bool SpawnDebuggerOnProcess(unsigned /* process_id */)
|
|
return false;
|
|
}
|
|
|
|
-#if defined(OS_MACOSX)
|
|
+#if defined(OS_MACOSX) || defined(OS_OPENBSD)
|
|
|
|
// Based on Apple's recommended method as described in
|
|
// http://developer.apple.com/qa/qa2004/qa1361.html
|
|
@@ -68,14 +71,26 @@ bool BeingDebugged() {
|
|
// we're looking for information about a specific process ID.
|
|
int mib[] = {
|
|
CTL_KERN,
|
|
+#if defined(OS_OPENBSD)
|
|
+ KERN_PROC2,
|
|
+#else
|
|
KERN_PROC,
|
|
+#endif
|
|
KERN_PROC_PID,
|
|
getpid()
|
|
+#if defined(OS_OPENBSD)
|
|
+ , sizeof(struct kinfo_proc2),
|
|
+ 400 /* XXX */
|
|
+#endif
|
|
};
|
|
|
|
// Caution: struct kinfo_proc is marked __APPLE_API_UNSTABLE. The source and
|
|
// binary interfaces may change.
|
|
+#if defined(OS_OPENBSD)
|
|
+ struct kinfo_proc2 info;
|
|
+#else
|
|
struct kinfo_proc info;
|
|
+#endif
|
|
size_t info_size = sizeof(info);
|
|
|
|
int sysctl_result = sysctl(mib, arraysize(mib), &info, &info_size, NULL, 0);
|
|
@@ -88,7 +103,11 @@ bool BeingDebugged() {
|
|
|
|
// This process is being debugged if the P_TRACED flag is set.
|
|
is_set = true;
|
|
+#if defined(OS_OPENBSD)
|
|
+ being_debugged = (info.p_flag & P_TRACED) != 0;
|
|
+#else
|
|
being_debugged = (info.kp_proc.p_flag & P_TRACED) != 0;
|
|
+#endif
|
|
return being_debugged;
|
|
}
|
|
|