Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/tpfmt add an option to put samples for each symbols ...



details:   https://anonhg.NetBSD.org/src/rev/c13f403f8d42
branches:  trunk
changeset: 767651:c13f403f8d42
user:      yamt <yamt%NetBSD.org@localhost>
date:      Tue Jul 26 12:24:16 2011 +0000

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

diffstat:

 usr.bin/tpfmt/tpfmt.c |  19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diffs (61 lines):

diff -r 32d28f975c97 -r c13f403f8d42 usr.bin/tpfmt/tpfmt.c
--- a/usr.bin/tpfmt/tpfmt.c     Tue Jul 26 12:21:27 2011 +0000
+++ b/usr.bin/tpfmt/tpfmt.c     Tue Jul 26 12:24:16 2011 +0000
@@ -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) {



Home | Main Index | Thread Index | Old Index