From af75428ab6afc65aa15b9f927c2e8ccc8a48f83d Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Wed, 17 Jun 2009 17:57:28 -0700 Subject: [PATCH] darwin sigar_dlinfo_modules impl --- src/os/darwin/darwin_sigar.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 1007ffb2..d18f317c 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); }