File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 2525#include <fcntl.h>
2626#include <unistd.h>
2727
28+ #if defined(__FreeBSD__ )
29+ # include <sys/user.h>
30+ # include <libutil.h>
31+ #endif
32+
2833enum {
2934 ZEND_GDBJIT_NOACTION ,
3035 ZEND_GDBJIT_REGISTER ,
@@ -105,6 +110,7 @@ ZEND_API void zend_gdb_unregister_all(void)
105110ZEND_API bool zend_gdb_present (void )
106111{
107112 bool ret = 0 ;
113+ #if defined(__linux__ ) /* netbsd while having this procfs part, does not hold the tracer pid */
108114 int fd = open ("/proc/self/status" , O_RDONLY );
109115
110116 if (fd > 0 ) {
@@ -136,6 +142,17 @@ ZEND_API bool zend_gdb_present(void)
136142
137143 close (fd );
138144 }
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
139156
140157 return ret ;
141158}
You can’t perform that action at this time.
0 commit comments