12159047fSniklas /*
26e421504Sfgsch * Copyright (c) 1983, 1993, 2001
36e421504Sfgsch * The Regents of the University of California. All rights reserved.
42159047fSniklas *
56e421504Sfgsch * Redistribution and use in source and binary forms, with or without
66e421504Sfgsch * modification, are permitted provided that the following conditions
76e421504Sfgsch * are met:
86e421504Sfgsch * 1. Redistributions of source code must retain the above copyright
96e421504Sfgsch * notice, this list of conditions and the following disclaimer.
106e421504Sfgsch * 2. Redistributions in binary form must reproduce the above copyright
116e421504Sfgsch * notice, this list of conditions and the following disclaimer in the
126e421504Sfgsch * documentation and/or other materials provided with the distribution.
136e421504Sfgsch * 3. Neither the name of the University nor the names of its contributors
146e421504Sfgsch * may be used to endorse or promote products derived from this software
156e421504Sfgsch * without specific prior written permission.
166e421504Sfgsch *
176e421504Sfgsch * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
186e421504Sfgsch * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
196e421504Sfgsch * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
206e421504Sfgsch * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
216e421504Sfgsch * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
226e421504Sfgsch * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
236e421504Sfgsch * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
246e421504Sfgsch * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
256e421504Sfgsch * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
266e421504Sfgsch * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
276e421504Sfgsch * SUCH DAMAGE.
282159047fSniklas */
29*c074d1c9Sdrahn #include "demangle.h"
302159047fSniklas #include "gprof.h"
31*c074d1c9Sdrahn #include "search_list.h"
32*c074d1c9Sdrahn #include "source.h"
332159047fSniklas #include "symtab.h"
34*c074d1c9Sdrahn #include "cg_arcs.h"
35*c074d1c9Sdrahn #include "utils.h"
362159047fSniklas
372159047fSniklas
382159047fSniklas /*
392159047fSniklas * Print name of symbol. Return number of characters printed.
402159047fSniklas */
412159047fSniklas int
print_name_only(self)42*c074d1c9Sdrahn print_name_only (self)
43*c074d1c9Sdrahn Sym *self;
442159047fSniklas {
452159047fSniklas const char *name = self->name;
462159047fSniklas const char *filename;
472159047fSniklas char *demangled = 0;
482159047fSniklas char buf[PATH_MAX];
492159047fSniklas int size = 0;
502159047fSniklas
512159047fSniklas if (name)
522159047fSniklas {
532159047fSniklas if (!bsd_style_output)
542159047fSniklas {
552159047fSniklas if (name[0] == '_' && name[1] && discard_underscores)
562159047fSniklas {
572159047fSniklas name++;
582159047fSniklas }
59f7cc78ecSespie if (demangle)
60f7cc78ecSespie {
612159047fSniklas demangled = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
622159047fSniklas if (demangled)
632159047fSniklas {
642159047fSniklas name = demangled;
652159047fSniklas }
662159047fSniklas }
67f7cc78ecSespie }
682159047fSniklas printf ("%s", name);
692159047fSniklas size = strlen (name);
702159047fSniklas if (line_granularity && self->file)
712159047fSniklas {
722159047fSniklas filename = self->file->name;
732159047fSniklas if (!print_path)
742159047fSniklas {
752159047fSniklas filename = strrchr (filename, '/');
762159047fSniklas if (filename)
772159047fSniklas {
782159047fSniklas ++filename;
792159047fSniklas }
802159047fSniklas else
812159047fSniklas {
822159047fSniklas filename = self->file->name;
832159047fSniklas }
842159047fSniklas }
85b55d4692Sfgsch sprintf (buf, " (%s:%d @ %lx)", filename, self->line_num,
86b55d4692Sfgsch (unsigned long) self->addr);
87f7cc78ecSespie printf ("%s", buf);
882159047fSniklas size += strlen (buf);
892159047fSniklas }
902159047fSniklas if (demangled)
912159047fSniklas {
922159047fSniklas free (demangled);
932159047fSniklas }
942159047fSniklas DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order));
952159047fSniklas DBG (PROPDEBUG, printf ("%4.0f%% ", 100.0 * self->cg.prop.fract));
962159047fSniklas }
972159047fSniklas return size;
982159047fSniklas }
992159047fSniklas
1002159047fSniklas
1012159047fSniklas void
print_name(self)102*c074d1c9Sdrahn print_name (self)
103*c074d1c9Sdrahn Sym *self;
1042159047fSniklas {
1052159047fSniklas print_name_only (self);
1062159047fSniklas
1072159047fSniklas if (self->cg.cyc.num != 0)
1082159047fSniklas {
109f7cc78ecSespie printf (_(" <cycle %d>"), self->cg.cyc.num);
1102159047fSniklas }
1112159047fSniklas if (self->cg.index != 0)
1122159047fSniklas {
1132159047fSniklas if (self->cg.print_flag)
1142159047fSniklas {
1152159047fSniklas printf (" [%d]", self->cg.index);
1162159047fSniklas }
1172159047fSniklas else
1182159047fSniklas {
1192159047fSniklas printf (" (%d)", self->cg.index);
1202159047fSniklas }
1212159047fSniklas }
1222159047fSniklas }
123