]> oss.titaniummirror.com Git - msp430-binutils.git/blobdiff - gprof/cg_print.c
Imported binutils-2.20
[msp430-binutils.git] / gprof / cg_print.c
index 104d0499ec67f8899321ecda4953f294b478fea5..0b2e989c2a92f97051cf65b54329d8d85a060ae9 100644 (file)
@@ -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.
 
@@ -19,8 +20,8 @@
    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
    02110-1301, USA.  */
 \f
-#include "libiberty.h"
 #include "gprof.h"
+#include "libiberty.h"
 #include "search_list.h"
 #include "source.h"
 #include "symtab.h"
@@ -166,7 +167,7 @@ sort_members (Sym *cyc)
   todo = cyc->cg.cyc.next;
   cyc->cg.cyc.next = 0;
 
-  for (doing = todo; doing && doing->cg.cyc.next; doing = todo)
+  for (doing = todo; doing != NULL; doing = todo)
     {
       todo = doing->cg.cyc.next;
 
@@ -804,13 +805,8 @@ cg_print_function_ordering ()
     {
       if (symtab.base[index].ncalls == 0)
        {
-         /* Filter out gprof generated names.  */
-         if (strcmp (symtab.base[index].name, "<locore>")
-             && strcmp (symtab.base[index].name, "<hicore>"))
-           {
-             unused_syms[unused++] = &symtab.base[index];
-             symtab.base[index].has_been_placed = 1;
-           }
+         unused_syms[unused++] = &symtab.base[index];
+         symtab.base[index].has_been_placed = 1;
        }
       else
        {
@@ -1217,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;
@@ -1249,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++)