File tree 1 file changed +17
-0
lines changed
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 25
25
#include <fcntl.h>
26
26
#include <unistd.h>
27
27
28
+ #if defined(__FreeBSD__ )
29
+ # include <sys/user.h>
30
+ # include <libutil.h>
31
+ #endif
32
+
28
33
enum {
29
34
ZEND_GDBJIT_NOACTION ,
30
35
ZEND_GDBJIT_REGISTER ,
@@ -105,6 +110,7 @@ ZEND_API void zend_gdb_unregister_all(void)
105
110
ZEND_API bool zend_gdb_present (void )
106
111
{
107
112
bool ret = 0 ;
113
+ #if defined(__linux__ ) /* netbsd while having this procfs part, does not hold the tracer pid */
108
114
int fd = open ("/proc/self/status" , O_RDONLY );
109
115
110
116
if (fd > 0 ) {
@@ -136,6 +142,17 @@ ZEND_API bool zend_gdb_present(void)
136
142
137
143
close (fd );
138
144
}
145
+ #elif defined(__FreeBSD__ )
146
+ struct kinfo_proc * proc = kinfo_getproc (getpid ());
147
+
148
+ if (proc ) {
149
+ if ((proc -> ki_flag & P_TRACED ) != 0 ) {
150
+ struct kinfo_proc * dbg = kinfo_getproc (proc -> ki_tracer );
151
+
152
+ ret = (dbg && strstr (dbg -> ki_comm , "gdb" ));
153
+ }
154
+ }
155
+ #endif
139
156
140
157
return ret ;
141
158
}
You can’t perform that action at this time.
0 commit comments