1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.0' into PHP-8.1

* PHP-8.0:
  zend gdb detection fix on FreeBSD.
This commit is contained in:
Joe Watkins
2021-12-21 07:19:58 +01:00

View File

@@ -25,6 +25,11 @@
#include <fcntl.h>
#include <unistd.h>
#if defined(__FreeBSD__)
# include <sys/user.h>
# include <libutil.h>
#endif
enum {
ZEND_GDBJIT_NOACTION,
ZEND_GDBJIT_REGISTER,
@@ -105,6 +110,7 @@ ZEND_API void zend_gdb_unregister_all(void)
ZEND_API bool zend_gdb_present(void)
{
bool ret = 0;
#if defined(__linux__) /* netbsd while having this procfs part, does not hold the tracer pid */
int fd = open("/proc/self/status", O_RDONLY);
if (fd > 0) {
@@ -136,6 +142,17 @@ ZEND_API bool zend_gdb_present(void)
close(fd);
}
#elif defined(__FreeBSD__)
struct kinfo_proc *proc = kinfo_getproc(getpid());
if (proc) {
if ((proc->ki_flag & P_TRACED) != 0) {
struct kinfo_proc *dbg = kinfo_getproc(proc->ki_tracer);
ret = (dbg && strstr(dbg->ki_comm, "gdb"));
}
}
#endif
return ret;
}