]>
Commit | Line | Data |
---|---|---|
5489fcc3 KR |
1 | /* |
2 | * Copyright (c) 1983 Regents of the University of California. | |
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 | |
12516a37 | 29 | DEFUN (print_name_only, (self), Sym * self) |
5489fcc3 | 30 | { |
12516a37 KR |
31 | const char *name = self->name; |
32 | const char *filename; | |
33 | char *demangled = 0; | |
34 | char buf[PATH_MAX]; | |
35 | int size = 0; | |
5489fcc3 | 36 | |
12516a37 KR |
37 | if (name) |
38 | { | |
39 | if (!bsd_style_output) | |
40 | { | |
41 | if (name[0] == '_' && name[1] && discard_underscores) | |
42 | { | |
43 | name++; | |
03c35bcb | 44 | } |
12516a37 KR |
45 | demangled = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS); |
46 | if (demangled) | |
47 | { | |
48 | name = demangled; | |
03c35bcb KR |
49 | } |
50 | } | |
12516a37 KR |
51 | printf ("%s", name); |
52 | size = strlen (name); | |
53 | if (line_granularity && self->file) | |
54 | { | |
55 | filename = self->file->name; | |
56 | if (!print_path) | |
57 | { | |
58 | filename = strrchr (filename, '/'); | |
59 | if (filename) | |
60 | { | |
61 | ++filename; | |
62 | } | |
63 | else | |
64 | { | |
65 | filename = self->file->name; | |
03c35bcb KR |
66 | } |
67 | } | |
12516a37 KR |
68 | sprintf (buf, " (%s:%d)", filename, self->line_num); |
69 | printf (buf); | |
70 | size += strlen (buf); | |
03c35bcb | 71 | } |
12516a37 KR |
72 | if (demangled) |
73 | { | |
74 | free (demangled); | |
03c35bcb | 75 | } |
12516a37 KR |
76 | DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order)); |
77 | DBG (PROPDEBUG, printf ("%4.0f%% ", 100.0 * self->cg.prop.fract)); | |
03c35bcb | 78 | } |
12516a37 | 79 | return size; |
03c35bcb | 80 | } |
5489fcc3 KR |
81 | |
82 | ||
83 | void | |
12516a37 | 84 | DEFUN (print_name, (self), Sym * self) |
5489fcc3 | 85 | { |
12516a37 | 86 | print_name_only (self); |
5489fcc3 | 87 | |
12516a37 KR |
88 | if (self->cg.cyc.num != 0) |
89 | { | |
90 | printf (" <cycle %d>", self->cg.cyc.num); | |
03c35bcb | 91 | } |
12516a37 KR |
92 | if (self->cg.index != 0) |
93 | { | |
94 | if (self->cg.print_flag) | |
95 | { | |
96 | printf (" [%d]", self->cg.index); | |
97 | } | |
98 | else | |
99 | { | |
100 | printf (" (%d)", self->cg.index); | |
03c35bcb KR |
101 | } |
102 | } | |
103 | } |