summaryrefslogtreecommitdiff
path: root/gprof/cg_print.c
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-06-16 11:49:12 +0000
committerNick Clifton <nickc@redhat.com>2009-06-16 11:49:12 +0000
commit69419ececf8617464a3a68d98f65b219c379f113 (patch)
tree4a66fe6b83157bd03c47f09924d5af13985b9fb0 /gprof/cg_print.c
parentff24b200da0ea9f58d9b7676925725191ab7832a (diff)
downloadbinutils-redhat-69419ececf8617464a3a68d98f65b219c379f113.tar.gz
* 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.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/gprof/cg_print.c b/gprof/cg_print.c
index 58ff60841f..0b2e989c2a 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++)