Module Name:    src
Committed By:   yamt
Date:           Tue Jul 26 12:24:16 UTC 2011

Modified Files:
        src/usr.bin/tpfmt: tpfmt.c

Log Message:
add an option to put samples for each symbols together.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.bin/tpfmt/tpfmt.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tpfmt/tpfmt.c
diff -u src/usr.bin/tpfmt/tpfmt.c:1.4 src/usr.bin/tpfmt/tpfmt.c:1.5
--- src/usr.bin/tpfmt/tpfmt.c:1.4	Tue Jul 26 12:21:27 2011
+++ src/usr.bin/tpfmt/tpfmt.c	Tue Jul 26 12:24:16 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: tpfmt.c,v 1.4 2011/07/26 12:21:27 yamt Exp $	*/
+/*	$NetBSD: tpfmt.c,v 1.5 2011/07/26 12:24:16 yamt Exp $	*/
 
 /*-
  * Copyright (c) 2010,2011 YAMAMOTO Takashi,
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: tpfmt.c,v 1.4 2011/07/26 12:21:27 yamt Exp $");
+__RCSID("$NetBSD: tpfmt.c,v 1.5 2011/07/26 12:24:16 yamt Exp $");
 #endif /* not lint */
 
 #include <sys/rbtree.h>
@@ -52,6 +52,7 @@
 
 static bool filter_by_pid;
 static pid_t target_pid;
+static bool per_symbol;
 
 struct addr {
 	struct rb_node node;
@@ -143,7 +144,7 @@
 	extern char *optarg;
 	extern int optind;
 
-	while ((ch = getopt(argc, argv, "CkLPp:")) != -1) {
+	while ((ch = getopt(argc, argv, "CkLPp:s")) != -1) {
 		uintmax_t val;
 		char *ep;
 
@@ -170,6 +171,9 @@
 		case 'P':	/* don't distinguish processes */
 			distinguish_processes = false;
 			break;
+		case 's':	/* per symbol */
+			per_symbol = true;
+			break;
 		default:
 			exit(EXIT_FAILURE);
 		}
@@ -224,6 +228,15 @@
 			a->cpuid = 0;
 		}
 		a->in_kernel = in_kernel;
+		if (per_symbol) {
+			const char *name;
+			uint64_t offset;
+
+			name = ksymlookup(a->addr, &offset);
+			if (name != NULL) {
+				a->addr -= offset;
+			}
+		}
 		a->nsamples = 1;
 		o = rb_tree_insert_node(&addrtree, a);
 		if (o != a) {

Reply via email to