More mult-arch conversions: IEEE_FLOAT, SKIP_PROLOGUE,
[deliverable/binutils-gdb.git] / gprof / basic_blocks.c
index 74201748bc325ca16d16318b78571e773f475602..43dd762b01c667d2ed09efa067e1b15a55b5fbd3 100644 (file)
@@ -6,7 +6,7 @@
 #include <stdio.h>
 #include <unistd.h>
 #include "basic_blocks.h"
-#include "core.h"
+#include "corefile.h"
 #include "gmon_io.h"
 #include "gmon_out.h"
 #include "gprof.h"
@@ -19,7 +19,7 @@
  * Default option values:
  */
 bool bb_annotate_all_lines = FALSE;
-int bb_min_calls = 1;
+unsigned long bb_min_calls = 1;
 int bb_table_length = 10;
 
 /*
@@ -90,10 +90,10 @@ DEFUN (cmp_ncalls, (lp, rp), const void *lp AND const void *rp)
       return -1;
     }
 
-  if (right->ncalls != left->ncalls)
-    {
-      return right->ncalls - left->ncalls;
-    }
+  if (left->ncalls < right->ncalls)
+    return 1;
+  else if (left->ncalls > right->ncalls)
+    return -1;
 
   return left->line_num - right->line_num;
 }
@@ -126,12 +126,12 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
 {
   int nblocks, b;
   bfd_vma addr;
-  long ncalls;
+  unsigned long ncalls;
   Sym *sym;
 
   if (fread (&nblocks, sizeof (nblocks), 1, ifp) != 1)
     {
-      fprintf (stderr, "%s: %s: unexpected end of file\n", whoami, filename);
+      fprintf (stderr, _("%s: %s: unexpected end of file\n"), whoami, filename);
       done (1);
     }
 
@@ -189,8 +189,9 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
              int i;
 
              DBG (BBDEBUG,
-                  printf ("[bb_read_rec] 0x%lx->0x%lx (%s:%d) cnt=%ld\n",
-                          addr, sym->addr, sym->name, sym->line_num, ncalls));
+                  printf ("[bb_read_rec] 0x%lx->0x%lx (%s:%d) cnt=%lu\n",
+                          (unsigned long) addr, (unsigned long) sym->addr,
+                          sym->name, sym->line_num, ncalls));
 
              for (i = 0; i < NBBS; i++)
                {
@@ -211,7 +212,7 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
            {
              user_warned = TRUE;
              fprintf (stderr,
-                      "%s: warning: ignoring basic-block exec counts (use -l or --line)\n",
+                      _("%s: warning: ignoring basic-block exec counts (use -l or --line)\n"),
                       whoami);
            }
        }
@@ -231,7 +232,7 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename)
   const unsigned char tag = GMON_TAG_BB_COUNT;
   int nblocks = 0;
   bfd_vma addr;
-  long ncalls;
+  unsigned long ncalls;
   Sym *sym;
   int i;
 
@@ -319,17 +320,20 @@ DEFUN_VOID (print_exec_counts)
     {
       if (sym->ncalls > 0 || ! ignore_zeros)
        {
-         printf ("%s:%d: (%s:0x%lx) %d executions\n",
-                 sym->file ? sym->file->name : "<unknown>", sym->line_num,
-                 sym->name, sym->addr, sym->ncalls);
+         /* FIXME: This only works if bfd_vma is unsigned long.  */
+         printf (_("%s:%d: (%s:0x%lx) %lu executions\n"),
+                 sym->file ? sym->file->name : _("<unknown>"), sym->line_num,
+                 sym->name, (unsigned long) sym->addr, sym->ncalls);
        }
       for (j = 0; j < NBBS && sym->bb_addr[j]; j ++)
        {
          if (sym->bb_calls[j] > 0 || ! ignore_zeros)
            {
-             printf ("%s:%d: (%s:0x%lx) %d executions\n",
-                     sym->file ? sym->file->name : "<unknown>", sym->line_num,
-                     sym->name, sym->bb_addr[j], sym->bb_calls[j]);
+             /* FIXME: This only works if bfd_vma is unsigned long.  */
+             printf (_("%s:%d: (%s:0x%lx) %lu executions\n"),
+                     sym->file ? sym->file->name : _("<unknown>"), sym->line_num,
+                     sym->name, (unsigned long) sym->bb_addr[j],
+                     sym->bb_calls[j]);
            }
        }
     }
@@ -355,8 +359,8 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
   Source_File *sf = arg;
   Sym *b;
   int i;
-  static int last_count;
-  int last_print=-1;
+  static unsigned long last_count;
+  unsigned long last_print = (unsigned long) -1;
 
   b = NULL;
   if (line_num <= sf->num_lines)
