OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [gprof/] [gprof.c] - Diff between revs 156 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 156 Rev 816
/*
/*
 * Copyright (c) 1983, 1993, 1998, 2001, 2002
 * Copyright (c) 1983, 1993, 1998, 2001, 2002
 *      The Regents of the University of California.  All rights reserved.
 *      The Regents of the University of California.  All rights reserved.
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * modification, are permitted provided that the following conditions
 * are met:
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the University nor the names of its contributors
 * 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
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *    without specific prior written permission.
 *
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * 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
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 * SUCH DAMAGE.
 */
 */
 
 
#include "libiberty.h"
#include "libiberty.h"
#include "gprof.h"
#include "gprof.h"
#include "bfdver.h"
#include "bfdver.h"
#include "search_list.h"
#include "search_list.h"
#include "source.h"
#include "source.h"
#include "symtab.h"
#include "symtab.h"
#include "basic_blocks.h"
#include "basic_blocks.h"
#include "call_graph.h"
#include "call_graph.h"
#include "cg_arcs.h"
#include "cg_arcs.h"
#include "cg_print.h"
#include "cg_print.h"
#include "corefile.h"
#include "corefile.h"
#include "gmon_io.h"
#include "gmon_io.h"
#include "hertz.h"
#include "hertz.h"
#include "hist.h"
#include "hist.h"
#include "sym_ids.h"
#include "sym_ids.h"
#include "demangle.h"
#include "demangle.h"
#include "getopt.h"
#include "getopt.h"
 
 
static void usage (FILE *, int) ATTRIBUTE_NORETURN;
static void usage (FILE *, int) ATTRIBUTE_NORETURN;
 
 
const char *whoami;
const char *whoami;
const char *function_mapping_file;
const char *function_mapping_file;
const char *a_out_name = A_OUTNAME;
const char *a_out_name = A_OUTNAME;
long hz = HZ_WRONG;
long hz = HZ_WRONG;
 
 
/*
/*
 * Default options values:
 * Default options values:
 */
 */
