| 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 |
|
|---|
| 47 | static void usage PARAMS ((FILE *, int)) ATTRIBUTE_NORETURN;
|
|---|
| 48 | int main PARAMS ((int, char **));
|
|---|
| 49 |
|
|---|
| 50 | const char *whoami;
|
|---|
| 51 | const char *function_mapping_file;
|
|---|
| 52 | const char *a_out_name = A_OUTNAME;
|
|---|
| 53 | long hz = HZ_WRONG;
|
|---|
| 54 |
|
|---|
| 55 | /*
|
|---|
| 56 | * Default options values:
|
|---|
| 57 | */
|
|---|
| 58 | int debug_level = 0;
|
|---|
| 59 | int output_style = 0;
|
|---|
| 60 | int output_width = 80;
|
|---|
| 61 | bfd_boolean bsd_style_output = FALSE;
|
|---|
| 62 | bfd_boolean demangle = TRUE;
|
|---|
| 63 | bfd_boolean discard_underscores = TRUE;
|
|---|
| 64 | bfd_boolean ignore_direct_calls = FALSE;
|
|---|
| 65 | bfd_boolean ignore_static_funcs = FALSE;
|
|---|
| 66 | bfd_boolean ignore_zeros = TRUE;
|
|---|
| 67 | bfd_boolean line_granularity = FALSE;
|
|---|
| 68 | bfd_boolean print_descriptions = TRUE;
|
|---|
| 69 | bfd_boolean print_path = FALSE;
|
|---|
| 70 | bfd_boolean ignore_non_functions = FALSE;
|
|---|
| 71 | File_Format file_format = FF_AUTO;
|
|---|
| 72 |
|
|---|
| 73 | bfd_boolean first_output = TRUE;
|
|---|
| 74 |
|
|---|
| 75 | char copyright[] =
|
|---|
| 76 | "@(#) Copyright (c) 1983 Regents of the University of California.\n\
|
|---|
| 77 | All rights reserved.\n";
|
|---|
| 78 |
|
|---|
| 79 | static char *gmon_name = GMONNAME; /* profile filename */
|
|---|
| 80 |
|
|---|
| 81 | bfd *abfd;
|
|---|
| 82 |
|
|---|
| 83 | /*
|
|---|
| 84 | * Functions that get excluded by default:
|
|---|
| 85 | */
|
|---|
| 86 | static 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 |
|
|---|
| 100 | static 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 |
|
|---|
|
|---|