source: branches/libc-0.6/src/binutils/gprof/gprof.c@ 2653

Last change on this file since 2653 was 610, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r609,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 16.2 KB
Line 
1/*
2 * Copyright (c) 1983, 1993, 1998, 2001, 2002
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the University nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include "libiberty.h"
31#include "gprof.h"
32#include "search_list.h"
33#include "source.h"
34#include "symtab.h"
35#include "basic_blocks.h"
36#include "call_graph.h"
37#include "cg_arcs.h"
38#include "cg_print.h"
39#include "corefile.h"
40#include "gmon_io.h"
41#include "hertz.h"
42#include "hist.h"
43#include "sym_ids.h"
44#include "demangle.h"
45#include "getopt.h"
46
47static void usage PARAMS ((FILE *, int)) ATTRIBUTE_NORETURN;
48int main PARAMS ((int, char **));
49
50const char *whoami;
51const char *function_mapping_file;
52const char *a_out_name = A_OUTNAME;
53long hz = HZ_WRONG;
54
55/*
56 * Default options values:
57 */
58int debug_level = 0;
59int output_style = 0;
60int output_width = 80;
61bfd_boolean bsd_style_output = FALSE;
62bfd_boolean demangle = TRUE;
63bfd_boolean discard_underscores = TRUE;
64bfd_boolean ignore_direct_calls = FALSE;
65bfd_boolean ignore_static_funcs = FALSE;
66bfd_boolean ignore_zeros = TRUE;
67bfd_boolean line_granularity = FALSE;
68bfd_boolean print_descriptions = TRUE;
69bfd_boolean print_path = FALSE;
70bfd_boolean ignore_non_functions = FALSE;
71File_Format file_format = FF_AUTO;
72
73bfd_boolean first_output = TRUE;
74
75char copyright[] =
76 "@(#) Copyright (c) 1983 Regents of the University of California.\n\
77 All rights reserved.\n";
78
79static char *gmon_name = GMONNAME; /* profile filename */
80
81bfd *abfd;
82
83/*
84 * Functions that get excluded by default:
85 */
86static char *default_excluded_list[] =
87{
88 "_gprof_mcount", "mcount", "_mcount", "__mcount", "__mcount_internal",
89 "__mcleanup",
90 "<locore>", "<hicore>",
91 0
92};
93
94/* Codes used for the long options with no short synonyms. 150 isn't
95 special; it's just an arbitrary non-ASCII char value. */
96
97#define OPTION_DEMANGLE (150)
98#define OPTION_NO_DEMANGLE (OPTION_DEMANGLE + 1)
99
100static struct option long_options[] =
101{
102 {"line", no_argument, 0, 'l'},
103 {"no-static", no_argument, 0, 'a'},
104 {"ignore-non-functions", no_argument, 0, 'D'},
105
106 /* output styles: */
107