diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 2cbd4bc0..ec59267b 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -39,6 +39,7 @@ #include #include #include +#include #define __OPENTRANSPORTPROVIDERS__ #include #include @@ -1885,10 +1886,36 @@ int sigar_proc_exe_get(sigar_t *sigar, sigar_pid_t pid, #endif } +#ifdef DARWIN +static int sigar_dlinfo_modules(sigar_t *sigar, sigar_proc_modules_t *procmods) +{ + uint32_t i, count = _dyld_image_count(); + + for (i=0; imodule_getter(procmods->data, + (char *)name, strlen(name)); + + if (status != SIGAR_OK) { + /* not an error; just stop iterating */ + break; + } + } + return SIGAR_OK; +} +#endif /* DARWIN */ + int sigar_proc_modules_get(sigar_t *sigar, sigar_pid_t pid, sigar_proc_modules_t *procmods) { -#ifdef SIGAR_HAS_DLINFO_MODULES +#if defined(SIGAR_HAS_DLINFO_MODULES) || defined(DARWIN) if (pid == sigar_pid_get(sigar)) { return sigar_dlinfo_modules(sigar, procmods); }