From 64c50fc5db62e96b429cd2f2e166e878569f4a15 Mon Sep 17 00:00:00 2001 From: Jeff Law Date: Sun, 31 Dec 1995 06:36:30 +0000 Subject: * gprof.c (long_options): Add "--function-ordering" and "--file-ordering" options. (usage): Add new options to usage message. (main): Handle new options. * gprof.h (STYLE_FUNCTION_ORDER): Define. (STYLE_FILE_ORDER): Define. (function_mapping_file): Declare. * cg_arcs.c (arcs, numarcs): New globals. (arc_add): Put new arcs into the arc array so the function/file ordering code can examine them. * cg_arcs.h (struct arc): New field "has_been_placed". (arcs, numarcs): Declare new globals. * core.c (symbol_map, symbol_map_count): New globals. (read_function_mappings): New function to read in a function to object map file. (core_init): Call read_function_mappings if a function mapping file exists. (core_create_function_syms): Handle function to object file mappings. * symtab.h (struct sym): New fields "mapped", "has_been_placed", "nuses", "prev". * cg_print.c (cmp_arc_count): New function for sorting arcs. (cmp_fun_nuses): Likewise for functions. (cg_print_function_ordering): New function to print a suggested function ordering. (cg_print_file_ordering): Likewise for ordering .o files. (order_and_dump_functions_by_arcs): Helper function for function and object file ordering code. Gprof changes for mentor vm work. --- gprof/gprof.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'gprof/gprof.c') diff --git a/gprof/gprof.c b/gprof/gprof.c index 0f9dd85..742f0a6 100644 --- a/gprof/gprof.c +++ b/gprof/gprof.c @@ -33,6 +33,7 @@ #define VERSION "2.6" const char *whoami; +const char *function_mapping_file; const char *a_out_name = A_OUTNAME; long hz = HZ_WRONG; @@ -89,6 +90,8 @@ static struct option long_options[] = {"no-graph", optional_argument, 0, 'Q'}, {"exec-counts", optional_argument, 0, 'C'}, {"no-exec-counts", optional_argument, 0, 'Z'}, + {"function-ordering", no_argument, 0, 'r'}, + {"file-ordering", required_argument, 0, 'R'}, {"file-info", no_argument, 0, 'i'}, {"sum", no_argument, 0, 's'}, @@ -136,6 +139,7 @@ Usage: %s [-[abcDhilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][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\ [--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\ @@ -322,6 +326,15 @@ DEFUN (main, (argc, argv), int argc AND char **argv) output_style |= STYLE_CALL_GRAPH; user_specified |= STYLE_CALL_GRAPH; break; + case 'r': + output_style |= STYLE_FUNCTION_ORDER; + user_specified |= STYLE_FUNCTION_ORDER; + break; + case 'R': + output_style |= STYLE_FILE_ORDER; + user_specified |= STYLE_FILE_ORDER; + function_mapping_file = optarg; + break; case 'Q': if (optarg) { @@ -391,6 +404,16 @@ DEFUN (main, (argc, argv), int argc AND char **argv) } } + /* Don't allow both ordering options, they modify the arc data in-place. */ + if ((user_specified & STYLE_FUNCTION_ORDER) + && (user_specified & STYLE_FILE_ORDER)) + { + fprintf (stderr,"\ +%s: Only one of --function-ordering and --file-ordering may be specified.\n", + whoami); + done (1); + } + /* append value of GPROF_PATH to source search list if set: */ str = (char *) getenv ("GPROF_PATH"); if (str) @@ -581,6 +604,14 @@ DEFUN (main, (argc, argv), int argc AND char **argv) { print_annotated_source (); } + if (output_style & STYLE_FUNCTION_ORDER) + { + cg_print_function_ordering (); + } + if (output_style & STYLE_FILE_ORDER) + { + cg_print_file_ordering (); + } return 0; } -- cgit v1.1