diff options
author | Nick Clifton <nickc@redhat.com> | 2009-06-16 11:49:12 +0000 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2009-06-16 11:49:12 +0000 |
commit | e7e981d68486380483cff5ed13408b8ab00f56d8 (patch) | |
tree | d3570972a90e2c05ef4f75e47889804dc9e5f123 /gprof/cg_print.c | |
parent | 81694485e2c696e1aa8dfb3f92110d437c833b22 (diff) | |
download | gdb-e7e981d68486380483cff5ed13408b8ab00f56d8.zip gdb-e7e981d68486380483cff5ed13408b8ab00f56d8.tar.gz gdb-e7e981d68486380483cff5ed13408b8ab00f56d8.tar.bz2 |
* corefile.c (cmp_symbol_map): New function.
(read_function_mappins): Use qsort to sort the symbols.
(search_mapped_symbol): New function.
(core_create_function_syms): Use bsearch to find symbols.
* corefile.h (struct function_map): Add new bit-field: is_first.
* cg_print.c (cmp_symbol_map): New function.
(cg_print_file_ordering): Sort the symbol map.
Diffstat (limited to 'gprof/cg_print.c')
-rw-r--r-- | gprof/cg_print.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gprof/cg_print.c b/gprof/cg_print.c index 58ff608..0b2e989 100644 --- a/gprof/cg_print.c +++ b/gprof/cg_print.c @@ -1,6 +1,7 @@ /* cg_print.c - Print routines for displaying call graphs. - Copyright 2000, 2001, 2002, 2004, 2007 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2004, 2007, 2009 + Free Software Foundation, Inc. This file is part of GNU Binutils. @@ -1212,12 +1213,22 @@ order_and_dump_functions_by_arcs (the_arcs, arc_count, all, } } +/* Compare two function_map structs based on file name. + We want to sort in ascending order. */ + +static int +cmp_symbol_map (const void * l, const void * r) +{ + return strcmp (((struct function_map *) l)->file_name, + ((struct function_map *) r)->file_name); +} + /* Print a suggested .o ordering for files on a link line based on profiling information. This uses the function placement code for the bulk of its work. */ void -cg_print_file_ordering () +cg_print_file_ordering (void) { unsigned long scratch_arc_count, index; Arc **scratch_arcs; @@ -1244,6 +1255,8 @@ cg_print_file_ordering () printf ("%s\n", symtab.base[index].name); } + qsort (symbol_map, symbol_map_count, sizeof (struct function_map), cmp_symbol_map); + /* Now output any .o's that didn't have any text symbols. */ last = NULL; for (index = 0; index < symbol_map_count; index++) |