]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* |
0eee5820 | 2 | * Copyright (c) 1983, 1998, 2001 Regents of the University of California. |
252b5132 RH |
3 | * All rights reserved. |
4 | * | |
5 | * Redistribution and use in source and binary forms are permitted | |
6 | * provided that: (1) source distributions retain this entire copyright | |
7 | * notice and comment, and (2) distributions including binaries display | |
8 | * the following acknowledgement: ``This product includes software | |
9 | * developed by the University of California, Berkeley and its contributors'' | |
10 | * in the documentation or other materials provided with the distribution | |
11 | * and in all advertising materials mentioning features or use of this | |
12 | * software. Neither the name of the University nor the names of its | |
13 | * contributors may be used to endorse or promote products derived | |
14 | * from this software without specific prior written permission. | |
15 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
16 | * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
18 | */ | |
19 | #include <demangle.h> | |
20 | #include "gprof.h" | |
21 | #include "cg_arcs.h" | |
22 | #include "symtab.h" | |
23 | ||
24 | ||
25 | /* | |
26 | * Print name of symbol. Return number of characters printed. | |
27 | */ | |
28 | int | |
29 | DEFUN (print_name_only, (self), Sym * self) | |
30 | { | |
31 | const char *name = self->name; | |
32 | const char *filename; | |
33 | char *demangled = 0; | |
34 | char buf[PATH_MAX]; | |
35 | int size = 0; | |
36 | ||
37 | if (name) | |
38 | { | |
39 | if (!bsd_style_output) | |
40 | { | |
41 | if (name[0] == '_' && name[1] && discard_underscores) | |
42 | { | |
43 | name++; | |
44 | } | |
45 | if (demangle) | |
46 | { | |
47 | demangled = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS); | |
48 | if (demangled) | |
49 | { | |
50 | name = demangled; | |
51 | } | |
52 | } | |
53 | } | |
54 | printf ("%s", name); | |
55 | size = strlen (name); | |
56 | if (line_granularity && self->file) | |
57 | { | |
58 | filename = self->file->name; | |
59 | if (!print_path) | |
60 | { | |
61 | filename = strrchr (filename, '/'); | |
62 | if (filename) | |
63 | { | |
64 | ++filename; | |
65 | } | |
66 | else | |
67 | { | |
68 | filename = self->file->name; | |
69 | } | |
70 | } | |
0eee5820 AM |
71 | sprintf (buf, " (%s:%d @ %lx)", filename, self->line_num, |
72 | (unsigned long) self->addr); | |
305c7206 | 73 | printf ("%s", buf); |
252b5132 RH |
74 | size += strlen (buf); |
75 | } | |
76 | if (demangled) | |
77 | { | |
78 | free (demangled); | |
79 | } | |
80 | DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order)); | |
81 | DBG (PROPDEBUG, printf ("%4.0f%% ", 100.0 * self->cg.prop.fract)); | |
82 | } | |
83 | return size; | |
84 | } | |
85 | ||
86 | ||
87 | void | |
88 | DEFUN (print_name, (self), Sym * self) | |
89 | { | |
90 | print_name_only (self); | |
91 | ||
92 | if (self->cg.cyc.num != 0) | |
93 | { | |
94 | printf (_(" <cycle %d>"), self->cg.cyc.num); | |
95 | } | |
96 | if (self->cg.index != 0) | |
97 | { | |
98 | if (self->cg.print_flag) | |
99 | { | |
100 | printf (" [%d]", self->cg.index); | |
101 | } | |
102 | else | |
103 | { | |
104 | printf (" (%d)", self->cg.index); | |
105 | } | |
106 | } | |
107 | } |