@@ -373,7 +377,8 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
     {
       char tmpbuf[NBBS * 30];
       char *p;
-      int ncalls;
+      unsigned long ncalls;
+      int ncalls_set;
       int len;
 
       ++num_executable_lines;
@@ -381,7 +386,8 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
       p = tmpbuf;
       *p = '\0';
 
-      ncalls = -1;
+      ncalls = 0;
+      ncalls_set = 0;
 
       /* If this is a function entry point, label the line no matter what.
        * Otherwise, we're in the middle of a function, so check to see
@@ -393,19 +399,21 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
 
       if (b->is_func)
        {
-         sprintf (p, "%d", b->ncalls);
+         sprintf (p, "%lu", b->ncalls);
          p += strlen (p);
          last_count = b->ncalls;
          last_print = last_count;
          ncalls = b->ncalls;
+         ncalls_set = 1;
        }
       else if (bb_annotate_all_lines
               && b->bb_addr[0] && b->bb_addr[0] > b->addr)
        {
-         sprintf (p, "%d", last_count);
+         sprintf (p, "%lu", last_count);
          p += strlen (p);
          last_print = last_count;
          ncalls = last_count;
+         ncalls_set = 1;
        }
 
       /* Loop through all of this line's basic-blocks.  For each one,
@@ -416,8 +424,11 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
       for (i = 0; i < NBBS && b->bb_addr[i]; i++)
        {
          last_count = b->bb_calls[i];
-         if (ncalls < 0)
-           ncalls = 0;
+         if (! ncalls_set)
+           {
+             ncalls = 0;
+             ncalls_set = 1;
+           }
          ncalls += last_count;
 
          if (bb_annotate_all_lines && last_count == last_print)
@@ -427,7 +438,7 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
 
          if (p > tmpbuf)
            *p++ = ',';
-         sprintf (p, "%d", last_count);
+         sprintf (p, "%lu", last_count);
          p += strlen (p);
 
          last_print = last_count;
@@ -442,12 +453,13 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
 
       if (bb_annotate_all_lines && p == tmpbuf)
        {
-         sprintf (p, "%d", last_count);
+         sprintf (p, "%lu", last_count);
          p += strlen (p);
          ncalls = last_count;
+         ncalls_set = 1;
        }
 
-      if (ncalls < 0)
+      if (! ncalls_set)
        {
          int c;
 
@@ -581,7 +593,7 @@ DEFUN_VOID (print_annotated_source)
 
       if (bb_table_length > 0)
        {
-         fprintf (ofp, "\n\nTop %d Lines:\n\n     Line      Count\n\n",
+         fprintf (ofp, _("\n\nTop %d Lines:\n\n     Line      Count\n\n"),
                   bb_table_length);
 
          /* abuse line arrays---it's not needed anymore: */
@@ -594,29 +606,30 @@ DEFUN_VOID (print_annotated_source)
          for (i = 0; i < table_len; ++i)
            {
              sym = sf->line[i];
-             if (!sym || sym->ncalls <= 0)
+             if (!sym || sym->ncalls == 0)
                {
                  break;
                }
-             fprintf (ofp, "%9d %10d\n", sym->line_num, sym->ncalls);
+             fprintf (ofp, "%9d %10lu\n", sym->line_num, sym->ncalls);
            }
        }
 
       free (sf->line);
       sf->line = 0;
 
-      fprintf (ofp, "\nExecution Summary:\n\n");
-      fprintf (ofp, "%9ld   Executable lines in this file\n",
+      fprintf (ofp, _("\nExecution Summary:\n\n"));
+      fprintf (ofp, _("%9ld   Executable lines in this file\n"),
               num_executable_lines);
-      fprintf (ofp, "%9ld   Lines executed\n", num_lines_executed);
-      fprintf (ofp, "%9.2f   Percent of the file executed\n",
+      fprintf (ofp, _("%9ld   Lines executed\n"), num_lines_executed);
+      fprintf (ofp, _("%9.2f   Percent of the file executed\n"),
               num_executable_lines
               ? 100.0 * num_lines_executed / (double) num_executable_lines
               : 100.0);
-      fprintf (ofp, "\n%9d   Total number of line executions\n", sf->ncalls);
-      fprintf (ofp, "%9.2f   Average executions per line\n",
+      fprintf (ofp, _("\n%9lu   Total number of line executions\n"),
+              sf->ncalls);
+      fprintf (ofp, _("%9.2f   Average executions per line\n"),
               num_executable_lines
-              ? sf->ncalls / (double) num_executable_lines
+              ? (double) sf->ncalls / (double) num_executable_lines
               : 0.0);
       if (ofp != stdout)
        {
This page took 0.026131 seconds and 4 git commands to generate.