diff options
author | markj <markj@FreeBSD.org> | 2013-06-28 03:14:40 +0000 |
---|---|---|
committer | markj <markj@FreeBSD.org> | 2013-06-28 03:14:40 +0000 |
commit | 5aabb39c86af06392b2155209b47c6511f6f8167 (patch) | |
tree | f5aa63161918609f26d9e9ca9b964853e772f986 /sys/cddl/dev | |
parent | b4606583056cfbefe7934774c4b8f98725c9b4a4 (diff) | |
download | FreeBSD-src-5aabb39c86af06392b2155209b47c6511f6f8167.zip FreeBSD-src-5aabb39c86af06392b2155209b47c6511f6f8167.tar.gz |
The dtmalloc provider uses the short description of a malloc type as the
function name of its corresponding DTrace probes. These descriptions may
contain whitespace, but probe names cannot, so just replace any whitespace
with underscores when creating probes.
MFC after: 1 week
Diffstat (limited to 'sys/cddl/dev')
-rw-r--r-- | sys/cddl/dev/dtmalloc/dtmalloc.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/cddl/dev/dtmalloc/dtmalloc.c b/sys/cddl/dev/dtmalloc/dtmalloc.c index ca822f9..81ff43f 100644 --- a/sys/cddl/dev/dtmalloc/dtmalloc.c +++ b/sys/cddl/dev/dtmalloc/dtmalloc.c @@ -28,6 +28,7 @@ #include <sys/param.h> #include <sys/systm.h> #include <sys/conf.h> +#include <sys/ctype.h> #include <sys/kernel.h> #include <sys/malloc.h> #include <sys/module.h> @@ -111,8 +112,17 @@ dtmalloc_type_cb(struct malloc_type *mtp, void *arg __unused) { char name[DTRACE_FUNCNAMELEN]; struct malloc_type_internal *mtip = mtp->ks_handle; + int i; + /* + * malloc_type descriptions are allowed to contain whitespace, but + * DTrace probe identifiers are not, so replace the whitespace with + * underscores. + */ strlcpy(name, mtp->ks_shortdesc, sizeof(name)); + for (i = 0; name[i] != 0; i++) + if (isspace(name[i])) + name[i] = '_'; if (dtrace_probe_lookup(dtmalloc_id, NULL, name, "malloc") != 0) return; |