binutils-gdb/gprof/utils.c

123 lines
3.2 KiB
C
Raw Normal View History

1999-05-03 09:29:11 +02:00
/*
2002-07-30 11:07:00 +02:00
* Copyright (c) 1983, 1993, 2001
* The Regents of the University of California. All rights reserved.
1999-05-03 09:29:11 +02:00
*
2002-07-30 11:07:00 +02:00
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
1999-05-03 09:29:11 +02:00
*/
* alpha.c (alpha_Instruction): Don't use. (alpha_find_call): Avoid use of bitfields and casts between pointers and integers of different sizes. Avoid endian problems when cross-compiling. * vax.c (vax_find_call): Likewise. (struct modebyte): Don't use. (vax_operandmode): Pass in an unsigned char *. (vax_operandlength): Likewise. (vax_reladdr): Rename to vax_offset and return relative offset rather than address. * i386.c (i386_find_call): Avoid casts between pointers and integers of different sizes. * sparc.c (sparc_find_call): Likewise. Avoid endian problems. * tahoe.c (tahoe_find_call): Likewise. (tahoe_reladdr): Rename to tahoe_offset and return relative offset rather than address. * basic_blocks.h: Don't include headers here. * call_graph.h: Likewise. * cg_arcs.h: Likewise. * cg_print.h: Likewise. * corefile.h: Likewise. * gmon_io.h: Likewise. * gmon_out.h: Likewise. * hertz.h: Likewise. * hist.h: Likewise. * source.h: Likewise. * sym_ids.h: Likewise. * symtab.h: Likewise. * gprof.h: Don't include ansidecl.h, do include bfd.h. (bool): Don't typedef. * alpha.c: Adjust #include's for above header changes. * basic_blocks.c: Likewise. * call_graph.c: Likewise. * cg_arcs.c: Likewise. * cg_dfn.c: Likewise. * cg_print.c: Likewise. * corefile.c: Likewise. * gmon_io.c: Likewise. * gprof.c: Likewise. * hertz.c: Likewise. * hist.c: Likewise. * i386.c: Likewise. * mips.c: Likewise. * sparc.c: Likewise. * sym_ids.c: Likewise. * symtab.c: Likewise. * tahoe.c: Likewise. * utils.c: Likewise. * vax.c: Likewise. * po/POTFILES.in: Regenerate.
2002-01-31 13:56:08 +01:00
#include "demangle.h"
1999-05-03 09:29:11 +02:00
#include "gprof.h"
* alpha.c (alpha_Instruction): Don't use. (alpha_find_call): Avoid use of bitfields and casts between pointers and integers of different sizes. Avoid endian problems when cross-compiling. * vax.c (vax_find_call): Likewise. (struct modebyte): Don't use. (vax_operandmode): Pass in an unsigned char *. (vax_operandlength): Likewise. (vax_reladdr): Rename to vax_offset and return relative offset rather than address. * i386.c (i386_find_call): Avoid casts between pointers and integers of different sizes. * sparc.c (sparc_find_call): Likewise. Avoid endian problems. * tahoe.c (tahoe_find_call): Likewise. (tahoe_reladdr): Rename to tahoe_offset and return relative offset rather than address. * basic_blocks.h: Don't include headers here. * call_graph.h: Likewise. * cg_arcs.h: Likewise. * cg_print.h: Likewise. * corefile.h: Likewise. * gmon_io.h: Likewise. * gmon_out.h: Likewise. * hertz.h: Likewise. * hist.h: Likewise. * source.h: Likewise. * sym_ids.h: Likewise. * symtab.h: Likewise. * gprof.h: Don't include ansidecl.h, do include bfd.h. (bool): Don't typedef. * alpha.c: Adjust #include's for above header changes. * basic_blocks.c: Likewise. * call_graph.c: Likewise. * cg_arcs.c: Likewise. * cg_dfn.c: Likewise. * cg_print.c: Likewise. * corefile.c: Likewise. * gmon_io.c: Likewise. * gprof.c: Likewise. * hertz.c: Likewise. * hist.c: Likewise. * i386.c: Likewise. * mips.c: Likewise. * sparc.c: Likewise. * sym_ids.c: Likewise. * symtab.c: Likewise. * tahoe.c: Likewise. * utils.c: Likewise. * vax.c: Likewise. * po/POTFILES.in: Regenerate.
2002-01-31 13:56:08 +01:00
#include "search_list.h"
#include "source.h"
1999-05-03 09:29:11 +02:00
#include "symtab.h"
* alpha.c (alpha_Instruction): Don't use. (alpha_find_call): Avoid use of bitfields and casts between pointers and integers of different sizes. Avoid endian problems when cross-compiling. * vax.c (vax_find_call): Likewise. (struct modebyte): Don't use. (vax_operandmode): Pass in an unsigned char *. (vax_operandlength): Likewise. (vax_reladdr): Rename to vax_offset and return relative offset rather than address. * i386.c (i386_find_call): Avoid casts between pointers and integers of different sizes. * sparc.c (sparc_find_call): Likewise. Avoid endian problems. * tahoe.c (tahoe_find_call): Likewise. (tahoe_reladdr): Rename to tahoe_offset and return relative offset rather than address. * basic_blocks.h: Don't include headers here. * call_graph.h: Likewise. * cg_arcs.h: Likewise. * cg_print.h: Likewise. * corefile.h: Likewise. * gmon_io.h: Likewise. * gmon_out.h: Likewise. * hertz.h: Likewise. * hist.h: Likewise. * source.h: Likewise. * sym_ids.h: Likewise. * symtab.h: Likewise. * gprof.h: Don't include ansidecl.h, do include bfd.h. (bool): Don't typedef. * alpha.c: Adjust #include's for above header changes. * basic_blocks.c: Likewise. * call_graph.c: Likewise. * cg_arcs.c: Likewise. * cg_dfn.c: Likewise. * cg_print.c: Likewise. * corefile.c: Likewise. * gmon_io.c: Likewise. * gprof.c: Likewise. * hertz.c: Likewise. * hist.c: Likewise. * i386.c: Likewise. * mips.c: Likewise. * sparc.c: Likewise. * sym_ids.c: Likewise. * symtab.c: Likewise. * tahoe.c: Likewise. * utils.c: Likewise. * vax.c: Likewise. * po/POTFILES.in: Regenerate.
2002-01-31 13:56:08 +01:00
#include "cg_arcs.h"
#include "utils.h"
1999-05-03 09:29:11 +02:00
/*
* Print name of symbol. Return number of characters printed.
*/
int
print_name_only (self)
Sym *self;
1999-05-03 09:29:11 +02:00
{
const char *name = self->name;
const char *filename;
char *demangled = 0;
char buf[PATH_MAX];
int size = 0;
if (name)
{
if (!bsd_style_output)
{
if (name[0] == '_' && name[1] && discard_underscores)
{
name++;
}
if (demangle)
{
demangled = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
if (demangled)
{
name = demangled;
}
}
}
printf ("%s", name);
size = strlen (name);
if (line_granularity && self->file)
{
filename = self->file->name;
if (!print_path)
{
filename = strrchr (filename, '/');
if (filename)
{
++filename;
}
else
{
filename = self->file->name;
}
}
sprintf (buf, " (%s:%d @ %lx)", filename, self->line_num,
(unsigned long) self->addr);
printf ("%s", buf);
1999-05-03 09:29:11 +02:00
size += strlen (buf);
}
if (demangled)
{
free (demangled);
}
DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order));
DBG (PROPDEBUG, printf ("%4.0f%% ", 100.0 * self->cg.prop.fract));
}
return size;
}
void
print_name (self)
Sym *self;
1999-05-03 09:29:11 +02:00
{
print_name_only (self);
if (self->cg.cyc.num != 0)
{
printf (_(" <cycle %d>"), self->cg.cyc.num);
}
if (self->cg.index != 0)
{
if (self->cg.print_flag)
{
printf (" [%d]", self->cg.index);
}
else
{
printf (" (%d)", self->cg.index);
}
}
}