summaryrefslogtreecommitdiffstats
path: root/lib/libproc/proc_sym.c
diff options
context:
space:
mode:
authorrpaulo <rpaulo@FreeBSD.org>2010-08-11 17:33:26 +0000
committerrpaulo <rpaulo@FreeBSD.org>2010-08-11 17:33:26 +0000
commitafd44137e854c021c1e26e7a5d261dcf706ee9dc (patch)
tree6df5d79ff9e595481ae54191003939135774e4d9 /lib/libproc/proc_sym.c
parent5688dd21e911eab4ec09be1089f77d8d58fff05c (diff)
downloadFreeBSD-src-afd44137e854c021c1e26e7a5d261dcf706ee9dc.zip
FreeBSD-src-afd44137e854c021c1e26e7a5d261dcf706ee9dc.tar.gz
Several fixes for libproc:
o return the correct status in proc_wstatus() o proc_read takes a void * o correctly allocate the objs structure array Sponsored by: The FreeBSD Foundation
Diffstat (limited to 'lib/libproc/proc_sym.c')
-rw-r--r--lib/libproc/proc_sym.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/libproc/proc_sym.c b/lib/libproc/proc_sym.c
index 82c4c74..1d56df0 100644
--- a/lib/libproc/proc_sym.c
+++ b/lib/libproc/proc_sym.c
@@ -110,14 +110,25 @@ proc_iter_objs(struct proc_handle *p, proc_map_f *func, void *cd)
rd_loadobj_t *rdl;
prmap_t map;
char path[MAXPATHLEN];
+ char last[MAXPATHLEN];
if (p->nobjs == 0)
return (-1);
+ memset(last, 0, sizeof(last));
for (i = 0; i < p->nobjs; i++) {
rdl = &p->rdobjs[i];
proc_rdl2prmap(rdl, &map);
basename_r(rdl->rdl_path, path);
+ /*
+ * We shouldn't call the callback twice with the same object.
+ * To do that we are assuming the fact that if there are
+ * repeated object names (i.e. different mappings for the
+ * same object) they occur next to each other.
+ */
+ if (strcmp(path, last) == 0)
+ continue;
(*func)(cd, &map, path);
+ strlcpy(last, path, sizeof(last));
}
return (0);
OpenPOWER on IntegriCloud