From 630b051036e446754f13d1f07cfd6de0612a90de Mon Sep 17 00:00:00 2001 From: Conrad Hoffmann Date: Thu, 21 Nov 2013 13:13:06 +0000 Subject: * gprof.c (inline_file_names): New variable. (OPTION_INLINE_FILE_NAMES): Define. (long_options): Add --inline-file-names. (usage): Likewise. (main): Process --inline-file-names. * gprof.h: Add prototype for inline_file_names. * utils.c (print_name_only): Handle inline_file_names. * gprof.texi: Document new command line option. --- gprof/ChangeLog | 11 +++++++++++ gprof/gprof.c | 12 +++++++++--- gprof/gprof.h | 1 + gprof/gprof.texi | 28 +++++++++++++++------------- gprof/utils.c | 13 ++++++++++--- 5 files changed, 46 insertions(+), 19 deletions(-) (limited to 'gprof') diff --git a/gprof/ChangeLog b/gprof/ChangeLog index c6190e9..d08636f 100644 --- a/gprof/ChangeLog +++ b/gprof/ChangeLog @@ -1,3 +1,14 @@ +2013-11-21 Conrad Hoffmann + + * gprof.c (inline_file_names): New variable. + (OPTION_INLINE_FILE_NAMES): Define. + (long_options): Add --inline-file-names. + (usage): Likewise. + (main): Process --inline-file-names. + * gprof.h: Add prototype for inline_file_names. + * utils.c (print_name_only): Handle inline_file_names. + * gprof.texi: Document new command line option. + 2013-11-02 Alan Modra * Makefile.am (.m.c): Fix input and output file specification. diff --git a/gprof/gprof.c b/gprof/gprof.c index 8d54538..6415c30 100644 --- a/gprof/gprof.c +++ b/gprof/gprof.c @@ -68,6 +68,7 @@ bfd_boolean line_granularity = FALSE; bfd_boolean print_descriptions = TRUE; bfd_boolean print_path = FALSE; bfd_boolean ignore_non_functions = FALSE; +bfd_boolean inline_file_names = FALSE; File_Format file_format = FF_AUTO; bfd_boolean first_output = TRUE; @@ -91,8 +92,9 @@ static char *default_excluded_list[] = /* Codes used for the long options with no short synonyms. 150 isn't special; it's just an arbitrary non-ASCII char value. */ -#define OPTION_DEMANGLE (150) -#define OPTION_NO_DEMANGLE (OPTION_DEMANGLE + 1) +#define OPTION_DEMANGLE (150) +#define OPTION_NO_DEMANGLE (OPTION_DEMANGLE + 1) +#define OPTION_INLINE_FILE_NAMES (OPTION_DEMANGLE + 2) static struct option long_options[] = { @@ -123,6 +125,7 @@ static struct option long_options[] = {"no-demangle", no_argument, 0, OPTION_NO_DEMANGLE}, {"directory-path", required_argument, 0, 'I'}, {"display-unused-functions", no_argument, 0, 'z'}, + {"inline-file-names", no_argument, 0, OPTION_INLINE_FILE_NAMES}, {"min-count", required_argument, 0, 'm'}, {"print-path", no_argument, 0, 'L'}, {"separate-files", no_argument, 0, 'y'}, @@ -162,7 +165,7 @@ Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqSQZ][name]] [-I dirs]\n\ [--[no-]annotated-source[=name]] [--[no-]exec-counts[=name]]\n\ [--[no-]flat-profile[=name]] [--[no-]graph[=name]]\n\ [--[no-]time=name] [--all-lines] [--brief] [--debug[=level]]\n\ - [--function-ordering] [--file-ordering]\n\ + [--function-ordering] [--file-ordering] [--inline-file-names]\n\ [--directory-path=dirs] [--display-unused-functions]\n\ [--file-format=name] [--file-info] [--help] [--line] [--min-count=n]\n\ [--no-static] [--print-path] [--separate-files]\n\ @@ -470,6 +473,9 @@ This program is free software. This program has absolutely no warranty.\n")); case OPTION_NO_DEMANGLE: demangle = FALSE; break; + case OPTION_INLINE_FILE_NAMES: + inline_file_names = TRUE; + break; default: usage (stderr, 1); } diff --git a/gprof/gprof.h b/gprof/gprof.h index 69527fc..c919ea4 100644 --- a/gprof/gprof.h +++ b/gprof/gprof.h @@ -126,6 +126,7 @@ extern bfd_boolean line_granularity; /* function or line granularity? */ extern bfd_boolean print_descriptions; /* output profile description */ extern bfd_boolean print_path; /* print path or just filename? */ extern bfd_boolean ignore_non_functions; /* Ignore non-function symbols. */ +extern bfd_boolean inline_file_names; /* print file names after symbols */ extern File_Format file_format; /* requested file format */ diff --git a/gprof/gprof.texi b/gprof/gprof.texi index 30f43f9..3f210b4 100644 --- a/gprof/gprof.texi +++ b/gprof/gprof.texi @@ -1,8 +1,6 @@ \input texinfo @c -*-texinfo-*- @setfilename gprof.info -@c Copyright 1988, 1992, 1993, 1998, 1999, 2000, 2001, 2002, 2003, -@c 2004, 2007, 2008, 2009 -@c Free Software Foundation, Inc. +@c Copyright 1988-2013 Free Software Foundation, Inc. @settitle GNU gprof @setchapternewpage odd @@ -23,8 +21,7 @@ This file documents the gprof profiler of the GNU system. @c man begin COPYRIGHT -Copyright @copyright{} 1988, 1992, 1997, 1998, 1999, 2000, 2001, 2003, -2007, 2008, 2009 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2013 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 @@ -57,8 +54,7 @@ execute programs. @sc{gnu} @code{gprof} was written by Jay Fenlason. Eric S. Raymond made some minor corrections and additions in 2003. @vskip 0pt plus 1filll -Copyright @copyright{} 1988, 1992, 1997, 1998, 1999, 2000, 2003, 2008, -2009 Free Software Foundation, Inc. +Copyright @copyright{} 1988-2013 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 @@ -124,12 +120,13 @@ gprof [ -[abcDhilLrsTvwxyz] ] [ -[ACeEfFJnNOpPqQZ][@var{name}] ] [ --debug[=@var{level}] ] [ --function-ordering ] [ --file-ordering @var{map_file} ] [ --directory-path=@var{dirs} ] [ --display-unused-functions ] [ --file-format=@var{name} ] - [ --file-info ] [ --help ] [ --line ] [ --min-count=@var{n} ] - [ --no-static ] [ --print-path ] [ --separate-files ] - [ --static-call-graph ] [ --sum ] [ --table-length=@var{len} ] - [ --traditional ] [ --version ] [ --width=@var{n} ] - [ --ignore-non-functions ] [ --demangle[=@var{STYLE}] ] - [ --no-demangle ] [--external-symbol-table=name] + [ --file-info ] [ --help ] [ --line ] [ --inline-file-names ] + [ --min-count=@var{n} ] [ --no-static ] [ --print-path ] + [ --separate-files ] [ --static-call-graph ] [ --sum ] + [ --table-length=@var{len} ] [ --traditional ] [ --version ] + [ --width=@var{n} ] [ --ignore-non-functions ] + [ --demangle[=@var{STYLE}] ] [ --no-demangle ] + [--external-symbol-table=name] [ @var{image-file} ] [ @var{profile-file} @dots{} ] @c man end @end smallexample @@ -712,6 +709,11 @@ the running time of @code{gprof}, and magnifies statistical inaccuracies. @xref{Sampling Error, ,Statistical Sampling Error}. +@item --inline-file-names +This option causes @code{gprof} to print the source file after each +symbol in both the flat profile and the call graph. The full path to the +file is printed if used with the @samp{-L} option. + @item -m @var{num} @itemx --min-count=@var{num} This option affects execution count output only. diff --git a/gprof/utils.c b/gprof/utils.c index f349841..4fc2db6 100644 --- a/gprof/utils.c +++ b/gprof/utils.c @@ -58,7 +58,7 @@ print_name_only (Sym *self) } printf ("%s", name); size = strlen (name); - if (line_granularity && self->file) + if ((line_granularity || inline_file_names) && self->file) { filename = self->file->name; if (!print_path) @@ -73,8 +73,15 @@ print_name_only (Sym *self) filename = self->file->name; } } - sprintf (buf, " (%s:%d @ %lx)", filename, self->line_num, - (unsigned long) self->addr); + if (line_granularity) + { + sprintf (buf, " (%s:%d @ %lx)", filename, self->line_num, + (unsigned long) self->addr); + } + else + { + sprintf (buf, " (%s:%d)", filename, self->line_num); + } printf ("%s", buf); size += strlen (buf); } -- cgit v1.1