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 | */ | |
6d9c411a | 19 | #include "demangle.h" |
252b5132 | 20 | #include "gprof.h" |
6d9c411a AM |
21 | #include "search_list.h" |
22 | #include "source.h" | |
252b5132 | 23 | #include "symtab.h" |
6d9c411a | 24 | #include "cg_arcs.h" |
1355568a | 25 | #include "utils.h" |
252b5132 RH |
26 | |
27 | ||
28 | /* | |
29 | * Print name of symbol. Return number of characters printed. | |
30 | */ | |
31 | int | |
1355568a AM |
32 | print_name_only (self) |
33 | Sym *self; | |
252b5132 RH |
34 | { |
35 | const char *name = self->name; | |
36 | const char *filename; | |
37 | char *demangled = 0; | |
38 | char buf[PATH_MAX]; | |
39 | int size = 0; | |
40 | ||
41 | if (name) | |
42 | { | |
43 | if (!bsd_style_output) | |
44 | { | |
45 | if (name[0] == '_' && name[1] && discard_underscores) | |
46 | { | |
47 | name++; | |
48 | } | |
49 | if (demangle) | |
50 | { | |
51 | demangled = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS); | |
52 | if (demangled) | |
53 | { | |
54 | name = demangled; | |
55 | } | |
56 | } | |
57 | } | |
58 | printf ("%s", name); | |
59 | size = strlen (name); | |
60 | if (line_granularity && self->file) | |
61 | { | |
62 | filename = self->file->name; | |
63 | if (!print_path) | |
64 | { | |
65 | filename = strrchr (filename, '/'); | |
66 | if (filename) | |
67 | { | |
68 | ++filename; | |
69 | } | |
70 | else | |
71 | { | |
72 | filename = self->file->name; | |
73 | } | |
74 | } | |
0eee5820 AM |
75 | sprintf (buf, " (%s:%d @ %lx)", filename, self->line_num, |
76 | (unsigned long) self->addr); | |
305c7206 | 77 | printf ("%s", buf); |
252b5132 RH |
78 | size += strlen (buf); |
79 | } | |
80 | if (demangled) | |
81 | { | |
82 | free (demangled); | |
83 | } | |
84 | DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order)); | |
85 | DBG (PROPDEBUG, printf ("%4.0f%% ", 100.0 * self->cg.prop.fract)); | |
86 | } | |
87 | return size; | |
88 | } | |
89 | ||
90 | ||
91 | void | |
1355568a AM |
92 | print_name (self) |
93 | Sym *self; | |
252b5132 RH |
94 | { |
95 | print_name_only (self); | |
96 | ||
97 | if (self->cg.cyc.num != 0) | |
98 | { | |
99 | printf (_(" <cycle %d>"), self->cg.cyc.num); | |
100 | } | |
101 | if (self->cg.index != 0) | |
102 | { | |
103 | if (self->cg.print_flag) | |
104 | { | |
105 | printf (" [%d]", self->cg.index); | |
106 | } | |
107 | else | |
108 | { | |
109 | printf (" (%d)", self->cg.index); | |
110 | } | |
111 | } | |
112 | } |