#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"
* 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;
/*
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;
}
{
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);
}
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++)
{
{
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);
}
}
const unsigned char tag = GMON_TAG_BB_COUNT;
int nblocks = 0;
bfd_vma addr;
- long ncalls;
+ unsigned long ncalls;
Sym *sym;
int i;
{
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]);
}
}
}
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)
{
char tmpbuf[NBBS * 30];
char *p;
- int ncalls;
+ unsigned long ncalls;
+ int ncalls_set;
int len;
++num_executable_lines;
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
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,
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)
if (p > tmpbuf)
*p++ = ',';
- sprintf (p, "%d", last_count);
+ sprintf (p, "%lu", last_count);
p += strlen (p);
last_print = last_count;
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;
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: */
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)
{