Avoid some overflow cases:

* basic_blocks.h (bb_min_calls): Change to unsigned long.
	* call_graph.h (cg_tally): Change count parameter to unsigned
	long.
	* cg_arcs.h (Arc): Change count field to unsigned long.
	(arc_add): Change count parameter to unsigned long.
	* source.h (Source_File): Change ncalls field to unsigned long.
	* symtab.h (Sym): Change fields ncalls, bb_calls, and
	cg.self_calls to unsigned long.
	* Many files: Update accordingly.
This commit is contained in:
Ian Lance Taylor
1998-08-12 19:06:24 +00:00
parent 15ec5eb33b
commit 8c73afb353
19 changed files with 110 additions and 86 deletions

View File

@ -1,3 +1,18 @@
Wed Aug 12 14:59:06 1998 Ian Lance Taylor <ian@cygnus.com>
Avoid some overflow cases:
* basic_blocks.h (bb_min_calls): Change to unsigned long.
* call_graph.h (cg_tally): Change count parameter to unsigned
long.
* cg_arcs.h (Arc): Change count field to unsigned long.
(arc_add): Change count parameter to unsigned long.
* source.h (Source_File): Change ncalls field to unsigned long.
* symtab.h (Sym): Change fields ncalls, bb_calls, and
cg.self_calls to unsigned long.
* Many files: Update accordingly.
* configure, Makefile.in, aclocal.m4: Rebuild with current tools.
Fri Jul 10 17:29:49 1998 Stan Cox <scox@equinox.cygnus.com> Fri Jul 10 17:29:49 1998 Stan Cox <scox@equinox.cygnus.com>
* configure.in (BSD44_FORMAT): Define for cygwin32, win32, mingw32 * configure.in (BSD44_FORMAT): Define for cygwin32, win32, mingw32

View File

@ -127,7 +127,7 @@ alpha_find_call (parent, p_lowpc, p_highpc)
printf (_("[find_call] 0x%lx: jsr%s <indirect_child>\n"), printf (_("[find_call] 0x%lx: jsr%s <indirect_child>\n"),
(bfd_vma) pc - delta, (bfd_vma) pc - delta,
pc->j.func == Jxx_FUNC_JSR ? "" : "_coroutine")); pc->j.func == Jxx_FUNC_JSR ? "" : "_coroutine"));
arc_add (parent, &indirect_child, 0); arc_add (parent, &indirect_child, (unsigned long) 0);
} }
break; break;
@ -151,7 +151,7 @@ alpha_find_call (parent, p_lowpc, p_highpc)
{ {
DBG (CALLDEBUG, printf ("\n")); DBG (CALLDEBUG, printf ("\n"));
/* a hit: */ /* a hit: */
arc_add (parent, child, 0); arc_add (parent, child, (unsigned long) 0);
continue; continue;
} }
} }

View File