int debug_level = 0;
int debug_level = 0;
int output_style = 0;
int output_style = 0;
int output_width = 80;
int output_width = 80;
bfd_boolean bsd_style_output = FALSE;
bfd_boolean bsd_style_output = FALSE;
bfd_boolean demangle = TRUE;
bfd_boolean demangle = TRUE;
bfd_boolean ignore_direct_calls = FALSE;
bfd_boolean ignore_direct_calls = FALSE;
bfd_boolean ignore_static_funcs = FALSE;
bfd_boolean ignore_static_funcs = FALSE;
bfd_boolean ignore_zeros = TRUE;
bfd_boolean ignore_zeros = TRUE;
bfd_boolean line_granularity = FALSE;
bfd_boolean line_granularity = FALSE;
bfd_boolean print_descriptions = TRUE;
bfd_boolean print_descriptions = TRUE;
bfd_boolean print_path = FALSE;
bfd_boolean print_path = FALSE;
bfd_boolean ignore_non_functions = FALSE;
bfd_boolean ignore_non_functions = FALSE;
File_Format file_format = FF_AUTO;
File_Format file_format = FF_AUTO;
 
 
bfd_boolean first_output = TRUE;
bfd_boolean first_output = TRUE;
 
 
char copyright[] =
char copyright[] =
 "@(#) Copyright (c) 1983 Regents of the University of California.\n\
 "@(#) Copyright (c) 1983 Regents of the University of California.\n\
 All rights reserved.\n";
 All rights reserved.\n";
 
 
static char *gmon_name = GMONNAME;      /* profile filename */
static char *gmon_name = GMONNAME;      /* profile filename */
 
 
/*
/*
 * Functions that get excluded by default:
 * Functions that get excluded by default:
 */
 */
static char *default_excluded_list[] =
static char *default_excluded_list[] =
{
{
  "_gprof_mcount", "mcount", "_mcount", "__mcount", "__mcount_internal",
  "_gprof_mcount", "mcount", "_mcount", "__mcount", "__mcount_internal",
  "__mcleanup",
  "__mcleanup",
  "<locore>", "<hicore>",
  "<locore>", "<hicore>",
  0
  0
};
};
 
 
/* Codes used for the long options with no short synonyms.  150 isn't
/* Codes used for the long options with no short synonyms.  150 isn't
   special; it's just an arbitrary non-ASCII char value.  */
   special; it's just an arbitrary non-ASCII char value.  */
 
 
#define OPTION_DEMANGLE         (150)
#define OPTION_DEMANGLE         (150)
#define OPTION_NO_DEMANGLE      (OPTION_DEMANGLE + 1)
#define OPTION_NO_DEMANGLE      (OPTION_DEMANGLE + 1)
 
 
static struct option long_options[] =
static struct option long_options[] =
{
{
  {"line", no_argument, 0, 'l'},
  {"line", no_argument, 0, 'l'},
  {"no-static", no_argument, 0, 'a'},
  {"no-static", no_argument, 0, 'a'},
  {"ignore-non-functions", no_argument, 0, 'D'},
  {"ignore-non-functions", no_argument, 0, 'D'},
 
 
    /* output styles: */
    /* output styles: */
 
 
  {"annotated-source", optional_argument, 0, 'A'},
  {"annotated-source", optional_argument, 0, 'A'},
  {"no-annotated-source", optional_argument, 0, 'J'},
  {"no-annotated-source", optional_argument, 0, 'J'},
  {"flat-profile", optional_argument, 0, 'p'},
  {"flat-profile", optional_argument, 0, 'p'},
  {"no-flat-profile", optional_argument, 0, 'P'},
  {"no-flat-profile", optional_argument, 0, 'P'},
  {"graph", optional_argument, 0, 'q'},
  {"graph", optional_argument, 0, 'q'},
  {"no-graph", optional_argument, 0, 'Q'},
  {"no-graph", optional_argument, 0, 'Q'},
  {"exec-counts", optional_argument, 0, 'C'},
  {"exec-counts", optional_argument, 0, 'C'},
  {"no-exec-counts", optional_argument, 0, 'Z'},
  {"no-exec-counts", optional_argument, 0, 'Z'},
  {"function-ordering", no_argument, 0, 'r'},
  {"function-ordering", no_argument, 0, 'r'},
  {"file-ordering", required_argument, 0, 'R'},
  {"file-ordering", required_argument, 0, 'R'},
  {"file-info", no_argument, 0, 'i'},
  {"file-info", no_argument, 0, 'i'},
  {"sum", no_argument, 0, 's'},
  {"sum", no_argument, 0, 's'},
 
 
    /* various options to affect output: */
    /* various options to affect output: */
 
 
  {"all-lines", no_argument, 0, 'x'},
  {"all-lines", no_argument, 0, 'x'},
  {"demangle", optional_argument, 0, OPTION_DEMANGLE},
  {"demangle", optional_argument, 0, OPTION_DEMANGLE},
  {"no-demangle", no_argument, 0, OPTION_NO_DEMANGLE},
  {"no-demangle", no_argument, 0, OPTION_NO_DEMANGLE},
  {"directory-path", required_argument, 0, 'I'},
  {"directory-path", required_argument, 0, 'I'},
  {"display-unused-functions", no_argument, 0, 'z'},
  {"display-unused-functions", no_argument, 0, 'z'},
  {"min-count", required_argument, 0, 'm'},
  {"min-count", required_argument, 0, 'm'},
  {"print-path", no_argument, 0, 'L'},
  {"print-path", no_argument, 0, 'L'},
  {"separate-files", no_argument, 0, 'y'},
  {"separate-files", no_argument, 0, 'y'},
  {"static-call-graph", no_argument, 0, 'c'},
  {"static-call-graph", no_argument, 0, 'c'},
  {"table-length", required_argument, 0, 't'},
  {"table-length", required_argument, 0, 't'},
  {"time", required_argument, 0, 'n'},
  {"time", required_argument, 0, 'n'},
  {"no-time", required_argument, 0, 'N'},
  {"no-time", required_argument, 0, 'N'},
  {"width", required_argument, 0, 'w'},
  {"width", required_argument, 0, 'w'},
    /*
    /*
     * These are for backwards-compatibility only.  Their functionality
     * These are for backwards-compatibility only.  Their functionality
     * is provided by the output style options already:
     * is provided by the output style options already:
     */
     */
  {"", required_argument, 0, 'e'},
  {"", required_argument, 0, 'e'},
  {"", required_argument, 0, 'E'},
  {"", required_argument, 0, 'E'},
  {"", required_argument, 0, 'f'},
  {"", required_argument, 0, 'f'},
  {"", required_argument, 0, 'F'},
  {"", required_argument, 0, 'F'},
  {"", required_argument, 0, 'k'},
  {"", required_argument, 0, 'k'},
 
 
    /* miscellaneous: */
    /* miscellaneous: */
 
 
  {"brief", no_argument, 0, 'b'},
  {"brief", no_argument, 0, 'b'},
  {"debug", optional_argument, 0, 'd'},
  {"debug", optional_argument, 0, 'd'},
  {"help", no_argument, 0, 'h'},
  {"help", no_argument, 0, 'h'},
  {"file-format", required_argument, 0, 'O'},
  {"file-format", required_argument, 0, 'O'},
  {"traditional", no_argument, 0, 'T'},
  {"traditional", no_argument, 0, 'T'},
  {"version", no_argument, 0, 'v'},
  {"version", no_argument, 0, 'v'},
  {0, no_argument, 0, 0}
  {0, no_argument, 0, 0}
};
};
 
 
 
 
static void
static void
usage (FILE *stream, int status)
usage (FILE *stream, int status)
{
{
  fprintf (stream, _("\
  fprintf (stream, _("\
Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\
Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\
        [-d[num]] [-k from/to] [-m min-count] [-t table-length]\n\
        [-d[num]] [-k from/to] [-m min-count] [-t table-length]\n\
        [--[no-]annotated-source[=name]] [--[no-]exec-counts[=name]]\n\
        [--[no-]annotated-source[=name]] [--[no-]exec-counts[=name]]\n\
        [--[no-]flat-profile[=name]] [--[no-]graph[=name]]\n\
        [--[no-]flat-profile[=name]] [--[no-]graph[=name]]\n\
        [--[no-]time=name] [--all-lines] [--brief] [--debug[=level]]\n\
        [--[no-]time=name] [--all-lines] [--brief] [--debug[=level]]\n\
        [--function-ordering] [--file-ordering]\n\
        [--function-ordering] [--file-ordering]\n\
        [--directory-path=dirs] [--display-unused-functions]\n\
        [--directory-path=dirs] [--display-unused-functions]\n\
        [--file-format=name] [--file-info] [--help] [--line] [--min-count=n]\n\
        [--file-format=name] [--file-info] [--help] [--line] [--min-count=n]\n\
        [--no-static] [--print-path] [--separate-files]\n\
        [--no-static] [--print-path] [--separate-files]\n\
        [--static-call-graph] [--sum] [--table-length=len] [--traditional]\n\
        [--static-call-graph] [--sum] [--table-length=len] [--traditional]\n\
        [--version] [--width=n] [--ignore-non-functions]\n\
        [--version] [--width=n] [--ignore-non-functions]\n\
        [--demangle[=STYLE]] [--no-demangle] [@FILE]\n\
        [--demangle[=STYLE]] [--no-demangle] [@FILE]\n\
        [image-file] [profile-file...]\n"),
        [image-file] [profile-file...]\n"),
           whoami);
           whoami);
  if (REPORT_BUGS_TO[0] && status == 0)
  if (REPORT_BUGS_TO[0] && status == 0)
    fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO);
    fprintf (stream, _("Report bugs to %s\n"), REPORT_BUGS_TO);
  done (status);
  done (status);
}
}
 
 
 
 
int
int
main (int argc, char **argv)
main (int argc, char **argv)
{
{
  char **sp, *str;
  char **sp, *str;
  Sym **cg = 0;
  Sym **cg = 0;
  int ch, user_specified = 0;
  int ch, user_specified = 0;
 
 
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
#if defined (HAVE_SETLOCALE) && defined (HAVE_LC_MESSAGES)
  setlocale (LC_MESSAGES, "");
  setlocale (LC_MESSAGES, "");
#endif
#endif
#if defined (HAVE_SETLOCALE)
#if defined (HAVE_SETLOCALE)
  setlocale (LC_CTYPE, "");
  setlocale (LC_CTYPE, "");
#endif
#endif
#ifdef ENABLE_NLS
#ifdef ENABLE_NLS
  bindtextdomain (PACKAGE, LOCALEDIR);
  bindtextdomain (PACKAGE, LOCALEDIR);
  textdomain (PACKAGE);
  textdomain (PACKAGE);
#endif
#endif
 
 
  whoami = argv[0];
  whoami = argv[0];
  xmalloc_set_program_name (whoami);
  xmalloc_set_program_name (whoami);
 
 
  expandargv (&argc, &argv);
  expandargv (&argc, &argv);
 
 
  while ((ch = getopt_long (argc, argv,
  while ((ch = getopt_long (argc, argv,
        "aA::bBcC::d::De:E:f:F:hiI:J::k:lLm:n:N:O:p::P::q::Q::rR:st:Tvw:xyzZ::",
        "aA::bBcC::d::De:E:f:F:hiI:J::k:lLm:n:N:O:p::P::q::Q::rR:st:Tvw:xyzZ::",
                            long_options, 0))
                            long_options, 0))
         != EOF)
         != EOF)
    {
    {
      switch (ch)
      switch (ch)
        {
        {
        case 'a':
        case 'a':
          ignore_static_funcs = TRUE;
          ignore_static_funcs = TRUE;
          break;
          break;
        case 'A':
        case 'A':
          if (optarg)
          if (optarg)
            {
            {
              sym_id_add (optarg, INCL_ANNO);
              sym_id_add (optarg, INCL_ANNO);
            }
            }
          output_style |= STYLE_ANNOTATED_SOURCE;
          output_style |= STYLE_ANNOTATED_SOURCE;
          user_specified |= STYLE_ANNOTATED_SOURCE;
          user_specified |= STYLE_ANNOTATED_SOURCE;
          break;
          break;
        case 'b':
        case 'b':
          print_descriptions = FALSE;
          print_descriptions = FALSE;
          break;
          break;
        case 'B':
        case 'B':
          output_style |= STYLE_CALL_GRAPH;
          output_style |= STYLE_CALL_GRAPH;
          user_specified |= STYLE_CALL_GRAPH;
          user_specified |= STYLE_CALL_GRAPH;
          break;
          break;
        case 'c':
        case 'c':
          ignore_direct_calls = TRUE;
          ignore_direct_calls = TRUE;
          break;
          break;
        case 'C':
        case 'C':
          if (optarg)
          if (optarg)
            {
            {
              sym_id_add (optarg, INCL_EXEC);
              sym_id_add (optarg, INCL_EXEC);
            }
            }
          output_style |= STYLE_EXEC_COUNTS;
          output_style |= STYLE_EXEC_COUNTS;
          user_specified |= STYLE_EXEC_COUNTS;
          user_specified |= STYLE_EXEC_COUNTS;
          break;
          break;
        case 'd':
        case 'd':
          if (optarg)
          if (optarg)
            {
            {
              debug_level |= atoi (optarg);
              debug_level |= atoi (optarg);
              debug_level |= ANYDEBUG;
              debug_level |= ANYDEBUG;
            }
            }
          else
          else
            {
            {
              debug_level = ~0;
              debug_level = ~0;
            }
            }
          DBG (ANYDEBUG, printf ("[main] debug-level=0x%x\n", debug_level));
          DBG (ANYDEBUG, printf ("[main] debug-level=0x%x\n", debug_level));
#ifndef DEBUG
#ifndef DEBUG
          printf (_("%s: debugging not supported; -d ignored\n"), whoami);
          printf (_("%s: debugging not supported; -d ignored\n"), whoami);
#endif  /* DEBUG */
#endif  /* DEBUG */
          break;
          break;
        case 'D':
        case 'D':
          ignore_non_functions = TRUE;
          ignore_non_functions = TRUE;
          break;
          break;
        case 'E':
        case 'E':
          sym_id_add (optarg, EXCL_TIME);
          sym_id_add (optarg, EXCL_TIME);
        case 'e':
        case 'e':
          sym_id_add (optarg, EXCL_GRAPH);
          sym_id_add (optarg, EXCL_GRAPH);
          break;
          break;
        case 'F':
        case 'F':
          sym_id_add (optarg, INCL_TIME);
          sym_id_add (optarg, INCL_TIME);
        case 'f':
        case 'f':
          sym_id_add (optarg, INCL_GRAPH);
          sym_id_add (optarg, INCL_GRAPH);
          break;
          break;
        case 'g':
        case 'g':
          sym_id_add (optarg, EXCL_FLAT);
          sym_id_add (optarg, EXCL_FLAT);
          break;
          break;
        case 'G':
        case 'G':
          sym_id_add (optarg, INCL_FLAT);
          sym_id_add (optarg, INCL_FLAT);
          break;
          break;
        case 'h':
        case 'h':
          usage (stdout, 0);
          usage (stdout, 0);
        case 'i':
        case 'i':
          output_style |= STYLE_GMON_INFO;
          output_style |= STYLE_GMON_INFO;
          user_specified |= STYLE_GMON_INFO;
          user_specified |= STYLE_GMON_INFO;
          break;
          break;
        case 'I':
        case 'I':
          search_list_append (&src_search_list, optarg);
          search_list_append (&src_search_list, optarg);
          break;
          break;
        case 'J':
        case 'J':
          if (optarg)
          if (optarg)
            {
            {
              sym_id_add (optarg, EXCL_ANNO);
              sym_id_add (optarg, EXCL_ANNO);
              output_style |= STYLE_ANNOTATED_SOURCE;
              output_style |= STYLE_ANNOTATED_SOURCE;
            }
            }
          else
          else
            {
            {
              output_style &= ~STYLE_ANNOTATED_SOURCE;
              output_style &= ~STYLE_ANNOTATED_SOURCE;
            }
            }
          user_specified |= STYLE_ANNOTATED_SOURCE;
          user_specified |= STYLE_ANNOTATED_SOURCE;
          break;
          break;
        case 'k':
        case 'k':
          sym_id_add (optarg, EXCL_ARCS);
          sym_id_add (optarg, EXCL_ARCS);
          break;
          break;
        case 'l':
        case 'l':
          line_granularity = TRUE;
          line_granularity = TRUE;
          break;
          break;
        case 'L':
        case 'L':
          print_path = TRUE;
          print_path = TRUE;
          break;
          break;
        case 'm':
        case 'm':
          bb_min_calls = (unsigned long) strtoul (optarg, (char **) NULL, 10);
          bb_min_calls = (unsigned long) strtoul (optarg, (char **) NULL, 10);
          break;
          break;
        case 'n':
        case 'n':
          sym_id_add (optarg, INCL_TIME);
          sym_id_add (optarg, INCL_TIME);
          break;
          break;
        case 'N':
        case 'N':
          sym_id_add (optarg, EXCL_TIME);
          sym_id_add (optarg, EXCL_TIME);
          break;
          break;
        case 'O':
        case 'O':
          switch (optarg[0])
          switch (optarg[0])
            {
            {
            case 'a':
            case 'a':
              file_format = FF_AUTO;
              file_format = FF_AUTO;
              break;
              break;
            case 'm':
            case 'm':
              file_format = FF_MAGIC;
              file_format = FF_MAGIC;
              break;
              break;
            case 'b':
            case 'b':
              file_format = FF_BSD;
              file_format = FF_BSD;
              break;
              break;
            case '4':
            case '4':
              file_format = FF_BSD44;
              file_format = FF_BSD44;
              break;
              break;
            case 'p':
            case 'p':
              file_format = FF_PROF;
              file_format = FF_PROF;
              break;
              break;
            default:
            default:
              fprintf (stderr, _("%s: unknown file format %s\n"),
              fprintf (stderr, _("%s: unknown file format %s\n"),
                       optarg, whoami);
                       optarg, whoami);
              done (1);
              done (1);
            }
            }
          break;
          break;
        case 'p':
        case 'p':
          if (optarg)
          if (optarg)
            {
            {
              sym_id_add (optarg, INCL_FLAT);
              sym_id_add (optarg, INCL_FLAT);
            }
            }
          output_style |= STYLE_FLAT_PROFILE;
          output_style |= STYLE_FLAT_PROFILE;
          user_specified |= STYLE_FLAT_PROFILE;
          user_specified |= STYLE_FLAT_PROFILE;
          break;
          break;
        case 'P':
        case 'P':
          if (optarg)
          if (optarg)
            {
            {
              sym_id_add (optarg, EXCL_FLAT);
              sym_id_add (optarg, EXCL_FLAT);
              output_style |= STYLE_FLAT_PROFILE;
              output_style |= STYLE_FLAT_PROFILE;
            }
            }
          else
          else
            {
            {
              output_style &= ~STYLE_FLAT_PROFILE;
              output_style &= ~STYLE_FLAT_PROFILE;
            }
            }
          user_specified |= STYLE_FLAT_PROFILE;
          user_specified |= STYLE_FLAT_PROFILE;
          break;
          break;
        case 'q':
        case 'q':
          if (optarg)
          if (optarg)
            {
            {
              if (strchr (optarg, '/'))
              if (strchr (optarg, '/'))
                {
                {
                  sym_id_add (optarg, INCL_ARCS);
                  sym_id_add (optarg, INCL_ARCS);
                }
                }
              else
              else
                {
                {
                  sym_id_add (optarg, INCL_GRAPH);
                  sym_id_add (optarg, INCL_GRAPH);
                }
                }
            }
            }
          output_style |= STYLE_CALL_GRAPH;
          output_style |= STYLE_CALL_GRAPH;
          user_specified |= STYLE_CALL_GRAPH;
          user_specified |= STYLE_CALL_GRAPH;
          break;
          break;
        case 'r':
        case 'r':
          output_style |= STYLE_FUNCTION_ORDER;
          output_style |= STYLE_FUNCTION_ORDER;
          user_specified |= STYLE_FUNCTION_ORDER;
          user_specified |= STYLE_FUNCTION_ORDER;
          break;
          break;
        case 'R':
        case 'R':
          output_style |= STYLE_FILE_ORDER;
          output_style |= STYLE_FILE_ORDER;
          user_specified |= STYLE_FILE_ORDER;
          user_specified |= STYLE_FILE_ORDER;
          function_mapping_file = optarg;
          function_mapping_file = optarg;
          break;
          break;
        case 'Q':
        case 'Q':
          if (optarg)
          if (optarg)
            {
            {
              if (strchr (optarg, '/'))
              if (strchr (optarg, '/'))
                {
                {
                  sym_id_add (optarg, EXCL_ARCS);
                  sym_id_add (optarg, EXCL_ARCS);
                }
                }
              else
              else
                {
                {
                  sym_id_add (optarg, EXCL_GRAPH);
                  sym_id_add (optarg, EXCL_GRAPH);
                }
                }
              output_style |= STYLE_CALL_GRAPH;
              output_style |= STYLE_CALL_GRAPH;
            }
            }
          else
          else
            {
            {
              output_style &= ~STYLE_CALL_GRAPH;
              output_style &= ~STYLE_CALL_GRAPH;
            }
            }
          user_specified |= STYLE_CALL_GRAPH;
          user_specified |= STYLE_CALL_GRAPH;
          break;
          break;
        case 's':
        case 's':
          output_style |= STYLE_SUMMARY_FILE;
          output_style |= STYLE_SUMMARY_FILE;
          user_specified |= STYLE_SUMMARY_FILE;
          user_specified |= STYLE_SUMMARY_FILE;
          break;
          break;
        case 't':
        case 't':
          bb_table_length = atoi (optarg);
          bb_table_length = atoi (optarg);
          if (bb_table_length < 0)
          if (bb_table_length < 0)
            {
            {
              bb_table_length = 0;
              bb_table_length = 0;
            }
            }
          break;
          break;
        case 'T':
        case 'T':
          bsd_style_output = TRUE;
          bsd_style_output = TRUE;
          break;
          break;
        case 'v':
        case 'v':
          /* This output is intended to follow the GNU standards document.  */
          /* This output is intended to follow the GNU standards document.  */
          printf (_("GNU gprof %s\n"), BFD_VERSION_STRING);
          printf (_("GNU gprof %s\n"), BFD_VERSION_STRING);
          printf (_("Based on BSD gprof, copyright 1983 Regents of the University of California.\n"));
          printf (_("Based on BSD gprof, copyright 1983 Regents of the University of California.\n"));
          printf (_("\
          printf (_("\
This program is free software.  This program has absolutely no warranty.\n"));
This program is free software.  This program has absolutely no warranty.\n"));
          done (0);
          done (0);
        case 'w':
        case 'w':
          output_width = atoi (optarg);
          output_width = atoi (optarg);
          if (output_width < 1)
          if (output_width < 1)
            {
            {
              output_width = 1;
              output_width = 1;
            }
            }
          break;
          break;
        case 'x':
        case 'x':
          bb_annotate_all_lines = TRUE;
          bb_annotate_all_lines = TRUE;
          break;
          break;
        case 'y':
        case 'y':
          create_annotation_files = TRUE;
          create_annotation_files = TRUE;
          break;
          break;
        case 'z':
        case 'z':
          ignore_zeros = FALSE;
          ignore_zeros = FALSE;
          break;
          break;
        case 'Z':
        case 'Z':
          if (optarg)
          if (optarg)
            {
            {
              sym_id_add (optarg, EXCL_EXEC);
              sym_id_add (optarg, EXCL_EXEC);
              output_style |= STYLE_EXEC_COUNTS;
              output_style |= STYLE_EXEC_COUNTS;
            }
            }
          else
          else
            {
            {
              output_style &= ~STYLE_EXEC_COUNTS;
              output_style &= ~STYLE_EXEC_COUNTS;
            }
            }
          user_specified |= STYLE_ANNOTATED_SOURCE;
          user_specified |= STYLE_ANNOTATED_SOURCE;
          break;
          break;
        case OPTION_DEMANGLE:
        case OPTION_DEMANGLE:
          demangle = TRUE;
          demangle = TRUE;
          if (optarg != NULL)
          if (optarg != NULL)
            {
            {
              enum demangling_styles style;
              enum demangling_styles style;
 
 
              style = cplus_demangle_name_to_style (optarg);
              style = cplus_demangle_name_to_style (optarg);
              if (style == unknown_demangling)
              if (style == unknown_demangling)
                {
                {
                  fprintf (stderr,
                  fprintf (stderr,
                           _("%s: unknown demangling style `%s'\n"),
                           _("%s: unknown demangling style `%s'\n"),
                           whoami, optarg);
                           whoami, optarg);
                  xexit (1);
                  xexit (1);
                }
                }
 
 
              cplus_demangle_set_style (style);
              cplus_demangle_set_style (style);
           }
           }
          break;
          break;
        case OPTION_NO_DEMANGLE:
        case OPTION_NO_DEMANGLE:
          demangle = FALSE;
          demangle = FALSE;
          break;
          break;
        default:
        default:
          usage (stderr, 1);
          usage (stderr, 1);
        }
        }
    }
    }
 
 
  /* Don't allow both ordering options, they modify the arc data in-place.  */
  /* Don't allow both ordering options, they modify the arc data in-place.  */
  if ((user_specified & STYLE_FUNCTION_ORDER)
  if ((user_specified & STYLE_FUNCTION_ORDER)
      && (user_specified & STYLE_FILE_ORDER))
      && (user_specified & STYLE_FILE_ORDER))
    {
    {
      fprintf (stderr,_("\
      fprintf (stderr,_("\
%s: Only one of --function-ordering and --file-ordering may be specified.\n"),
%s: Only one of --function-ordering and --file-ordering may be specified.\n"),
               whoami);
               whoami);
      done (1);
      done (1);
    }
    }
 
 
  /* --sum implies --line, otherwise we'd lose basic block counts in
  /* --sum implies --line, otherwise we'd lose basic block counts in
       gmon.sum */
       gmon.sum */
  if (output_style & STYLE_SUMMARY_FILE)
  if (output_style & STYLE_SUMMARY_FILE)
    line_granularity = 1;
    line_granularity = 1;
 
 
  /* append value of GPROF_PATH to source search list if set: */
  /* append value of GPROF_PATH to source search list if set: */
  str = (char *) getenv ("GPROF_PATH");
  str = (char *) getenv ("GPROF_PATH");
  if (str)
  if (str)
    search_list_append (&src_search_list, str);
    search_list_append (&src_search_list, str);
 
 
  if (optind < argc)
  if (optind < argc)
    a_out_name = argv[optind++];
    a_out_name = argv[optind++];
 
 
  if (optind < argc)
  if (optind < argc)
    gmon_name = argv[optind++];
    gmon_name = argv[optind++];
 
 
  /* Turn off default functions.  */
  /* Turn off default functions.  */
  for (sp = &default_excluded_list[0]; *sp; sp++)
  for (sp = &default_excluded_list[0]; *sp; sp++)
    {
    {
      sym_id_add (*sp, EXCL_TIME);
      sym_id_add (*sp, EXCL_TIME);
      sym_id_add (*sp, EXCL_GRAPH);
      sym_id_add (*sp, EXCL_GRAPH);
      sym_id_add (*sp, EXCL_FLAT);
      sym_id_add (*sp, EXCL_FLAT);
    }
    }
 
 
  /* Read symbol table from core file.  */
  /* Read symbol table from core file.  */
  core_init (a_out_name);
  core_init (a_out_name);
 
 
  /* If we should ignore direct function calls, we need to load to
  /* If we should ignore direct function calls, we need to load to
     core's text-space.  */
     core's text-space.  */
  if (ignore_direct_calls)
  if (ignore_direct_calls)
    core_get_text_space (core_bfd);
    core_get_text_space (core_bfd);
 
 
  /* Create symbols from core image.  */
  /* Create symbols from core image.  */
  if (line_granularity)
  if (line_granularity)
    core_create_line_syms ();
    core_create_line_syms ();
  else
  else
    core_create_function_syms ();
    core_create_function_syms ();
 
 
  /* Translate sym specs into syms.  */
  /* Translate sym specs into syms.  */
  sym_id_parse ();
  sym_id_parse ();
 
 
  if (file_format == FF_PROF)
  if (file_format == FF_PROF)
    {
    {
      fprintf (stderr,
      fprintf (stderr,
               _("%s: sorry, file format `prof' is not yet supported\n"),
               _("%s: sorry, file format `prof' is not yet supported\n"),
               whoami);
               whoami);
      done (1);
      done (1);
    }
    }
  else
  else
    {
    {
      /* Get information about gmon.out file(s).  */
      /* Get information about gmon.out file(s).  */
      do
      do
        {
        {
          gmon_out_read (gmon_name);
          gmon_out_read (gmon_name);
          if (optind < argc)
          if (optind < argc)
            gmon_name = argv[optind];
            gmon_name = argv[optind];
        }
        }
      while (optind++ < argc);
      while (optind++ < argc);
    }
    }
 
 
  /* If user did not specify output style, try to guess something
  /* If user did not specify output style, try to guess something
     reasonable.  */
     reasonable.  */
  if (output_style == 0)
  if (output_style == 0)
    {
    {
      if (gmon_input & (INPUT_HISTOGRAM | INPUT_CALL_GRAPH))
      if (gmon_input & (INPUT_HISTOGRAM | INPUT_CALL_GRAPH))
        {
        {
          if (gmon_input & INPUT_HISTOGRAM)
          if (gmon_input & INPUT_HISTOGRAM)
            output_style |= STYLE_FLAT_PROFILE;
            output_style |= STYLE_FLAT_PROFILE;
          if (gmon_input & INPUT_CALL_GRAPH)
          if (gmon_input & INPUT_CALL_GRAPH)
            output_style |= STYLE_CALL_GRAPH;
            output_style |= STYLE_CALL_GRAPH;
        }
        }
      else
      else
        output_style = STYLE_EXEC_COUNTS;
        output_style = STYLE_EXEC_COUNTS;
 
 
      output_style &= ~user_specified;
      output_style &= ~user_specified;
    }
    }
 
 
  /* Dump a gmon.sum file if requested (before any other
  /* Dump a gmon.sum file if requested (before any other
     processing!)  */
     processing!)  */
  if (output_style & STYLE_SUMMARY_FILE)
  if (output_style & STYLE_SUMMARY_FILE)
    {
    {
      gmon_out_write (GMONSUM);
      gmon_out_write (GMONSUM);
    }
    }
 
 
  if (gmon_input & INPUT_HISTOGRAM)
  if (gmon_input & INPUT_HISTOGRAM)
    {
    {
      hist_assign_samples ();
      hist_assign_samples ();
    }
    }
 
 
  if (gmon_input & INPUT_CALL_GRAPH)
  if (gmon_input & INPUT_CALL_GRAPH)
    {
    {
      cg = cg_assemble ();
      cg = cg_assemble ();
    }
    }
 
 
  /* Do some simple sanity checks.  */
  /* Do some simple sanity checks.  */
  if ((output_style & STYLE_FLAT_PROFILE)
  if ((output_style & STYLE_FLAT_PROFILE)
      && !(gmon_input & INPUT_HISTOGRAM))
      && !(gmon_input & INPUT_HISTOGRAM))
    {
    {
      fprintf (stderr, _("%s: gmon.out file is missing histogram\n"), whoami);
      fprintf (stderr, _("%s: gmon.out file is missing histogram\n"), whoami);
      done (1);
      done (1);
    }
    }
 
 
  if ((output_style & STYLE_CALL_GRAPH) && !(gmon_input & INPUT_CALL_GRAPH))
  if ((output_style & STYLE_CALL_GRAPH) && !(gmon_input & INPUT_CALL_GRAPH))
    {
    {
      fprintf (stderr,
      fprintf (stderr,
               _("%s: gmon.out file is missing call-graph data\n"), whoami);
               _("%s: gmon.out file is missing call-graph data\n"), whoami);
      done (1);
      done (1);
    }
    }
 
 
  /* Output whatever user whishes to see.  */
  /* Output whatever user whishes to see.  */
  if (cg && (output_style & STYLE_CALL_GRAPH) && bsd_style_output)
  if (cg && (output_style & STYLE_CALL_GRAPH) && bsd_style_output)
    {
    {
      /* Print the dynamic profile.  */
      /* Print the dynamic profile.  */
      cg_print (cg);
      cg_print (cg);
    }
    }
 
 
  if (output_style & STYLE_FLAT_PROFILE)
  if (output_style & STYLE_FLAT_PROFILE)
    {
    {
      /* Print the flat profile.  */
      /* Print the flat profile.  */
      hist_print ();
      hist_print ();
    }
    }
 
 
  if (cg && (output_style & STYLE_CALL_GRAPH))
  if (cg && (output_style & STYLE_CALL_GRAPH))
    {
    {
      if (!bsd_style_output)
      if (!bsd_style_output)
        {
        {
          /* Print the dynamic profile.  */
          /* Print the dynamic profile.  */
          cg_print (cg);
          cg_print (cg);
        }
        }
      cg_print_index ();
      cg_print_index ();
    }
    }
 
 
  if (output_style & STYLE_EXEC_COUNTS)
  if (output_style & STYLE_EXEC_COUNTS)
    print_exec_counts ();
    print_exec_counts ();
 
 
  if (output_style & STYLE_ANNOTATED_SOURCE)
  if (output_style & STYLE_ANNOTATED_SOURCE)
    print_annotated_source ();
    print_annotated_source ();
 
 
  if (output_style & STYLE_FUNCTION_ORDER)
  if (output_style & STYLE_FUNCTION_ORDER)
    cg_print_function_ordering ();
    cg_print_function_ordering ();
 
 
  if (output_style & STYLE_FILE_ORDER)
  if (output_style & STYLE_FILE_ORDER)
    cg_print_file_ordering ();
    cg_print_file_ordering ();
 
 
  return 0;
  return 0;
}
}
 
 
void
void
done (int status)
done (int status)
{
{
  exit (status);
  exit (status);
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.