svn commit: r252325 - head/sys/cddl/dev/dtmalloc

Mark Johnston markj at FreeBSD.org
Fri Jun 28 03:14:41 UTC 2013


Author: markj
Date: Fri Jun 28 03:14:40 2013
New Revision: 252325
URL: http://svnweb.freebsd.org/changeset/base/252325

Log:
  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

Modified:
  head/sys/cddl/dev/dtmalloc/dtmalloc.c

Modified: head/sys/cddl/dev/dtmalloc/dtmalloc.c
==============================================================================
--- head/sys/cddl/dev/dtmalloc/dtmalloc.c	Fri Jun 28 03:04:07 2013	(r252324)
+++ head/sys/cddl/dev/dtmalloc/dtmalloc.c	Fri Jun 28 03:14:40 2013	(r252325)
@@ -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
 {
 	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;


More information about the svn-src-all mailing list