@ -19,7 +19,7 @@
* Default option values: * Default option values:
*/ */
bool bb_annotate_all_lines = FALSE; bool bb_annotate_all_lines = FALSE;
int bb_min_calls = 1; unsigned long bb_min_calls = 1;
int bb_table_length = 10; int bb_table_length = 10;
/* /*
@ -90,10 +90,10 @@ DEFUN (cmp_ncalls, (lp, rp), const void *lp AND const void *rp)
return -1; return -1;
} }
if (right->ncalls != left->ncalls) if (left->ncalls < right->ncalls)
{ return 1;
return right->ncalls - left->ncalls; else if (left->ncalls > right->ncalls)
} return -1;
return left->line_num - right->line_num; return left->line_num - right->line_num;
} }
@ -126,7 +126,7 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
{ {
int nblocks, b; int nblocks, b;
bfd_vma addr; bfd_vma addr;
long ncalls; unsigned long ncalls;
Sym *sym; Sym *sym;
if (fread (&nblocks, sizeof (nblocks), 1, ifp) != 1) if (fread (&nblocks, sizeof (nblocks), 1, ifp) != 1)
@ -189,7 +189,7 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
int i; int i;
DBG (BBDEBUG, DBG (BBDEBUG,
printf ("[bb_read_rec] 0x%lx->0x%lx (%s:%d) cnt=%ld\n", printf ("[bb_read_rec] 0x%lx->0x%lx (%s:%d) cnt=%lu\n",
addr, sym->addr, sym->name, sym->line_num, ncalls)); addr, sym->addr, sym->name, sym->line_num, ncalls));
for (i = 0; i < NBBS; i++) for (i = 0; i < NBBS; i++)
@ -231,7 +231,7 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename)
const unsigned char tag = GMON_TAG_BB_COUNT; const unsigned char tag = GMON_TAG_BB_COUNT;
int nblocks = 0; int nblocks = 0;
bfd_vma addr; bfd_vma addr;
long ncalls; unsigned long ncalls;
Sym *sym; Sym *sym;
int i; int i;
@ -319,7 +319,7 @@ DEFUN_VOID (print_exec_counts)
{ {
if (sym->ncalls > 0 || ! ignore_zeros) if (sym->ncalls > 0 || ! ignore_zeros)
{ {
printf (_("%s:%d: (%s:0x%lx) %d executions\n"), printf (_("%s:%d: (%s:0x%lx) %lu executions\n"),
sym->file ? sym->file->name : _("<unknown>"), sym->line_num, sym->file ? sym->file->name : _("<unknown>"), sym->line_num,
sym->name, sym->addr, sym->ncalls); sym->name, sym->addr, sym->ncalls);
} }
@ -327,7 +327,7 @@ DEFUN_VOID (print_exec_counts)
{ {
if (sym->bb_calls[j] > 0 || ! ignore_zeros) if (sym->bb_calls[j] > 0 || ! ignore_zeros)
{ {
printf (_("%s:%d: (%s:0x%lx) %d executions\n"), printf (_("%s:%d: (%s:0x%lx) %lu executions\n"),
sym->file ? sym->file->name : _("<unknown>"), sym->line_num, sym->file ? sym->file->name : _("<unknown>"), sym->line_num,
sym->name, sym->bb_addr[j], sym->bb_calls[j]); sym->name, sym->bb_addr[j], sym->bb_calls[j]);
} }
@ -355,8 +355,8 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
Source_File *sf = arg; Source_File *sf = arg;
Sym *b; Sym *b;
int i; int i;
static int last_count; static unsigned long last_count;
int last_print=-1; unsigned long last_print = (unsigned long) -1;
b = NULL; b = NULL;
if (line_num <= sf->num_lines) if (line_num <= sf->num_lines)
@ -373,7 +373,8 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
{ {
char tmpbuf[NBBS * 30]; char tmpbuf[NBBS * 30];
char *p; char *p;
int ncalls; unsigned long ncalls;
int ncalls_set;
int len; int len;
++num_executable_lines; ++num_executable_lines;
@ -381,7 +382,8 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
p = tmpbuf; p = tmpbuf;
*p = '\0'; *p = '\0';
ncalls = -1; ncalls = 0;
ncalls_set = 0;
/* If this is a function entry point, label the line no matter what. /* 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 * Otherwise, we're in the middle of a function, so check to see
@ -393,19 +395,21 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
if (b->is_func) if (b->is_func)
{ {
sprintf (p, "%d", b->ncalls); sprintf (p, "%lu", b->ncalls);
p += strlen (p); p += strlen (p);
last_count = b->ncalls; last_count = b->ncalls;
last_print = last_count; last_print = last_count;
ncalls = b->ncalls; ncalls = b->ncalls;
ncalls_set = 1;
} }
else if (bb_annotate_all_lines else if (bb_annotate_all_lines
&& b->bb_addr[0] && b->bb_addr[0] > b->addr) && b->bb_addr[0] && b->bb_addr[0] > b->addr)
{ {
sprintf (p, "%d", last_count); sprintf (p, "%lu", last_count);
p += strlen (p); p += strlen (p);
last_print = last_count; last_print = last_count;
ncalls = last_count; ncalls = last_count;
ncalls_set = 1;
} }
/* Loop through all of this line's basic-blocks. For each one, /* Loop through all of this line's basic-blocks. For each one,
@ -416,8 +420,11 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
for (i = 0; i < NBBS && b->bb_addr[i]; i++) for (i = 0; i < NBBS && b->bb_addr[i]; i++)
{ {
last_count = b->bb_calls[i]; last_count = b->bb_calls[i];
if (ncalls < 0) if (! ncalls_set)
ncalls = 0; {
ncalls = 0;
ncalls_set = 1;
}
ncalls += last_count; ncalls += last_count;
if (bb_annotate_all_lines && last_count == last_print) if (bb_annotate_all_lines && last_count == last_print)
@ -427,7 +434,7 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
if (p > tmpbuf) if (p > tmpbuf)
*p++ = ','; *p++ = ',';
sprintf (p, "%d", last_count); sprintf (p, "%lu", last_count);
p += strlen (p); p += strlen (p);
last_print = last_count; last_print = last_count;
@ -442,12 +449,13 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
if (bb_annotate_all_lines && p == tmpbuf) if (bb_annotate_all_lines && p == tmpbuf)
{ {
sprintf (p, "%d", last_count); sprintf (p, "%lu", last_count);
p += strlen (p); p += strlen (p);
ncalls = last_count; ncalls = last_count;
ncalls_set = 1;
} }
if (ncalls < 0) if (! ncalls_set)
{ {
int c; int c;
@ -594,11 +602,11 @@ DEFUN_VOID (print_annotated_source)
for (i = 0; i < table_len; ++i) for (i = 0; i < table_len; ++i)
{ {
sym = sf->line[i]; sym = sf->line[i];
if (!sym || sym->ncalls <= 0) if (!sym || sym->ncalls == 0)
{ {
break; break;
} }
fprintf (ofp, "%9d %10d\n", sym->line_num, sym->ncalls); fprintf (ofp, "%9d %10lu\n", sym->line_num, sym->ncalls);
} }
} }
@ -613,10 +621,11 @@ DEFUN_VOID (print_annotated_source)
num_executable_lines num_executable_lines
? 100.0 * num_lines_executed / (double) num_executable_lines ? 100.0 * num_lines_executed / (double) num_executable_lines
: 100.0); : 100.0);
fprintf (ofp, _("\n%9d Total number of line executions\n"), sf->ncalls); fprintf (ofp, _("\n%9lu Total number of line executions\n"),
sf->ncalls);
fprintf (ofp, _("%9.2f Average executions per line\n"), fprintf (ofp, _("%9.2f Average executions per line\n"),
num_executable_lines num_executable_lines
? sf->ncalls / (double) num_executable_lines ? (double) sf->ncalls / (double) num_executable_lines
: 0.0); : 0.0);
if (ofp != stdout) if (ofp != stdout)
{ {

View File

@ -10,8 +10,8 @@
* Options: * Options:
*/ */
extern bool bb_annotate_all_lines; /* force annotation of all lines? */ extern bool bb_annotate_all_lines; /* force annotation of all lines? */
extern int bb_table_length; /* length of most-used bb table */ extern int bb_table_length; /* length of most-used bb table */
extern int bb_min_calls; /* minimum execution count */ extern unsigned long bb_min_calls; /* minimum execution count */
extern void bb_read_rec PARAMS ((FILE * ifp, const char *filename)); extern void bb_read_rec PARAMS ((FILE * ifp, const char *filename));
extern void bb_write_blocks PARAMS ((FILE * ofp, const char *filename)); extern void bb_write_blocks PARAMS ((FILE * ofp, const char *filename));

View File

@ -8,7 +8,7 @@
extern void extern void
DEFUN (cg_tally, (from_pc, self_pc, count), DEFUN (cg_tally, (from_pc, self_pc, count),
bfd_vma from_pc AND bfd_vma self_pc AND int count) bfd_vma from_pc AND bfd_vma self_pc AND unsigned long count)
{ {
Sym *parent; Sym *parent;
Sym *child; Sym *child;
@ -45,7 +45,7 @@ DEFUN (cg_tally, (from_pc, self_pc, count),
{ {
child->ncalls += count; child->ncalls += count;
DBG (TALLYDEBUG, DBG (TALLYDEBUG,
printf (_("[cg_tally] arc from %s to %s traversed %d times\n"), printf (_("[cg_tally] arc from %s to %s traversed %lu times\n"),
parent->name, child->name, count)); parent->name, child->name, count));
arc_add (parent, child, count); arc_add (parent, child, count);
} }
@ -63,7 +63,7 @@ DEFUN (cg_read_rec, (ifp, filename), FILE * ifp AND CONST char *filename)
{ {
bfd_vma from_pc, self_pc; bfd_vma from_pc, self_pc;
struct gmon_cg_arc_record arc; struct gmon_cg_arc_record arc;
int count; unsigned long count;
if (fread (&arc, sizeof (arc), 1, ifp) != 1) if (fread (&arc, sizeof (arc), 1, ifp) != 1)
{ {
@ -75,7 +75,7 @@ DEFUN (cg_read_rec, (ifp, filename), FILE * ifp AND CONST char *filename)
self_pc = get_vma (core_bfd, (bfd_byte *) arc.self_pc); self_pc = get_vma (core_bfd, (bfd_byte *) arc.self_pc);
count = bfd_get_32 (core_bfd, (bfd_byte *) arc.count); count = bfd_get_32 (core_bfd, (bfd_byte *) arc.count);
DBG (SAMPLEDEBUG, DBG (SAMPLEDEBUG,
printf ("[cg_read_rec] frompc 0x%lx selfpc 0x%lx count %d\n", printf ("[cg_read_rec] frompc 0x%lx selfpc 0x%lx count %lu\n",
from_pc, self_pc, count)); from_pc, self_pc, count));
/* add this arc: */ /* add this arc: */
cg_tally (from_pc, self_pc, count); cg_tally (from_pc, self_pc, count);
@ -109,7 +109,7 @@ DEFUN (cg_write_arcs, (ofp, filename), FILE * ofp AND const char *filename)
done (1); done (1);
} }
DBG (SAMPLEDEBUG, DBG (SAMPLEDEBUG,
printf ("[cg_write_arcs] frompc 0x%lx selfpc 0x%lx count %d\n", printf ("[cg_write_arcs] frompc 0x%lx selfpc 0x%lx count %lu\n",
arc->parent->addr, arc->child->addr, arc->count)); arc->parent->addr, arc->child->addr, arc->count));
} }
} }

View File

@ -5,7 +5,8 @@
#include "gprof.h" #include "gprof.h"
#include "symtab.h" #include "symtab.h"
extern void cg_tally PARAMS ((bfd_vma from_pc, bfd_vma self_pc, int count)); extern void cg_tally PARAMS ((bfd_vma from_pc, bfd_vma self_pc,
unsigned long count));
extern void cg_read_rec PARAMS ((FILE * ifp, const char *filename)); extern void cg_read_rec PARAMS ((FILE * ifp, const char *filename));
extern void cg_write_arcs PARAMS ((FILE * ofp, const char *filename)); extern void cg_write_arcs PARAMS ((FILE * ofp, const char *filename));

View File

@ -65,12 +65,12 @@ DEFUN (arc_lookup, (parent, child), Sym * parent AND Sym * child)
*/ */
void void
DEFUN (arc_add, (parent, child, count), DEFUN (arc_add, (parent, child, count),
Sym * parent AND Sym * child AND int count) Sym * parent AND Sym * child AND unsigned long count)
{ {
static unsigned int maxarcs = 0; static unsigned int maxarcs = 0;
Arc *arc, **newarcs; Arc *arc, **newarcs;
DBG (TALLYDEBUG, printf ("[arc_add] %d arcs from %s to %s\n", DBG (TALLYDEBUG, printf ("[arc_add] %lu arcs from %s to %s\n",
count, parent->name, child->name)); count, parent->name, child->name));
arc = arc_lookup (parent, child); arc = arc_lookup (parent, child);
if (arc) if (arc)
@ -78,7 +78,7 @@ DEFUN (arc_add, (parent, child, count),
/* /*
* A hit: just increment the count. * A hit: just increment the count.
*/ */
DBG (TALLYDEBUG, printf ("[tally] hit %d += %d\n", DBG (TALLYDEBUG, printf ("[tally] hit %lu += %lu\n",
arc->count, count)); arc->count, count));
arc->count += count; arc->count += count;
return; return;
@ -211,7 +211,7 @@ DEFUN (propagate_time, (parent), Sym * parent)
DBG (PROPDEBUG, DBG (PROPDEBUG,
printf ("[prop_time] child \t"); printf ("[prop_time] child \t");
print_name (child); print_name (child);
printf (" with %f %f %d/%d\n", child->hist.time, printf (" with %f %f %lu/%lu\n", child->hist.time,
child->cg.child_time, arc->count, child->ncalls); child->cg.child_time, arc->count, child->ncalls);
printf ("[prop_time] parent\t"); printf ("[prop_time] parent\t");
print_name (parent); print_name (parent);
@ -361,7 +361,7 @@ DEFUN (inherit_flags, (child), Sym * child)
* is static (and all others are, too)) no time propagates * is static (and all others are, too)) no time propagates
* along this arc. * along this arc.
*/ */
if (child->ncalls) if (child->ncalls != 0)
{ {
child->cg.prop.fract += parent->cg.prop.fract child->cg.prop.fract += parent->cg.prop.fract
* (((double) arc->count) / ((double) child->ncalls)); * (((double) arc->count) / ((double) child->ncalls));
@ -391,7 +391,7 @@ DEFUN (inherit_flags, (child), Sym * child)
* arc is static (and all others are, too)) no time * arc is static (and all others are, too)) no time
* propagates along this arc. * propagates along this arc.
*/ */
if (head->ncalls) if (head->ncalls != 0)
{ {
head->cg.prop.fract += parent->cg.prop.fract head->cg.prop.fract += parent->cg.prop.fract
* (((double) arc->count) / ((double) head->ncalls)); * (((double) arc->count) / ((double) head->ncalls));

View File

@ -15,7 +15,7 @@ typedef struct arc
{ {
Sym *parent; /* source vertice of arc */ Sym *parent; /* source vertice of arc */
Sym *child; /* dest vertice of arc */ Sym *child; /* dest vertice of arc */
int count; /* # of calls from parent to child */ unsigned long count; /* # of calls from parent to child */
double time; /* time inherited along arc */ double time; /* time inherited along arc */
double child_time; /* child-time inherited along arc */ double child_time; /* child-time inherited along arc */
struct arc *next_parent; /* next parent of CHILD */ struct arc *next_parent; /* next parent of CHILD */
@ -27,7 +27,7 @@ Arc;
extern unsigned int num_cycles; /* number of cycles discovered */ extern unsigned int num_cycles; /* number of cycles discovered */
extern Sym *cycle_header; /* cycle headers */ extern Sym *cycle_header; /* cycle headers */
extern void arc_add PARAMS ((Sym * parent, Sym * child, int count)); extern void arc_add PARAMS ((Sym * parent, Sym * child, unsigned long count));
extern Arc *arc_lookup PARAMS ((Sym * parent, Sym * child)); extern Arc *arc_lookup PARAMS ((Sym * parent, Sym * child));
extern Sym **cg_assemble PARAMS ((void)); extern Sym **cg_assemble PARAMS ((void));
extern Arc **arcs; extern Arc **arcs;

View File

@ -86,13 +86,13 @@ DEFUN (print_cycle, (cyc), Sym * cyc)
sprintf (buf, "[%d]", cyc->cg.index); sprintf (buf, "[%d]", cyc->cg.index);
printf (bsd_style_output printf (bsd_style_output
? "%-6.6s %5.1f %7.2f %11.2f %7d" ? "%-6.6s %5.1f %7.2f %11.2f %7lu"
: "%-6.6s %5.1f %7.2f %7.2f %7d", buf, : "%-6.6s %5.1f %7.2f %7.2f %7lu", buf,
100 * (cyc->cg.prop.self + cyc->cg.prop.child) / print_time, 100 * (cyc->cg.prop.self + cyc->cg.prop.child) / print_time,
cyc->cg.prop.self / hz, cyc->cg.prop.child / hz, cyc->ncalls); cyc->cg.prop.self / hz, cyc->cg.prop.child / hz, cyc->ncalls);
if (cyc->cg.self_calls != 0) if (cyc->cg.self_calls != 0)
{ {
printf ("+%-7d", cyc->cg.self_calls); printf ("+%-7lu", cyc->cg.self_calls);
} }
else else
{ {
@ -111,8 +111,8 @@ DEFUN (cmp_member, (left, right), Sym * left AND Sym * right)
{ {
double left_time = left->cg.prop.self + left->cg.prop.child; double left_time = left->cg.prop.self + left->cg.prop.child;
double right_time = right->cg.prop.self + right->cg.prop.child; double right_time = right->cg.prop.self + right->cg.prop.child;
long left_calls = left->ncalls + left->cg.self_calls; unsigned long left_calls = left->ncalls + left->cg.self_calls;
long right_calls = right->ncalls + right->cg.self_calls; unsigned long right_calls = right->ncalls + right->cg.self_calls;
if (left_time > right_time) if (left_time > right_time)
{ {
@ -176,13 +176,13 @@ DEFUN (print_members, (cyc), Sym * cyc)
for (member = cyc->cg.cyc.next; member; member = member->cg.cyc.next) for (member = cyc->cg.cyc.next; member; member = member->cg.cyc.next)
{ {
printf (bsd_style_output printf (bsd_style_output
? "%6.6s %5.5s %7.2f %11.2f %7d" ? "%6.6s %5.5s %7.2f %11.2f %7lu"
: "%6.6s %5.5s %7.2f %7.2f %7d", : "%6.6s %5.5s %7.2f %7.2f %7lu",
"", "", member->cg.prop.self / hz, member->cg.prop.child / hz, "", "", member->cg.prop.self / hz, member->cg.prop.child / hz,
member->ncalls); member->ncalls);
if (member->cg.self_calls != 0) if (member->cg.self_calls != 0)
{ {
printf ("+%-7d", member->cg.self_calls); printf ("+%-7lu", member->cg.self_calls);
} }
else else
{ {
@ -218,13 +218,13 @@ DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right)
print_name (left_parent); print_name (left_parent);
printf (" calls "); printf (" calls ");
print_name (left_child); print_name (left_child);
printf (" %f + %f %d/%d\n", left->time, left->child_time, printf (" %f + %f %lu/%lu\n", left->time, left->child_time,
left->count, left_child->ncalls); left->count, left_child->ncalls);
printf ("[cmp_arc] "); printf ("[cmp_arc] ");
print_name (right_parent); print_name (right_parent);
printf (" calls "); printf (" calls ");
print_name (right_child); print_name (right_child);
printf (" %f + %f %d/%d\n", right->time, right->child_time, printf (" %f + %f %lu/%lu\n", right->time, right->child_time,
right->count, right_child->ncalls); right->count, right_child->ncalls);
printf ("\n"); printf ("\n");
); );
@ -364,8 +364,8 @@ DEFUN (print_parents, (child), Sym * child)
{ {
/* selfcall or call among siblings: */ /* selfcall or call among siblings: */
printf (bsd_style_output printf (bsd_style_output
? "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " ? "%6.6s %5.5s %7.7s %11.11s %7lu %7.7s "
: "%6.6s %5.5s %7.7s %7.7s %7d %7.7s ", : "%6.6s %5.5s %7.7s %7.7s %7lu %7.7s ",
"", "", "", "", "", "", "", "",
arc->count, ""); arc->count, "");
print_name (parent); print_name (parent);
@ -375,8 +375,8 @@ DEFUN (print_parents, (child), Sym * child)
{ {
/* regular parent of child: */ /* regular parent of child: */
printf (bsd_style_output printf (bsd_style_output
? "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " ? "%6.6s %5.5s %7.2f %11.2f %7lu/%-7lu "
: "%6.6s %5.5s %7.2f %7.2f %7d/%-7d ", : "%6.6s %5.5s %7.2f %7.2f %7lu/%-7lu ",
"", "", "", "",
arc->time / hz, arc->child_time / hz, arc->time / hz, arc->child_time / hz,
arc->count, cycle_head->ncalls); arc->count, cycle_head->ncalls);
@ -437,8 +437,8 @@ DEFUN (print_children, (parent), Sym * parent)
{ {
/* self call or call to sibling: */ /* self call or call to sibling: */
printf (bsd_style_output printf (bsd_style_output
? "%6.6s %5.5s %7.7s %11.11s %7d %7.7s " ? "%6.6s %5.5s %7.7s %11.11s %7lu %7.7s "
: "%6.6s %5.5s %7.7s %7.7s %7d %7.7s ", : "%6.6s %5.5s %7.7s %7.7s %7lu %7.7s ",
"", "", "", "", arc->count, ""); "", "", "", "", arc->count, "");
print_name (child); print_name (child);
printf ("\n"); printf ("\n");
@ -447,8 +447,8 @@ DEFUN (print_children, (parent), Sym * parent)
{ {
/* regular child of parent: */ /* regular child of parent: */
printf (bsd_style_output printf (bsd_style_output
? "%6.6s %5.5s %7.2f %11.2f %7d/%-7d " ? "%6.6s %5.5s %7.2f %11.2f %7lu/%-7lu "
: "%6.6s %5.5s %7.2f %7.2f %7d/%-7d ", : "%6.6s %5.5s %7.2f %7.2f %7lu/%-7lu ",
"", "", "", "",
arc->time / hz, arc->child_time / hz, arc->time / hz, arc->child_time / hz,
arc->count, child->cg.cyc.head->ncalls); arc->count, child->cg.cyc.head->ncalls);
@ -472,10 +472,10 @@ DEFUN (print_line, (np), Sym * np)
np->cg.prop.self / hz, np->cg.prop.child / hz); np->cg.prop.self / hz, np->cg.prop.child / hz);
if ((np->ncalls + np->cg.self_calls) != 0) if ((np->ncalls + np->cg.self_calls) != 0)
{ {
printf (" %7d", np->ncalls); printf (" %7lu", np->ncalls);
if (np->cg.self_calls != 0) if (np->cg.self_calls != 0)
{ {
printf ("+%-7d ", np->cg.self_calls); printf ("+%-7lu ", np->cg.self_calls);
} }
else else
{ {

View File

@ -149,7 +149,8 @@ DEFUN (gmon_out_read, (filename), const char *filename)
bfd_vma high_pc; bfd_vma high_pc;
int ncnt; int ncnt;
}; };
int i, samp_bytes, count; int i, samp_bytes;
unsigned long count;
bfd_vma from_pc, self_pc; bfd_vma from_pc, self_pc;
struct raw_arc raw_arc; struct raw_arc raw_arc;
struct raw_phdr raw; struct raw_phdr raw;
@ -260,7 +261,7 @@ DEFUN (gmon_out_read, (filename), const char *filename)
self_pc = get_vma (core_bfd, (bfd_byte *) raw_arc.self_pc); self_pc = get_vma (core_bfd, (bfd_byte *) raw_arc.self_pc);
count = bfd_get_32 (core_bfd, (bfd_byte *) raw_arc.count); count = bfd_get_32 (core_bfd, (bfd_byte *) raw_arc.count);
DBG (SAMPLEDEBUG, DBG (SAMPLEDEBUG,
printf ("[gmon_out_read] frompc 0x%lx selfpc 0x%lx count %d\n", printf ("[gmon_out_read] frompc 0x%lx selfpc 0x%lx count %lu\n",
from_pc, self_pc, count)); from_pc, self_pc, count));
/* add this arc: */ /* add this arc: */
cg_tally (from_pc, self_pc, count); cg_tally (from_pc, self_pc, count);
@ -399,7 +400,7 @@ DEFUN (gmon_out_write, (filename), const char *filename)
done (1); done (1);
} }
DBG (SAMPLEDEBUG, DBG (SAMPLEDEBUG,
printf ("[dumpsum] frompc 0x%lx selfpc 0x%lx count %d\n", printf ("[dumpsum] frompc 0x%lx selfpc 0x%lx count %lu\n",
arc->parent->addr, arc->child->addr, arc->count)); arc->parent->addr, arc->child->addr, arc->count));
} }
} }

View File

@ -279,7 +279,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
print_path = TRUE; print_path = TRUE;
break; break;
case 'm': case 'm':
bb_min_calls = atoi (optarg); bb_min_calls = (unsigned long) strtoul (optarg, (char **) NULL, 10);
break; break;
case 'n': case 'n':
sym_id_add (optarg, INCL_TIME); sym_id_add (optarg, INCL_TIME);

View File

@ -427,9 +427,9 @@ DEFUN (print_line, (sym, scale), Sym * sym AND double scale)
total_time > 0.0 ? 100 * sym->hist.time / total_time : 0.0, total_time > 0.0 ? 100 * sym->hist.time / total_time : 0.0,
accum_time / hz, sym->hist.time / hz); accum_time / hz, sym->hist.time / hz);
} }
if (sym->ncalls) if (sym->ncalls != 0)
{ {
printf (" %8d %8.2f %8.2f ", printf (" %8lu %8.2f %8.2f ",
sym->ncalls, scale * sym->hist.time / hz / sym->ncalls, sym->ncalls, scale * sym->hist.time / hz / sym->ncalls,
scale * (sym->hist.time + sym->cg.child_time) / hz / sym->ncalls); scale * (sym->hist.time + sym->cg.child_time) / hz / sym->ncalls);
} }
@ -460,7 +460,6 @@ DEFUN (cmp_time, (lp, rp), const PTR lp AND const PTR rp)
const Sym *left = *(const Sym **) lp; const Sym *left = *(const Sym **) lp;
const Sym *right = *(const Sym **) rp; const Sym *right = *(const Sym **) rp;
double time_diff; double time_diff;
long call_diff;
time_diff = right->hist.time - left->hist.time; time_diff = right->hist.time - left->hist.time;
if (time_diff > 0.0) if (time_diff > 0.0)
@ -472,12 +471,11 @@ DEFUN (cmp_time, (lp, rp), const PTR lp AND const PTR rp)
return -1; return -1;
} }
call_diff = right->ncalls - left->ncalls; if (right->ncalls > left->ncalls)
if (call_diff > 0)
{ {
return 1; return 1;
} }
if (call_diff < 0) if (right->ncalls < left->ncalls)
{ {
return -1; return -1;
} }
@ -547,7 +545,7 @@ DEFUN_VOID (hist_print)
for (index = 0; index < symtab.len; ++index) for (index = 0; index < symtab.len; ++index)
{ {
sym = time_sorted_syms[index]; sym = time_sorted_syms[index];
if (sym->ncalls) if (sym->ncalls != 0)
{ {
time = (sym->hist.time + sym->cg.child_time) / sym->ncalls; time = (sym->hist.time + sym->cg.child_time) / sym->ncalls;
if (time > top_time) if (time > top_time)
@ -557,7 +555,7 @@ DEFUN_VOID (hist_print)
} }
} }
} }
if (top_dog && top_dog->ncalls && top_time > 0.0) if (top_dog && top_dog->ncalls != 0 && top_time > 0.0)
{ {
top_time /= hz; top_time /= hz;
while (SItab[log_scale].scale * top_time < 1000.0 while (SItab[log_scale].scale * top_time < 1000.0

View File

@ -86,7 +86,7 @@ i386_find_call (parent, p_lowpc, p_highpc)
*/ */
DBG (CALLDEBUG, DBG (CALLDEBUG,
printf ("\tdestpc 0x%lx (%s)\n", destpc, child->name)); printf ("\tdestpc 0x%lx (%s)\n", destpc, child->name));
arc_add (parent, child, (long) 0); arc_add (parent, child, (unsigned long) 0);
instructp += 4; /* call is a 5 byte instruction */ instructp += 4; /* call is a 5 byte instruction */
continue; continue;
} }

View File

@ -9,7 +9,7 @@ typedef struct source_file
{ {
struct source_file *next; struct source_file *next;
const char *name; /* name of source file */ const char *name; /* name of source file */
int ncalls; /* # of "calls" to this file */ unsigned long ncalls; /* # of "calls" to this file */
int num_lines; /* # of lines in file */ int num_lines; /* # of lines in file */
int nalloced; /* number of lines allocated */ int nalloced; /* number of lines allocated */
void **line; /* usage-dependent per-line data */ void **line; /* usage-dependent per-line data */

View File

@ -75,7 +75,7 @@ sparc_find_call (parent, p_lowpc, p_highpc)
if (child->addr == dest_pc) if (child->addr == dest_pc)
{ {
/* a hit: */ /* a hit: */
arc_add (parent, child, 0); arc_add (parent, child, (unsigned long) 0);
continue; continue;
} }
} }

View File

@ -329,7 +329,7 @@ DEFUN_VOID (sym_id_parse)
right->name ? right->name : "*", right->addr, right->name ? right->name : "*", right->addr,
right->end_addr, right->end_addr,
table_name[id->which_table])); table_name[id->which_table]));
arc_add (left, right, 0); arc_add (left, right, (unsigned long) 0);
} }
} }
} }

View File

@ -41,11 +41,11 @@ typedef struct sym
is_bb_head:1, /* is this the head of a basic-blk? */ is_bb_head:1, /* is this the head of a basic-blk? */
mapped:1, /* this symbol was mapped to another name */ mapped:1, /* this symbol was mapped to another name */
has_been_placed:1; /* have we placed this symbol? */ has_been_placed:1; /* have we placed this symbol? */
int ncalls; /* how many times executed */ unsigned long ncalls; /* how many times executed */
int nuses; /* how many times this symbol appears in int nuses; /* how many times this symbol appears in
a particular context */ a particular context */
bfd_vma bb_addr[NBBS]; /* address of basic-block start */ bfd_vma bb_addr[NBBS]; /* address of basic-block start */
int bb_calls[NBBS]; /* how many times basic-block was called */ unsigned long bb_calls[NBBS]; /* how many times basic-block was called */
struct sym *next; /* for building chains of syms */ struct sym *next; /* for building chains of syms */
struct sym *prev; /* for building chains of syms */ struct sym *prev; /* for building chains of syms */
@ -62,7 +62,7 @@ typedef struct sym
/* call-graph specific info: */ /* call-graph specific info: */
struct struct
{ {
int self_calls; /* how many calls to self */ unsigned long self_calls; /* how many calls to self */
double child_time; /* cumulative ticks in children */ double child_time; /* cumulative ticks in children */
int index; /* index in the graph list */ int index; /* index in the graph list */
int top_order; /* graph call chain top-sort order */ int top_order; /* graph call chain top-sort order */

View File

@ -293,7 +293,7 @@ tahoe_find_call (parent, p_lowpc, p_highpc)
* [are there others that we miss?, * [are there others that we miss?,
* e.g. arrays of pointers to functions???] * e.g. arrays of pointers to functions???]
*/ */
arc_add (parent, &indirectchild, (long) 0); arc_add (parent, &indirectchild, (unsigned long) 0);
length += tahoe_operandlength (instructp + length); length += tahoe_operandlength (instructp + length);
continue; continue;
case byterel: case byterel:
@ -319,7 +319,7 @@ tahoe_find_call (parent, p_lowpc, p_highpc)
/* /*
* a hit * a hit
*/ */
arc_add (parent, child, (long) 0); arc_add (parent, child, (unsigned long) 0);
length += tahoe_operandlength (instructp + length); length += tahoe_operandlength (instructp + length);
continue; continue;
} }

View File

@ -296,7 +296,7 @@ vax_find_call (parent, p_lowpc, p_highpc)
* [are there others that we miss?, * [are there others that we miss?,
* e.g. arrays of pointers to functions???] * e.g. arrays of pointers to functions???]
*/ */
arc_add (parent, &indirectchild, (long) 0); arc_add (parent, &indirectchild, (unsigned long) 0);
length += vax_operandlength ( length += vax_operandlength (
(struct modebyte *) (instructp + length)); (struct modebyte *) (instructp + length));
continue; continue;
@ -323,7 +323,7 @@ vax_find_call (parent, p_lowpc, p_highpc)
/* /*
* a hit * a hit
*/ */
arc_add (parent, child, (long) 0); arc_add (parent, child, (unsigned long) 0);
length += vax_operandlength ((struct modebyte *) length += vax_operandlength ((struct modebyte *)
(instructp + length)); (instructp + length));
continue; continue;