Print this page
6375 Add native name demangling support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/sgs/prof/common/profv.c
          +++ new/usr/src/cmd/sgs/prof/common/profv.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
       25 + *
       26 + * Copyright 2018, Joyent, Inc.
  25   27   */
  26   28  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   29  /*
  30   30   * All routines in this file are for processing new-style, *versioned*
  31   31   * mon.out format. Together with rdelf.c, lookup.c and profv.h, these
  32   32   * form the complete set of files to profile new-style mon.out files.
  33   33   */
  34   34  
  35   35  #include <stdlib.h>
  36   36  #include <string.h>
  37   37  #include "conv.h"
  38   38  #include "profv.h"
↓ open down ↓ 28 lines elided ↑ open up ↑
  67   67          if ((namebuf = malloc(namebuf_sz)) == NULL) {
  68   68                  (void) fprintf(stderr, "%s: can't allocate %d bytes\n",
  69   69                      cmdname, namebuf_sz);
  70   70                  exit(ERR_MEMORY);
  71   71          }
  72   72  
  73   73          nbp = namebuf;
  74   74          nbe = namebuf + namebuf_sz;
  75   75  
  76   76          for (i = 0; i < total_funcs; i++) {
  77      -                if ((p = conv_demangle_name(profsym[i].name)) == NULL)
       77 +                p = conv_demangle_name(profsym[i].name);
       78 +                if (p == profsym[i].name)
  78   79                          continue;
  79   80  
  80   81                  namelen = strlen(p);
  81   82                  if ((nbp + namelen + 1) > nbe) {
  82   83                          namebuf_sz += BUCKET_SZ;
  83   84                          namebuf = realloc(namebuf, namebuf_sz);
  84   85                          if (namebuf == NULL) {
  85   86                                  (void) fprintf(stderr,
  86   87                                      "%s: can't alloc %d bytes\n",
  87   88                                      cmdname, BUCKET_SZ);
↓ open down ↓ 2 lines elided ↑ open up ↑
  90   91  
  91   92                          nbp = namebuf + cur_len;
  92   93                          nbe = namebuf + namebuf_sz;
  93   94                  }
  94   95  
  95   96                  (void) strcpy(nbp, p);
  96   97                  profsym[i].demangled_name = nbp;
  97   98  
  98   99                  nbp += namelen + 1;
  99  100                  cur_len += namelen + 1;
      101 +                free((void *)p);
 100  102          }
 101  103  }
 102  104  
 103  105  int
 104  106  cmp_by_time(const void *arg1, const void *arg2)
 105  107  {
 106  108          profrec_t *a = (profrec_t *)arg1;
 107  109          profrec_t *b = (profrec_t *)arg2;
 108  110  
 109  111          if (a->percent_time > b->percent_time)
↓ open down ↓ 805 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX