* __bb_exit_func.c: New file, from David Mosberger-Tang.

Thu Feb  9 16:56:07 1995  David Mosberger-Tang  <davidm@piston.cs.arizona.edu>

* All *.c: More cleanup towards GNU format.

* gmon_out.h (struct gmon_hist_hdr, struct gmon_cg_arc_record): replaced sizeof
(bfd_vma) by size (char*) because Ken tells me that bfd_vma is only guaranteed
to be at least as big as a pointer.

(GMON_Record_tag): added explicit enumeration values to ensure compatibility
across compilers.

* gmon_io.c (get_vma, put_vma): replaced sizeof(bfd_vma) by sizeof(char*).
This commit is contained in:
Ken Raeburn 1995-03-14 02:58:16 +00:00
parent 477b242500
commit 03c35bcb6e
25 changed files with 647 additions and 577 deletions

View File

@ -25,6 +25,7 @@ Do-first:
Things-to-keep: Things-to-keep:
.gdbinit .gdbinit
__bb_exit_func.c
ChangeLog ChangeLog
Makefile.in Makefile.in
NOTES NOTES

View File

@ -1,3 +1,21 @@
Mon Mar 13 21:44:24 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
* __bb_exit_func.c: New file, from David Mosberger-Tang.
Thu Feb 9 16:56:07 1995 David Mosberger-Tang <davidm@piston.cs.arizona.edu>
* All *.c: More cleanup towards GNU format.
* gmon_out.h (struct gmon_hist_hdr, struct gmon_cg_arc_record):
replaced sizeof (bfd_vma) by size (char*) because Ken tells me
that bfd_vma is only guaranteed to be at least as big as a pointer.
(GMON_Record_tag): added explicit enumeration values to ensure
compatibility across compilers.
* gmon_io.c (get_vma, put_vma): replaced sizeof(bfd_vma) by
sizeof(char*).
Tue Feb 7 17:24:12 1995 Ken Raeburn <raeburn@cujo.cygnus.com> Tue Feb 7 17:24:12 1995 Ken Raeburn <raeburn@cujo.cygnus.com>
* All *.c and *.h files: Ran "indent -gnu". Cleaned up a couple * All *.c and *.h files: Ran "indent -gnu". Cleaned up a couple

View File

@ -1,7 +1,10 @@
Sun Feb 5 16:27:32 1995 Thu Feb 9 16:48:04 1995
- documentation - documentation
- optimize bfd_find_nearest_line_num() (or replace by different interface) - optimize bfd_find_nearest_line_num() (or replace by different interface)
- gmon_io.c cannot deal with target architecture that have a pointer size
that is different from the host architectures pointer size---fix this
(gmon_out.h, and gmon_io.c)
- add support for prof file format so that prof files can be displayed - add support for prof file format so that prof files can be displayed
at the line-level (this is useful for the uprofile tool under DEC's at the line-level (this is useful for the uprofile tool under DEC's
OSF/1) OSF/1)

78
gprof/__bb_exit_func.c Normal file
View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 1994 David Mosberger-Tang.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or (at
* your option) any later version.
*
* __bb_exit_func() dumps all the basic-block statistics linked into
* the bb_head chain to .d files.
*/
#include <stdio.h>
#include <strings.h>
#include "bfd.h"
#include "gmon_out.h"
/* structure emitted by -a */
struct bb {
long zero_word;
const char *filename;
long *counts;
long ncounts;
struct bb *next;
const unsigned long *addresses;
};
struct bb *__bb_head = (struct bb *)0;
void
__bb_exit_func (void)
{
const int version = GMON_VERSION;
struct gmon_hdr ghdr;
struct bb *ptr;
FILE *fp;
/*
* GEN_GMON_CNT_FILE should be defined on systems with mcleanup()
* functions that do not write basic-block to gmon.out. In such
* cases profiling with "-pg -a" would result in a gmon.out file
* without basic-block info (because the file written here would
* be overwritten. Thus, a separate file is generated instead.
* The two files can easily be combined by specifying them
* on gprof's command line (and possibly generating a gmon.sum
* file with "gprof -s").
*/
#ifndef GEN_GMON_CNT_FILE
# define OUT_NAME "gmon.out"
#else
# define OUT_NAME "gmon.cnt"
#endif
fp = fopen(OUT_NAME, "wb");
if (!fp) {
perror(OUT_NAME);
return;
} /* if */
bcopy(GMON_MAGIC, &ghdr.cookie[0], 4);
bcopy(&version, &ghdr.version, sizeof(version));
fwrite(&ghdr, sizeof(ghdr), 1, fp);
for (ptr = __bb_head; ptr != 0; ptr = ptr->next) {
u_int ncounts = ptr->ncounts;
u_char tag;
u_int i;
tag = GMON_TAG_BB_COUNT;
fwrite(&tag, sizeof(tag), 1, fp);
fwrite(&ncounts, sizeof(ncounts), 1, fp);
for (i = 0; i < ncounts; ++i) {
fwrite(&ptr->addresses[i], sizeof(ptr->addresses[0]), 1, fp);
fwrite(&ptr->counts[i], sizeof(ptr->counts[0]), 1, fp);
} /* for */
} /* for */
fclose (fp);
} /* __bb_exit_func */
/*** end of __bb_exit_func.c ***/

View File

@ -89,20 +89,20 @@ find_call (parent, p_lowpc, p_highpc)
indirect_child.name = "<indirect child>"; indirect_child.name = "<indirect child>";
indirect_child.cg.prop.fract = 1.0; indirect_child.cg.prop.fract = 1.0;
indirect_child.cg.cyc.head = &indirect_child; indirect_child.cg.cyc.head = &indirect_child;
} /* if */ }
if (!core_text_space) if (!core_text_space)
{ {
return; return;
} /* if */ }
if (p_lowpc < s_lowpc) if (p_lowpc < s_lowpc)
{ {
p_lowpc = s_lowpc; p_lowpc = s_lowpc;
} /* if */ }
if (p_highpc > s_highpc) if (p_highpc > s_highpc)
{ {
p_highpc = s_highpc; p_highpc = s_highpc;
} /* if */ }
DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n", DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n",
parent->name, p_lowpc, p_highpc)); parent->name, p_lowpc, p_highpc));
for (pc = (Instruction *) (p_lowpc + delta); for (pc = (Instruction *) (p_lowpc + delta);
@ -128,7 +128,7 @@ find_call (parent, p_lowpc, p_highpc)
(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, 0);
} /* if */ }
break; break;
case OP_BSR: case OP_BSR:
@ -153,8 +153,8 @@ find_call (parent, p_lowpc, p_highpc)
/* a hit: */ /* a hit: */
arc_add (parent, child, 0); arc_add (parent, child, 0);
continue; continue;
} /* if */ }
} /* if */ }
/* /*
* Something funny going on. * Something funny going on.
*/ */
@ -163,7 +163,6 @@ find_call (parent, p_lowpc, p_highpc)
default: default:
break; break;
} /* switch */ }
} /* for */ }
} /* find_call */ }
/*** end of alpha.c ***/

View File

@ -47,13 +47,13 @@ DEFUN (cmp_bb, (lp, rp), const void *lp AND const void *rp)
if (r) if (r)
{ {
return r; return r;
} /* if */ }
if (left->line_num != right->line_num) if (left->line_num != right->line_num)
{ {
return left->line_num - right->line_num; return left->line_num - right->line_num;
} /* if */ }
} /* if */ }
if (left->addr < right->addr) if (left->addr < right->addr)
{ {
@ -66,8 +66,8 @@ DEFUN (cmp_bb, (lp, rp), const void *lp AND const void *rp)
else else
{ {
return 0; return 0;
} /* if */ }
} /* cmp_bb */ }
/* /*
@ -87,15 +87,15 @@ DEFUN (cmp_ncalls, (lp, rp), const void *lp AND const void *rp)
else if (!right) else if (!right)
{ {
return -1; return -1;
} /* if */ }
if (right->ncalls != left->ncalls) if (right->ncalls != left->ncalls)
{ {
return right->ncalls - left->ncalls; return right->ncalls - left->ncalls;
} /* if */ }
return left->line_num - right->line_num; return left->line_num - right->line_num;
} /* cmp_ncalls */ }
/* /*
@ -111,9 +111,9 @@ DEFUN (fskip_string, (fp), FILE * fp)
if (ch == '\0') if (ch == '\0')
{ {
break; break;
} /* if */ }
} /* if */ }
} /* fskip_string */ }
/* /*
@ -132,13 +132,13 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
{ {
fprintf (stderr, "%s: %s: unexpected end of file\n", whoami, filename); fprintf (stderr, "%s: %s: unexpected end of file\n", whoami, filename);
done (1); done (1);
} /* if */ }
nblocks = bfd_get_32 (core_bfd, (bfd_byte *) & nblocks); nblocks = bfd_get_32 (core_bfd, (bfd_byte *) & nblocks);
if (gmon_file_version == 0) if (gmon_file_version == 0)
{ {
fskip_string (ifp); fskip_string (ifp);
} /* if */ }
for (b = 0; b < nblocks; ++b) for (b = 0; b < nblocks; ++b)
{ {
@ -157,7 +157,7 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
} }
else else
{ {
@ -166,8 +166,8 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
} /* if */ }
/* /*
* Basic-block execution counts are meaningful only if we're * Basic-block execution counts are meaningful only if we're
@ -197,11 +197,11 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
fprintf (stderr, 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); whoami);
} /* if */ }
} /* if */ }
} /* for */ }
return; return;
} /* bb_read_rec */ }
/* /*
@ -225,8 +225,8 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename)
if (sym->ncalls > 0) if (sym->ncalls > 0)
{ {
++nblocks; ++nblocks;
} /* if */ }
} /* for */ }
/* write header: */ /* write header: */
bfd_put_32 (core_bfd, nblocks, (bfd_byte *) & nblocks); bfd_put_32 (core_bfd, nblocks, (bfd_byte *) & nblocks);
@ -235,7 +235,7 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
/* write counts: */ /* write counts: */
for (sym = symtab.base; sym < symtab.limit; ++sym) for (sym = symtab.base; sym < symtab.limit; ++sym)
@ -243,7 +243,7 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename)
if (sym->ncalls == 0) if (sym->ncalls == 0)
{ {
continue; continue;
} /* if */ }
put_vma (core_bfd, sym->addr, (bfd_byte *) & addr); put_vma (core_bfd, sym->addr, (bfd_byte *) & addr);
bfd_put_32 (core_bfd, sym->ncalls, (bfd_byte *) & ncalls); bfd_put_32 (core_bfd, sym->ncalls, (bfd_byte *) & ncalls);
@ -253,9 +253,9 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
} /* for */ }
} /* bb_write_blocks */ }
/* /*
@ -277,7 +277,7 @@ DEFUN_VOID (print_exec_counts)
else else
{ {
printf ("\f\n"); printf ("\f\n");
} /* if */ }
/* sort basic-blocks according to function name and line number: */ /* sort basic-blocks according to function name and line number: */
@ -297,8 +297,8 @@ DEFUN_VOID (print_exec_counts)
&& !sym_lookup (&syms[EXCL_EXEC], sym->addr)))) && !sym_lookup (&syms[EXCL_EXEC], sym->addr))))
{ {
sorted_bbs[len++] = sym; sorted_bbs[len++] = sym;
} /* if */ }
} /* for */ }
qsort (sorted_bbs, len, sizeof (sorted_bbs[0]), cmp_bb); qsort (sorted_bbs, len, sizeof (sorted_bbs[0]), cmp_bb);
/* output basic-blocks: */ /* output basic-blocks: */
@ -309,9 +309,9 @@ DEFUN_VOID (print_exec_counts)
printf ("%s:%d: (%s:0x%lx) %d executions\n", printf ("%s:%d: (%s:0x%lx) %d 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);
} /* for */ }
free (sorted_bbs); free (sorted_bbs);
} /* print_exec_counts */ }
/* /*
@ -330,13 +330,13 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
if (line_num == 1) if (line_num == 1)
{ {
last_count = -1; last_count = -1;
} /* if */ }
b = 0; b = 0;
if (line_num <= sf->num_lines) if (line_num <= sf->num_lines)
{ {
b = sf->line[line_num - 1]; b = sf->line[line_num - 1];
} /* if */ }
if (!b) if (!b)
{ {
cnt = -1; cnt = -1;
@ -345,15 +345,15 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
{ {
++num_executable_lines; ++num_executable_lines;
cnt = b->ncalls; cnt = b->ncalls;
} /* if */ }
if (cnt > 0) if (cnt > 0)
{ {
++num_lines_executed; ++num_lines_executed;
} /* if */ }
if (cnt < 0 && bb_annotate_all_lines) if (cnt < 0 && bb_annotate_all_lines)
{ {
cnt = last_count; cnt = last_count;
} /* if */ }
if (cnt < 0) if (cnt < 0)
{ {
@ -366,9 +366,9 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg),
else else
{ {
sprintf (buf, "%12ld -> ", cnt); sprintf (buf, "%12ld -> ", cnt);
} /* if */ }
last_count = cnt; last_count = cnt;
} /* annotate_with_count */ }
/* /*
@ -402,8 +402,8 @@ DEFUN_VOID (print_annotated_source)
&& !sym_lookup (&syms[EXCL_ANNO], sym->addr)))) && !sym_lookup (&syms[EXCL_ANNO], sym->addr))))
{ {
sym->file->num_lines = sym->line_num; sym->file->num_lines = sym->line_num;
} /* if */ }
} /* for */ }
/* allocate line descriptors: */ /* allocate line descriptors: */
@ -413,8 +413,8 @@ DEFUN_VOID (print_annotated_source)
{ {
sf->line = (void *) xmalloc (sf->num_lines * sizeof (sf->line[0])); sf->line = (void *) xmalloc (sf->num_lines * sizeof (sf->line[0]));
memset (sf->line, 0, sf->num_lines * sizeof (sf->line[0])); memset (sf->line, 0, sf->num_lines * sizeof (sf->line[0]));
} /* if */ }
} /* for */ }
/* count executions per line: */ /* count executions per line: */
@ -445,9 +445,9 @@ DEFUN_VOID (print_annotated_source)
new_line->addr = 0; new_line->addr = 0;
new_line->ncalls += sym->ncalls; new_line->ncalls += sym->ncalls;
sym->file->line[sym->line_num - 1] = new_line; sym->file->line[sym->line_num - 1] = new_line;
} /* if */ }
} /* if */ }
} /* for */ }
/* plod over source files, annotating them: */ /* plod over source files, annotating them: */
@ -456,14 +456,14 @@ DEFUN_VOID (print_annotated_source)
if (!sf->num_lines || (ignore_zeros && sf->ncalls == 0)) if (!sf->num_lines || (ignore_zeros && sf->ncalls == 0))
{ {
continue; continue;
} /* if */ }
num_executable_lines = num_lines_executed = 0; num_executable_lines = num_lines_executed = 0;
ofp = annotate_source (sf, 16, annotate_with_count, sf); ofp = annotate_source (sf, 16, annotate_with_count, sf);
if (!ofp) if (!ofp)
{ {
continue; continue;
} /* if */ }
if (bb_table_length > 0) if (bb_table_length > 0)
{ {
@ -476,17 +476,17 @@ DEFUN_VOID (print_annotated_source)
if (table_len > sf->num_lines) if (table_len > sf->num_lines)
{ {
table_len = sf->num_lines; table_len = sf->num_lines;
} /* if */ }
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;
} /* if */ }
fprintf (ofp, "%9d %10d\n", sym->line_num, sym->ncalls); fprintf (ofp, "%9d %10d\n", sym->line_num, sym->ncalls);
} /* for */ }
} /* if */ }
free (sf->line); free (sf->line);
sf->line = 0; sf->line = 0;
@ -507,8 +507,6 @@ DEFUN_VOID (print_annotated_source)
if (ofp != stdout) if (ofp != stdout)
{ {
fclose (ofp); fclose (ofp);
} /* if */ }
} /* for */ }
} /* print_annotated_source */ }
/*** end of basic_block.c ***/

View File

@ -29,8 +29,8 @@ DEFUN (cg_tally, (from_pc, self_pc, count),
printf ("[cg_tally] arc from %s to %s traversed %d times\n", printf ("[cg_tally] arc from %s to %s traversed %d times\n",
parent->name, child->name, count)); parent->name, child->name, count));
arc_add (parent, child, count); arc_add (parent, child, count);
} /* if */ }
} /* cg_tally */ }
/* /*
@ -51,7 +51,7 @@ DEFUN (cg_read_rec, (ifp, filename), FILE * ifp AND CONST char *filename)
fprintf (stderr, "%s: %s: unexpected end of file\n", fprintf (stderr, "%s: %s: unexpected end of file\n",
whoami, filename); whoami, filename);
done (1); done (1);
} /* if */ }
from_pc = get_vma (core_bfd, (bfd_byte *) arc.from_pc); from_pc = get_vma (core_bfd, (bfd_byte *) arc.from_pc);
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);
@ -60,7 +60,7 @@ DEFUN (cg_read_rec, (ifp, filename), FILE * ifp AND CONST char *filename)
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);
} /* cg_read_rec */ }
/* /*
@ -88,12 +88,10 @@ DEFUN (cg_write_arcs, (ofp, filename), FILE * ofp AND const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
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 %d\n",
arc->parent->addr, arc->child->addr, arc->count)); arc->parent->addr, arc->child->addr, arc->count));
} /* for */ }
} /* for */ }
} /* cg_write_arcs */ }
/*** end of call_graph.c ***/

View File

@ -41,7 +41,7 @@ DEFUN (arc_lookup, (parent, child), Sym * parent AND Sym * child)
{ {
printf ("[arc_lookup] parent == 0 || child == 0\n"); printf ("[arc_lookup] parent == 0 || child == 0\n");
return 0; return 0;
} /* if */ }
DBG (LOOKUPDEBUG, printf ("[arc_lookup] parent %s child %s\n", DBG (LOOKUPDEBUG, printf ("[arc_lookup] parent %s child %s\n",
parent->name, child->name)); parent->name, child->name));
for (arc = parent->cg.children; arc; arc = arc->next_child) for (arc = parent->cg.children; arc; arc = arc->next_child)
@ -52,10 +52,10 @@ DEFUN (arc_lookup, (parent, child), Sym * parent AND Sym * child)
&& child->end_addr <= arc->child->end_addr) && child->end_addr <= arc->child->end_addr)
{ {
return arc; return arc;
} /* if */ }
} /* for */ }
return 0; return 0;
} /* arc_lookup */ }
/* /*
@ -79,7 +79,7 @@ DEFUN (arc_add, (parent, child, count),
arc->count, count)); arc->count, count));
arc->count += count; arc->count += count;
return; return;
} /* if */ }
arc = (Arc *) xmalloc (sizeof (*arc)); arc = (Arc *) xmalloc (sizeof (*arc));
arc->parent = parent; arc->parent = parent;
arc->child = child; arc->child = child;
@ -92,7 +92,7 @@ DEFUN (arc_add, (parent, child, count),
/* prepend this parent to the parents of this child: */ /* prepend this parent to the parents of this child: */
arc->next_parent = child->cg.parents; arc->next_parent = child->cg.parents;
child->cg.parents = arc; child->cg.parents = arc;
} /* arc_add */ }
static int static int
@ -102,7 +102,7 @@ DEFUN (cmp_topo, (lp, rp), const PTR lp AND const PTR rp)
const Sym *right = *(const Sym **) rp; const Sym *right = *(const Sym **) rp;
return left->cg.top_order - right->cg.top_order; return left->cg.top_order - right->cg.top_order;
} /* cmp_topo */ }
static void static void
@ -115,7 +115,7 @@ DEFUN (propagate_time, (parent), Sym * parent)
if (parent->cg.prop.fract == 0.0) if (parent->cg.prop.fract == 0.0)
{ {
return; return;
} /* if */ }
/* gather time from children of this parent: */ /* gather time from children of this parent: */
@ -125,17 +125,17 @@ DEFUN (propagate_time, (parent), Sym * parent)
if (arc->count == 0 || child == parent || child->cg.prop.fract == 0) if (arc->count == 0 || child == parent || child->cg.prop.fract == 0)
{ {
continue; continue;
} /* if */ }
if (child->cg.cyc.head != child) if (child->cg.cyc.head != child)
{ {
if (parent->cg.cyc.num == child->cg.cyc.num) if (parent->cg.cyc.num == child->cg.cyc.num)
{ {
continue; continue;
} /* if */ }
if (parent->cg.top_order <= child->cg.top_order) if (parent->cg.top_order <= child->cg.top_order)
{ {
fprintf (stderr, "[propagate] toporder botches\n"); fprintf (stderr, "[propagate] toporder botches\n");
} /* if */ }
child = child->cg.cyc.head; child = child->cg.cyc.head;
} }
else else
@ -144,12 +144,12 @@ DEFUN (propagate_time, (parent), Sym * parent)
{ {
fprintf (stderr, "[propagate] toporder botches\n"); fprintf (stderr, "[propagate] toporder botches\n");
continue; continue;
} /* if */ }
} /* if */ }
if (child->ncalls == 0) if (child->ncalls == 0)
{ {
continue; continue;
} /* if */ }
/* distribute time for this arc: */ /* distribute time for this arc: */
arc->time = child->hist.time * (((double) arc->count) arc->time = child->hist.time * (((double) arc->count)
@ -172,7 +172,7 @@ DEFUN (propagate_time, (parent), Sym * parent)
{ {
parent->cg.cyc.head->cg.child_time += share; parent->cg.cyc.head->cg.child_time += share;
parent->cg.cyc.head->cg.prop.child += prop_share; parent->cg.cyc.head->cg.prop.child += prop_share;
} /* if */ }
DBG (PROPDEBUG, DBG (PROPDEBUG,
printf ("[prop_time] child \t"); printf ("[prop_time] child \t");
print_name (child); print_name (child);
@ -181,8 +181,8 @@ DEFUN (propagate_time, (parent), Sym * parent)
printf ("[prop_time] parent\t"); printf ("[prop_time] parent\t");
print_name (parent); print_name (parent);
printf ("\n[prop_time] share %f\n", share)); printf ("\n[prop_time] share %f\n", share));
} /* for */ }
} /* propagate_time */ }
/* /*
@ -205,12 +205,12 @@ DEFUN_VOID (cycle_time)
* that were excluded with -E. * that were excluded with -E.
*/ */
continue; continue;
} /* if */ }
cyc->hist.time += member->hist.time; cyc->hist.time += member->hist.time;
} /* for */ }
cyc->cg.prop.self = cyc->cg.prop.fract * cyc->hist.time; cyc->cg.prop.self = cyc->cg.prop.fract * cyc->hist.time;
} /* for */ }
} /* cycle_time */ }
static void static void
@ -229,8 +229,8 @@ DEFUN_VOID (cycle_link)
if (sym->cg.cyc.head == sym && sym->cg.cyc.next) if (sym->cg.cyc.head == sym && sym->cg.cyc.next)
{ {
++num_cycles; ++num_cycles;
} /* if */ }
} /* for */ }
/* /*
* cycle_header is indexed by cycle number: i.e. it is origin 1, * cycle_header is indexed by cycle number: i.e. it is origin 1,
@ -249,7 +249,7 @@ DEFUN_VOID (cycle_link)
if (!(sym->cg.cyc.head == sym && sym->cg.cyc.next != 0)) if (!(sym->cg.cyc.head == sym && sym->cg.cyc.next != 0))
{ {
continue; continue;
} /* if */ }
++num; ++num;
++cyc; ++cyc;
sym_init (cyc); sym_init (cyc);
@ -267,7 +267,7 @@ DEFUN_VOID (cycle_link)
{ {
member->cg.cyc.num = num; member->cg.cyc.num = num;
member->cg.cyc.head = cyc; member->cg.cyc.head = cyc;
} /* for */ }
/* /*
* Count calls from outside the cycle and those among cycle * Count calls from outside the cycle and those among cycle
@ -280,7 +280,7 @@ DEFUN_VOID (cycle_link)
if (arc->parent == member) if (arc->parent == member)
{ {
continue; continue;
} /* if */ }
if (arc->parent->cg.cyc.num == num) if (arc->parent->cg.cyc.num == num)
{ {
cyc->cg.self_calls += arc->count; cyc->cg.self_calls += arc->count;
@ -288,11 +288,11 @@ DEFUN_VOID (cycle_link)
else else
{ {
cyc->ncalls += arc->count; cyc->ncalls += arc->count;
} /* if */ }
} /* for */ }
} /* for */ }
} /* for */ }
} /* cycle_link */ }
/* /*
@ -319,7 +319,7 @@ DEFUN (inherit_flags, (child), Sym * child)
if (child == parent) if (child == parent)
{ {
continue; continue;
} /* if */ }
child->cg.print_flag |= parent->cg.print_flag; child->cg.print_flag |= parent->cg.print_flag;
/* /*
* If the child was never actually called (e.g., this arc * If the child was never actually called (e.g., this arc
@ -330,8 +330,8 @@ DEFUN (inherit_flags, (child), Sym * child)
{ {
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));
} /* if */ }
} /* for */ }
} }
else else
{ {
@ -348,7 +348,7 @@ DEFUN (inherit_flags, (child), Sym * child)
if (arc->parent->cg.cyc.head == head) if (arc->parent->cg.cyc.head == head)
{ {
continue; continue;
} /* if */ }
parent = arc->parent; parent = arc->parent;
head->cg.print_flag |= parent->cg.print_flag; head->cg.print_flag |= parent->cg.print_flag;
/* /*
@ -360,16 +360,16 @@ DEFUN (inherit_flags, (child), Sym * child)
{ {
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));
} /* if */ }
} /* for */ }
} /* for */ }
for (member = head; member; member = member->cg.cyc.next) for (member = head; member; member = member->cg.cyc.next)
{ {
member->cg.print_flag = head->cg.print_flag; member->cg.print_flag = head->cg.print_flag;
member->cg.prop.fract = head->cg.prop.fract; member->cg.prop.fract = head->cg.prop.fract;
} /* for */ }
} /* if */ }
} /* inherit_flags */ }
/* /*
@ -399,7 +399,7 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols)
{ {
old_head = child->cg.cyc.head; old_head = child->cg.cyc.head;
inherit_flags (child); inherit_flags (child);
} /* if */ }
DBG (PROPDEBUG, DBG (PROPDEBUG,
printf ("[prop_flags] "); printf ("[prop_flags] ");
print_name (child); print_name (child);
@ -417,7 +417,7 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols)
&& !sym_lookup (&syms[EXCL_GRAPH], child->addr))) && !sym_lookup (&syms[EXCL_GRAPH], child->addr)))
{ {
child->cg.print_flag = TRUE; child->cg.print_flag = TRUE;
} /* if */ }
} }
else else
{ {
@ -430,8 +430,8 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols)
&& sym_lookup (&syms[EXCL_GRAPH], child->addr)) && sym_lookup (&syms[EXCL_GRAPH], child->addr))
{ {
child->cg.print_flag = FALSE; child->cg.print_flag = FALSE;
} /* if */ }
} /* if */ }
if (child->cg.prop.fract == 0.0) if (child->cg.prop.fract == 0.0)
{ {
/* /*
@ -444,7 +444,7 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols)
&& !sym_lookup (&syms[EXCL_TIME], child->addr))) && !sym_lookup (&syms[EXCL_TIME], child->addr)))
{ {
child->cg.prop.fract = 1.0; child->cg.prop.fract = 1.0;
} /* if */ }
} }
else else
{ {
@ -458,8 +458,8 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols)
&& sym_lookup (&syms[EXCL_TIME], child->addr)) && sym_lookup (&syms[EXCL_TIME], child->addr))
{ {
child->cg.prop.fract = 0.0; child->cg.prop.fract = 0.0;
} /* if */ }
} /* if */ }
child->cg.prop.self = child->hist.time * child->cg.prop.fract; child->cg.prop.self = child->hist.time * child->cg.prop.fract;
print_time += child->cg.prop.self; print_time += child->cg.prop.self;
DBG (PROPDEBUG, DBG (PROPDEBUG,
@ -469,8 +469,8 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols)
child->cg.print_flag, child->cg.prop.fract); child->cg.print_flag, child->cg.prop.fract);
printf ("[prop_flags] time %f propself %f print_time %f\n", printf ("[prop_flags] time %f propself %f print_time %f\n",
child->hist.time, child->cg.prop.self, print_time)); child->hist.time, child->cg.prop.self, print_time));
} /* if */ }
} /* propagate_flags */ }
/* /*
@ -491,45 +491,45 @@ DEFUN (cmp_total, (lp, rp), const PTR lp AND const PTR rp)
if (diff < 0.0) if (diff < 0.0)
{ {
return 1; return 1;
} /* if */ }
if (diff > 0.0) if (diff > 0.0)
{ {
return -1; return -1;
} /* if */ }
if (!left->name && left->cg.cyc.num != 0) if (!left->name && left->cg.cyc.num != 0)
{ {
return -1; return -1;
} /* if */ }
if (!right->name && right->cg.cyc.num != 0) if (!right->name && right->cg.cyc.num != 0)
{ {
return 1; return 1;
} /* if */ }
if (!left->name) if (!left->name)
{ {
return -1; return -1;
} /* if */ }
if (!right->name) if (!right->name)
{ {
return 1; return 1;
} /* if */ }
if (left->name[0] != '_' && right->name[0] == '_') if (left->name[0] != '_' && right->name[0] == '_')
{ {
return -1; return -1;
} /* if */ }
if (left->name[0] == '_' && right->name[0] != '_') if (left->name[0] == '_' && right->name[0] != '_')
{ {
return 1; return 1;
} /* if */ }
if (left->ncalls > right->ncalls) if (left->ncalls > right->ncalls)
{ {
return -1; return -1;
} /* if */ }
if (left->ncalls < right->ncalls) if (left->ncalls < right->ncalls)
{ {
return 1; return 1;
} /* if */ }
return strcmp (left->name, right->name); return strcmp (left->name, right->name);
} /* cmp_total */ }
/* /*
@ -562,7 +562,7 @@ DEFUN_VOID (cg_assemble)
else else
{ {
parent->cg.self_calls = 0; parent->cg.self_calls = 0;
} /* if */ }
parent->cg.prop.fract = 0.0; parent->cg.prop.fract = 0.0;
parent->cg.prop.self = 0.0; parent->cg.prop.self = 0.0;
parent->cg.prop.child = 0.0; parent->cg.prop.child = 0.0;
@ -574,8 +574,8 @@ DEFUN_VOID (cg_assemble)
if (ignore_direct_calls) if (ignore_direct_calls)
{ {
find_call (parent, parent->addr, (parent + 1)->addr); find_call (parent, parent->addr, (parent + 1)->addr);
} /* if */ }
} /* for */ }
/* /*
* Topologically order things. If any node is unnumbered, number * Topologically order things. If any node is unnumbered, number
* it and any of its descendents. * it and any of its descendents.
@ -585,8 +585,8 @@ DEFUN_VOID (cg_assemble)
if (parent->cg.top_order == DFN_NAN) if (parent->cg.top_order == DFN_NAN)
{ {
cg_dfn (parent); cg_dfn (parent);
} /* if */ }
} /* for */ }
/* link together nodes on the same cycle: */ /* link together nodes on the same cycle: */
cycle_link (); cycle_link ();
@ -596,7 +596,7 @@ DEFUN_VOID (cg_assemble)
for (index = 0; index < symtab.len; ++index) for (index = 0; index < symtab.len; ++index)
{ {
top_sorted_syms[index] = &symtab.base[index]; top_sorted_syms[index] = &symtab.base[index];
} /* for */ }
qsort (top_sorted_syms, symtab.len, sizeof (Sym *), cmp_topo); qsort (top_sorted_syms, symtab.len, sizeof (Sym *), cmp_topo);
DBG (DFNDEBUG, DBG (DFNDEBUG,
printf ("[cg_assemble] topological sort listing\n"); printf ("[cg_assemble] topological sort listing\n");
@ -606,7 +606,7 @@ DEFUN_VOID (cg_assemble)
printf ("%d:", top_sorted_syms[index]->cg.top_order); printf ("%d:", top_sorted_syms[index]->cg.top_order);
print_name (top_sorted_syms[index]); print_name (top_sorted_syms[index]);
printf ("\n"); printf ("\n");
} /* for */ }
); );
/* /*
* Starting from the topological top, propagate print flags to * Starting from the topological top, propagate print flags to
@ -624,7 +624,7 @@ DEFUN_VOID (cg_assemble)
for (index = 0; index < symtab.len; ++index) for (index = 0; index < symtab.len; ++index)
{ {
propagate_time (top_sorted_syms[index]); propagate_time (top_sorted_syms[index]);
} /* for */ }
free (top_sorted_syms); free (top_sorted_syms);
@ -636,18 +636,16 @@ DEFUN_VOID (cg_assemble)
for (index = 0; index < symtab.len; index++) for (index = 0; index < symtab.len; index++)
{ {
time_sorted_syms[index] = &symtab.base[index]; time_sorted_syms[index] = &symtab.base[index];
} /* if */ }
for (index = 1; index <= num_cycles; index++) for (index = 1; index <= num_cycles; index++)
{ {
time_sorted_syms[symtab.len + index - 1] = &cycle_header[index]; time_sorted_syms[symtab.len + index - 1] = &cycle_header[index];
} /* for */ }
qsort (time_sorted_syms, symtab.len + num_cycles, sizeof (Sym *), qsort (time_sorted_syms, symtab.len + num_cycles, sizeof (Sym *),
cmp_total); cmp_total);
for (index = 0; index < symtab.len + num_cycles; index++) for (index = 0; index < symtab.len + num_cycles; index++)
{ {
time_sorted_syms[index]->cg.index = index + 1; time_sorted_syms[index]->cg.index = index + 1;
} /* for */ }
return time_sorted_syms; return time_sorted_syms;
} /* cg_assemble */ }
/*** end of cg_arcs.c ***/

View File

@ -44,7 +44,7 @@ static bool
DEFUN (is_numbered, (child), Sym * child) DEFUN (is_numbered, (child), Sym * child)
{ {
return child->cg.top_order != DFN_NAN && child->cg.top_order != DFN_BUSY; return child->cg.top_order != DFN_NAN && child->cg.top_order != DFN_BUSY;
} /* is_numbered */ }
/* /*
@ -56,9 +56,9 @@ DEFUN (is_busy, (child), Sym * child)
if (child->cg.top_order == DFN_NAN) if (child->cg.top_order == DFN_NAN)
{ {
return FALSE; return FALSE;
} /* if */ }
return TRUE; return TRUE;
} /* is_busy */ }
/* /*
@ -81,17 +81,17 @@ DEFUN (find_cycle, (child), Sym * child)
if (child == head) if (child == head)
{ {
break; break;
} /* if */ }
if (child->cg.cyc.head != child && child->cg.cyc.head == head) if (child->cg.cyc.head != child && child->cg.cyc.head == head)
{ {
break; break;
} /* if */ }
} /* for */ }
if (cycle_top <= 0) if (cycle_top <= 0)
{ {
fprintf (stderr, "[find_cycle] couldn't find head of cycle\n"); fprintf (stderr, "[find_cycle] couldn't find head of cycle\n");
done (1); done (1);
} /* if */ }
#ifdef DEBUG #ifdef DEBUG
if (debug_level & DFNDEBUG) if (debug_level & DFNDEBUG)
{ {
@ -104,7 +104,7 @@ DEFUN (find_cycle, (child), Sym * child)
else else
{ {
printf ("<unknown>"); printf ("<unknown>");
} /* if */ }
printf ("\n"); printf ("\n");
} }
#endif #endif
@ -137,7 +137,7 @@ DEFUN (find_cycle, (child), Sym * child)
printf ("[find_cycle] tail "); printf ("[find_cycle] tail ");
print_name (tail); print_name (tail);
printf ("\n")); printf ("\n"));
} /* for */ }
/* /*
* If what we think is the top of the cycle has a cyclehead * If what we think is the top of the cycle has a cyclehead
* field, then it's not really the head of the cycle, which is * field, then it's not really the head of the cycle, which is
@ -149,7 +149,7 @@ DEFUN (find_cycle, (child), Sym * child)
DBG (DFNDEBUG, printf ("[find_cycle] new cyclehead "); DBG (DFNDEBUG, printf ("[find_cycle] new cyclehead ");
print_name (head); print_name (head);
printf ("\n")); printf ("\n"));
} /* if */ }
for (index = cycle_top + 1; index <= dfn_depth; ++index) for (index = cycle_top + 1; index <= dfn_depth; ++index)
{ {
child = dfn_stack[index].sym; child = dfn_stack[index].sym;
@ -174,16 +174,16 @@ DEFUN (find_cycle, (child), Sym * child)
printf (" onto "); printf (" onto ");
print_name (head); print_name (head);
printf ("\n")); printf ("\n"));
} /* for */ }
} }
else if (child->cg.cyc.head != head /* firewall */ ) else if (child->cg.cyc.head != head /* firewall */ )
{ {
fprintf (stderr, "[find_cycle] glommed, but not to head\n"); fprintf (stderr, "[find_cycle] glommed, but not to head\n");
done (1); done (1);
} /* if */ }
} /* for */ }
} /* if */ }
} /* find_cycle */ }
/* /*
@ -198,14 +198,14 @@ DEFUN (pre_visit, (parent), Sym * parent)
{ {
fprintf (stderr, "[pre_visit] dfn_stack overflow\n"); fprintf (stderr, "[pre_visit] dfn_stack overflow\n");
done (1); done (1);
} /* if */ }
dfn_stack[dfn_depth].sym = parent; dfn_stack[dfn_depth].sym = parent;
dfn_stack[dfn_depth].cycle_top = dfn_depth; dfn_stack[dfn_depth].cycle_top = dfn_depth;
parent->cg.top_order = DFN_BUSY; parent->cg.top_order = DFN_BUSY;
DBG (DFNDEBUG, printf ("[pre_visit]\t\t%d:", dfn_depth); DBG (DFNDEBUG, printf ("[pre_visit]\t\t%d:", dfn_depth);
print_name (parent); print_name (parent);
printf ("\n")); printf ("\n"));
} /* pre_visit */ }
/* /*
@ -233,14 +233,14 @@ DEFUN (post_visit, (parent), Sym * parent)
DBG (DFNDEBUG, printf ("[post_visit]\t\tmember "); DBG (DFNDEBUG, printf ("[post_visit]\t\tmember ");
print_name (member); print_name (member);
printf ("-> cg.top_order = %d\n", dfn_counter)); printf ("-> cg.top_order = %d\n", dfn_counter));
} /* for */ }
} }
else else
{ {
DBG (DFNDEBUG, printf ("[post_visit]\t\tis part of a cycle\n")); DBG (DFNDEBUG, printf ("[post_visit]\t\tis part of a cycle\n"));
} /* if */ }
--dfn_depth; --dfn_depth;
} /* post_visit */ }
/* /*
@ -260,7 +260,7 @@ DEFUN (cg_dfn, (parent), Sym * parent)
if (is_numbered (parent)) if (is_numbered (parent))
{ {
return; return;
} /* if */ }
/* /*
* If we're already busy, must be a cycle: * If we're already busy, must be a cycle:
*/ */
@ -268,7 +268,7 @@ DEFUN (cg_dfn, (parent), Sym * parent)
{ {
find_cycle (parent); find_cycle (parent);
return; return;
} /* if */ }
pre_visit (parent); pre_visit (parent);
/* /*
* Recursively visit children: * Recursively visit children:
@ -276,8 +276,6 @@ DEFUN (cg_dfn, (parent), Sym * parent)
for (arc = parent->cg.children; arc; arc = arc->next_child) for (arc = parent->cg.children; arc; arc = arc->next_child)
{ {
cg_dfn (arc->child); cg_dfn (arc->child);
} /* for */ }
post_visit (parent); post_visit (parent);
} /* cg_dfn */ }
/*** end of cg_dfn.c ***/

View File

@ -28,7 +28,7 @@ DEFUN_VOID (print_header)
else else
{ {
printf ("\f\n"); printf ("\f\n");
} /* if */ }
if (!bsd_style_output) if (!bsd_style_output)
{ {
if (print_descriptions) if (print_descriptions)
@ -38,8 +38,8 @@ DEFUN_VOID (print_header)
else else
{ {
printf ("\t\t\tCall graph\n\n"); printf ("\t\t\tCall graph\n\n");
} /* if */ }
} /* if */ }
printf ("\ngranularity: each sample hit covers %ld byte(s)", printf ("\ngranularity: each sample hit covers %ld byte(s)",
(long) hist_scale * sizeof (UNIT)); (long) hist_scale * sizeof (UNIT));
if (print_time > 0.0) if (print_time > 0.0)
@ -54,7 +54,7 @@ DEFUN_VOID (print_header)
* This doesn't hurt, since all the numerators will be 0.0: * This doesn't hurt, since all the numerators will be 0.0:
*/ */
print_time = 1.0; print_time = 1.0;
} /* if */ }
if (bsd_style_output) if (bsd_style_output)
{ {
printf ("%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n", printf ("%6.6s %5.5s %7.7s %11.11s %7.7s/%-7.7s %-8.8s\n",
@ -69,8 +69,8 @@ DEFUN_VOID (print_header)
else else
{ {
printf ("index %% time self children called name\n"); printf ("index %% time self children called name\n");
} /* if */ }
} /* print_header */ }
/* /*
@ -92,9 +92,9 @@ DEFUN (print_cycle, (cyc), Sym * cyc)
else else
{ {
printf (" %7.7s", ""); printf (" %7.7s", "");
} /* if */ }
printf (" <cycle %d as a whole>\t[%d]\n", cyc->cg.cyc.num, cyc->cg.index); printf (" <cycle %d as a whole>\t[%d]\n", cyc->cg.cyc.num, cyc->cg.index);
} /* print_cycle */ }
/* /*
@ -112,22 +112,22 @@ DEFUN (cmp_member, (left, right), Sym * left AND Sym * right)
if (left_time > right_time) if (left_time > right_time)
{ {
return GREATERTHAN; return GREATERTHAN;
} /* if */ }
if (left_time < right_time) if (left_time < right_time)
{ {
return LESSTHAN; return LESSTHAN;
} /* if */ }
if (left_calls > right_calls) if (left_calls > right_calls)
{ {
return GREATERTHAN; return GREATERTHAN;
} /* if */ }
if (left_calls < right_calls) if (left_calls < right_calls)
{ {
return LESSTHAN; return LESSTHAN;
} /* if */ }
return EQUALTO; return EQUALTO;
} /* cmp_member */ }
/* /*
@ -151,12 +151,12 @@ DEFUN (sort_members, (cyc), Sym * cyc)
if (cmp_member (doing, prev->cg.cyc.next) == GREATERTHAN) if (cmp_member (doing, prev->cg.cyc.next) == GREATERTHAN)
{ {
break; break;
} /* if */ }
} /* for */ }
doing->cg.cyc.next = prev->cg.cyc.next; doing->cg.cyc.next = prev->cg.cyc.next;
prev->cg.cyc.next = doing; prev->cg.cyc.next = doing;
} /* for */ }
} /* sort_members */ }
/* /*
@ -180,12 +180,12 @@ DEFUN (print_members, (cyc), Sym * cyc)
else else
{ {
printf (" %7.7s", ""); printf (" %7.7s", "");
} /* if */ }
printf (" "); printf (" ");
print_name (member); print_name (member);
printf ("\n"); printf ("\n");
} /* for */ }
} /* print_members */ }
/* /*
@ -224,11 +224,11 @@ DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right)
if (left_parent == left_child) if (left_parent == left_child)
{ {
return LESSTHAN; /* left is a self call */ return LESSTHAN; /* left is a self call */
} /* if */ }
if (right_parent == right_child) if (right_parent == right_child)
{ {
return GREATERTHAN; /* right is a self call */ return GREATERTHAN; /* right is a self call */
} /* if */ }
if (left_parent->cg.cyc.num != 0 && left_child->cg.cyc.num != 0 if (left_parent->cg.cyc.num != 0 && left_child->cg.cyc.num != 0
&& left_parent->cg.cyc.num == left_child->cg.cyc.num) && left_parent->cg.cyc.num == left_child->cg.cyc.num)
@ -241,18 +241,18 @@ DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right)
if (left->count < right->count) if (left->count < right->count)
{ {
return LESSTHAN; return LESSTHAN;
} /* if */ }
if (left->count > right->count) if (left->count > right->count)
{ {
return GREATERTHAN; return GREATERTHAN;
} /* if */ }
return EQUALTO; return EQUALTO;
} }
else else
{ {
/* right isn't a call within the cycle */ /* right isn't a call within the cycle */
return LESSTHAN; return LESSTHAN;
} /* if */ }
} }
else else
{ {
@ -271,23 +271,23 @@ DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right)
if (left_time < right_time) if (left_time < right_time)
{ {
return LESSTHAN; return LESSTHAN;
} /* if */ }
if (left_time > right_time) if (left_time > right_time)
{ {
return GREATERTHAN; return GREATERTHAN;
} /* if */ }
if (left->count < right->count) if (left->count < right->count)
{ {
return LESSTHAN; return LESSTHAN;
} /* if */ }
if (left->count > right->count) if (left->count > right->count)
{ {
return GREATERTHAN; return GREATERTHAN;
} /* if */ }
return EQUALTO; return EQUALTO;
} /* if */ }
} /* if */ }
} /* cmp_arc */ }
static void static void
@ -314,15 +314,15 @@ DEFUN (sort_parents, (child), Sym * child)
if (cmp_arc (arc, prev->next_parent) != GREATERTHAN) if (cmp_arc (arc, prev->next_parent) != GREATERTHAN)
{ {
break; break;
} /* if */ }
} /* for */ }
arc->next_parent = prev->next_parent; arc->next_parent = prev->next_parent;
prev->next_parent = arc; prev->next_parent = arc;
} /* for */ }
/* reattach sorted arcs to child: */ /* reattach sorted arcs to child: */
child->cg.parents = sorted.next_parent; child->cg.parents = sorted.next_parent;
} /* sort_parents */ }
static void static void
@ -339,7 +339,7 @@ DEFUN (print_parents, (child), Sym * child)
else else
{ {
cycle_head = child; cycle_head = child;
} /* if */ }
if (!child->cg.parents) if (!child->cg.parents)
{ {
printf (bsd_style_output printf (bsd_style_output
@ -347,7 +347,7 @@ DEFUN (print_parents, (child), Sym * child)
: "%6.6s %5.5s %7.7s %7.7s %7.7s %7.7s <spontaneous>\n", : "%6.6s %5.5s %7.7s %7.7s %7.7s %7.7s <spontaneous>\n",
"", "", "", "", "", ""); "", "", "", "", "", "");
return; return;
} /* if */ }
sort_parents (child); sort_parents (child);
for (arc = child->cg.parents; arc; arc = arc->next_parent) for (arc = child->cg.parents; arc; arc = arc->next_parent)
{ {
@ -375,9 +375,9 @@ DEFUN (print_parents, (child), Sym * child)
arc->count, cycle_head->ncalls); arc->count, cycle_head->ncalls);
print_name (parent); print_name (parent);
printf ("\n"); printf ("\n");
} /* if */ }
} /* for */ }
} /* print_parents */ }
static void static void
@ -403,15 +403,15 @@ DEFUN (sort_children, (parent), Sym * parent)
if (cmp_arc (arc, prev->next_child) != LESSTHAN) if (cmp_arc (arc, prev->next_child) != LESSTHAN)
{ {
break; break;
} /* if */ }
} /* for */ }
arc->next_child = prev->next_child; arc->next_child = prev->next_child;
prev->next_child = arc; prev->next_child = arc;
} /* for */ }
/* reattach sorted children to parent: */ /* reattach sorted children to parent: */
parent->cg.children = sorted.next_child; parent->cg.children = sorted.next_child;
} /* sort_children */ }
static void static void
@ -447,9 +447,9 @@ DEFUN (print_children, (parent), Sym * parent)
arc->count, child->cg.cyc.head->ncalls); arc->count, child->cg.cyc.head->ncalls);
print_name (child); print_name (child);
printf ("\n"); printf ("\n");
} /* if */ }
} /* for */ }
} /* print_children */ }
static void static void
@ -473,15 +473,15 @@ DEFUN (print_line, (np), Sym * np)
else else
{ {
printf (" %7.7s ", ""); printf (" %7.7s ", "");
} /* if */ }
} }
else else
{ {
printf (" %7.7s %7.7s ", "", ""); printf (" %7.7s %7.7s ", "", "");
} /* if */ }
print_name (np); print_name (np);
printf ("\n"); printf ("\n");
} /* print_line */ }
/* /*
@ -496,7 +496,7 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym)
if (print_descriptions && bsd_style_output) if (print_descriptions && bsd_style_output)
{ {
bsd_callg_blurb (stdout); bsd_callg_blurb (stdout);
} /* if */ }
print_header (); print_header ();
@ -509,7 +509,7 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym)
|| !parent->cg.print_flag) || !parent->cg.print_flag)
{ {
continue; continue;
} /* if */ }
if (!parent->name && parent->cg.cyc.num != 0) if (!parent->name && parent->cg.cyc.num != 0)
{ {
/* cycle header: */ /* cycle header: */
@ -521,7 +521,7 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym)
print_parents (parent); print_parents (parent);
print_line (parent); print_line (parent);
print_children (parent); print_children (parent);
} /* if */ }
if (bsd_style_output) if (bsd_style_output)
printf ("\n"); printf ("\n");
printf ("-----------------------------------------------\n"); printf ("-----------------------------------------------\n");
@ -533,7 +533,7 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym)
{ {
fsf_callg_blurb (stdout); fsf_callg_blurb (stdout);
} }
} /* cg_print */ }
static int static int
@ -543,7 +543,7 @@ DEFUN (cmp_name, (left, right), const PTR left AND const PTR right)
const Sym **npp2 = (const Sym **) right; const Sym **npp2 = (const Sym **) right;
return strcmp ((*npp1)->name, (*npp2)->name); return strcmp ((*npp1)->name, (*npp2)->name);
} /* cmp_name */ }
void void
@ -565,14 +565,14 @@ DEFUN_VOID (cg_print_index)
&& symtab.base[index].hist.time == 0) && symtab.base[index].hist.time == 0)
{ {
continue; continue;
} /* if */ }
name_sorted_syms[nnames++] = &symtab.base[index]; name_sorted_syms[nnames++] = &symtab.base[index];
} /* for */ }
qsort (name_sorted_syms, nnames, sizeof (Sym *), cmp_name); qsort (name_sorted_syms, nnames, sizeof (Sym *), cmp_name);
for (index = 1, todo = nnames; index <= num_cycles; index++) for (index = 1, todo = nnames; index <= num_cycles; index++)
{ {
name_sorted_syms[todo++] = &cycle_header[index]; name_sorted_syms[todo++] = &cycle_header[index];
} /* for */ }
printf ("\f\nIndex by function name\n\n"); printf ("\f\nIndex by function name\n\n");
index = (todo + 2) / 3; index = (todo + 2) / 3;
for (i = 0; i < index; i++) for (i = 0; i < index; i++)
@ -589,7 +589,7 @@ DEFUN_VOID (cg_print_index)
else else
{ {
sprintf (buf, "(%d)", sym->cg.index); sprintf (buf, "(%d)", sym->cg.index);
} /* if */ }
if (j < nnames) if (j < nnames)
{ {
if (bsd_style_output) if (bsd_style_output)
@ -602,7 +602,7 @@ DEFUN_VOID (cg_print_index)
for (; col < starting_col + 5; ++col) for (; col < starting_col + 5; ++col)
{ {
putchar (' '); putchar (' ');
} /* for */ }
printf (" %s ", buf); printf (" %s ", buf);
col += print_name_only (sym); col += print_name_only (sym);
if (!line_granularity && sym->is_static && sym->file) if (!line_granularity && sym->is_static && sym->file)
@ -618,24 +618,22 @@ DEFUN_VOID (cg_print_index)
else else
{ {
filename = sym->file->name; filename = sym->file->name;
} /* if */ }
} /* if */ }
printf (" (%s)", filename); printf (" (%s)", filename);
col += strlen (filename) + 3; col += strlen (filename) + 3;
} /* if */ }
} /* if */ }
} }
else else
{ {
printf ("%6.6s ", buf); printf ("%6.6s ", buf);
sprintf (buf, "<cycle %d>", sym->cg.cyc.num); sprintf (buf, "<cycle %d>", sym->cg.cyc.num);
printf ("%-19.19s", buf); printf ("%-19.19s", buf);
} /* if */ }
starting_col += column_width; starting_col += column_width;
} /* for */ }
printf ("\n"); printf ("\n");
} /* for */ }
free (name_sorted_syms); free (name_sorted_syms);
} /* cg_print_index */ }
/*** end of cg_print.c ***/

View File

@ -19,13 +19,13 @@ DEFUN (core_init, (a_out_name), const char *a_out_name)
{ {
perror (a_out_name); perror (a_out_name);
done (1); done (1);
} /* if */ }
if (!bfd_check_format (core_bfd, bfd_object)) if (!bfd_check_format (core_bfd, bfd_object))
{ {
fprintf (stderr, "%s: %s: not in a.out format\n", whoami, a_out_name); fprintf (stderr, "%s: %s: not in a.out format\n", whoami, a_out_name);
done (1); done (1);
} /* if */ }
/* get core's text section: */ /* get core's text section: */
core_text_sect = bfd_get_section_by_name (core_bfd, ".text"); core_text_sect = bfd_get_section_by_name (core_bfd, ".text");
@ -37,8 +37,8 @@ DEFUN (core_init, (a_out_name), const char *a_out_name)
fprintf (stderr, "%s: can't find .text section in %s\n", fprintf (stderr, "%s: can't find .text section in %s\n",
whoami, a_out_name); whoami, a_out_name);
done (1); done (1);
} /* if */ }
} /* if */ }
/* read core's symbol table: */ /* read core's symbol table: */
@ -49,7 +49,7 @@ DEFUN (core_init, (a_out_name), const char *a_out_name)
fprintf (stderr, "%s: %s: %s\n", whoami, a_out_name, fprintf (stderr, "%s: %s: %s\n", whoami, a_out_name,
bfd_errmsg (bfd_get_error ())); bfd_errmsg (bfd_get_error ()));
done (1); done (1);
} /* if */ }
core_syms = (asymbol **) xmalloc (core_num_syms); core_syms = (asymbol **) xmalloc (core_num_syms);
core_num_syms = bfd_canonicalize_symtab (core_bfd, core_syms); core_num_syms = bfd_canonicalize_symtab (core_bfd, core_syms);
@ -58,8 +58,8 @@ DEFUN (core_init, (a_out_name), const char *a_out_name)
fprintf (stderr, "%s: %s: %s\n", whoami, a_out_name, fprintf (stderr, "%s: %s: %s\n", whoami, a_out_name,
bfd_errmsg (bfd_get_error ())); bfd_errmsg (bfd_get_error ()));
done (1); done (1);
} /* if */ }
} /* core_init */ }
/* /*
@ -75,19 +75,19 @@ DEFUN (core_get_text_space, (core_bfd), bfd * core_bfd)
fprintf (stderr, "%s: ran out room for %ld bytes of text space\n", fprintf (stderr, "%s: ran out room for %ld bytes of text space\n",
whoami, core_text_sect->_raw_size); whoami, core_text_sect->_raw_size);
done (1); done (1);
} /* if */ }
if (!bfd_get_section_contents (core_bfd, core_text_sect, core_text_space, if (!bfd_get_section_contents (core_bfd, core_text_sect, core_text_space,
0, core_text_sect->_raw_size)) 0, core_text_sect->_raw_size))
{ {
bfd_perror ("bfd_get_section_contents"); bfd_perror ("bfd_get_section_contents");
free (core_text_space); free (core_text_space);
core_text_space = 0; core_text_space = 0;
} /* if */ }
if (!core_text_space) if (!core_text_space)
{ {
fprintf (stderr, "%s: can't do -c\n", whoami); fprintf (stderr, "%s: can't do -c\n", whoami);
} /* if */ }
} /* core_get_text_space */ }
/* /*
@ -111,14 +111,14 @@ DEFUN (core_sym_class, (sym), asymbol * sym)
if (!sym->section) if (!sym->section)
{ {
return 0; return 0;
} /* if */ }
if (ignore_static_funcs && (sym->flags & BSF_LOCAL)) if (ignore_static_funcs && (sym->flags & BSF_LOCAL))
{ {
DBG (AOUTDEBUG, printf ("[core_sym_class] %s: not a function\n", DBG (AOUTDEBUG, printf ("[core_sym_class] %s: not a function\n",
sym->name)); sym->name));
return 0; return 0;
} /* if */ }
bfd_get_symbol_info (core_bfd, sym, &syminfo); bfd_get_symbol_info (core_bfd, sym, &syminfo);
i = syminfo.type; i = syminfo.type;
@ -126,7 +126,7 @@ DEFUN (core_sym_class, (sym), asymbol * sym)
if (i == 'T') if (i == 'T')
{ {
return i; /* it's a global symbol */ return i; /* it's a global symbol */
} /* if */ }
if (i != 't') if (i != 't')
{ {
@ -134,14 +134,14 @@ DEFUN (core_sym_class, (sym), asymbol * sym)
DBG (AOUTDEBUG, printf ("[core_sym_class] %s is of class %c\n", DBG (AOUTDEBUG, printf ("[core_sym_class] %s is of class %c\n",
sym->name, i)); sym->name, i));
return 0; return 0;
} /* if */ }
/* do some more filtering on static function-names: */ /* do some more filtering on static function-names: */
if (ignore_static_funcs) if (ignore_static_funcs)
{ {
return 0; return 0;
} /* if */ }
/* /*
* Can't zero-length name or funny characters in name, where * Can't zero-length name or funny characters in name, where
* `funny' includes: `.' (.o file names) and `$' (Pascal labels). * `funny' includes: `.' (.o file names) and `$' (Pascal labels).
@ -149,15 +149,15 @@ DEFUN (core_sym_class, (sym), asymbol * sym)
if (!sym->name || sym->name[0] == '\0') if (!sym->name || sym->name[0] == '\0')
{ {
return 0; return 0;
} /* if */ }
for (name = sym->name; *name; ++name) for (name = sym->name; *name; ++name)
{ {
if (*name == '.' || *name == '$') if (*name == '.' || *name == '$')
{ {
return 0; return 0;
} /* if */ }
} /* if */ }
/* /*
* On systems where the C compiler adds an underscore to all * On systems where the C compiler adds an underscore to all
* names, static names without underscores seem usually to be * names, static names without underscores seem usually to be
@ -178,9 +178,9 @@ DEFUN (core_sym_class, (sym), asymbol * sym)
|| !strncmp (sym->name, "___gnu_compiled", 15)) || !strncmp (sym->name, "___gnu_compiled", 15))
{ {
return 0; return 0;
} /* if */ }
return 't'; /* it's a static text symbol */ return 't'; /* it's a static text symbol */
} /* core_sym_class */ }
/* /*
@ -212,8 +212,8 @@ DEFUN (get_src_info, (addr, filename, name, line_num),
(long) addr, fname ? fname : "<unknown>", l, (long) addr, fname ? fname : "<unknown>", l,
func_name ? func_name : "<unknown>")); func_name ? func_name : "<unknown>"));
return FALSE; return FALSE;
} /* if */ }
} /* get_src_info */ }
/* /*
@ -235,15 +235,15 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd)
if (!core_sym_class (core_syms[i])) if (!core_sym_class (core_syms[i]))
{ {
continue; continue;
} /* if */ }
++symtab.len; ++symtab.len;
} /* for */ }
if (symtab.len == 0) if (symtab.len == 0)
{ {
fprintf (stderr, "%s: file `%s' has no symbols\n", whoami, a_out_name); fprintf (stderr, "%s: file `%s' has no symbols\n", whoami, a_out_name);
done (1); done (1);
} /* if */ }
/* the "+ 2" is for the sentinels: */ /* the "+ 2" is for the sentinels: */
symtab.base = (Sym *) xmalloc ((symtab.len + 2) * sizeof (Sym)); symtab.base = (Sym *) xmalloc ((symtab.len + 2) * sizeof (Sym));
@ -260,7 +260,7 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd)
printf ("[core_create_function_syms] rejecting: 0x%lx %s\n", printf ("[core_create_function_syms] rejecting: 0x%lx %s\n",
core_syms[i]->value, core_syms[i]->name)); core_syms[i]->value, core_syms[i]->name));
continue; continue;
} /* if */ }
sym_init (symtab.limit); sym_init (symtab.limit);
@ -294,8 +294,8 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd)
printf ("[core_create_function_syms: rej %s (maps to %s)\n", printf ("[core_create_function_syms: rej %s (maps to %s)\n",
symtab.limit->name, func_name)); symtab.limit->name, func_name));
continue; continue;
} /* if */ }
} /* if */ }
#endif #endif
symtab.limit->is_func = TRUE; symtab.limit->is_func = TRUE;
@ -303,7 +303,7 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd)
if (class == 't') if (class == 't')
{ {
symtab.limit->is_static = TRUE; symtab.limit->is_static = TRUE;
} /* if */ }
min_vma = MIN (symtab.limit->addr, min_vma); min_vma = MIN (symtab.limit->addr, min_vma);
max_vma = MAX (symtab.limit->addr, max_vma); max_vma = MAX (symtab.limit->addr, max_vma);
@ -316,13 +316,13 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd)
&& strcmp (symtab.limit->name, "main") == 0) && strcmp (symtab.limit->name, "main") == 0)
{ {
discard_underscores = 0; discard_underscores = 0;
} /* if */ }
DBG (AOUTDEBUG, printf ("[core_create_function_syms] %ld %s 0x%lx\n", DBG (AOUTDEBUG, printf ("[core_create_function_syms] %ld %s 0x%lx\n",
(long) (symtab.limit - symtab.base), (long) (symtab.limit - symtab.base),
symtab.limit->name, symtab.limit->addr)); symtab.limit->name, symtab.limit->addr));
++symtab.limit; ++symtab.limit;
} /* for */ }
/* create sentinels: */ /* create sentinels: */
@ -340,7 +340,7 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd)
symtab.len = symtab.limit - symtab.base; symtab.len = symtab.limit - symtab.base;
symtab_finalize (&symtab); symtab_finalize (&symtab);
} /* core_create_function_syms */ }
/* /*
@ -393,7 +393,7 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
&& strcmp (prev_filename, filename) == 0)) && strcmp (prev_filename, filename) == 0))
{ {
continue; continue;
} /* if */ }
++ltab.len; ++ltab.len;
prev_line_num = dummy.line_num; prev_line_num = dummy.line_num;
@ -403,12 +403,12 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
if (offset - prev_offset < min_dist) if (offset - prev_offset < min_dist)
{ {
min_dist = offset - prev_offset; min_dist = offset - prev_offset;
} /* if */ }
prev_offset = offset; prev_offset = offset;
min_vma = MIN (vma, min_vma); min_vma = MIN (vma, min_vma);
max_vma = MAX (vma, max_vma); max_vma = MAX (vma, max_vma);
} /* for */ }
DBG (AOUTDEBUG, printf ("[core_create_line_syms] min_dist=%lx\n", min_dist)); DBG (AOUTDEBUG, printf ("[core_create_line_syms] min_dist=%lx\n", min_dist));
@ -430,7 +430,7 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
&& strcmp (prev->file->name, filename) == 0)) && strcmp (prev->file->name, filename) == 0))
{ {
continue; continue;
} /* if */ }
/* make name pointer a malloc'ed string: */ /* make name pointer a malloc'ed string: */
ltab.limit->name = strdup (ltab.limit->name); ltab.limit->name = strdup (ltab.limit->name);
@ -447,13 +447,13 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
&& strcmp (ltab.limit->name, "main") == 0) && strcmp (ltab.limit->name, "main") == 0)
{ {
discard_underscores = 0; discard_underscores = 0;
} /* if */ }
DBG (AOUTDEBUG, printf ("[core_create_line_syms] %d %s 0x%lx\n", DBG (AOUTDEBUG, printf ("[core_create_line_syms] %d %s 0x%lx\n",
ltab.len, ltab.limit->name, ltab.len, ltab.limit->name,
ltab.limit->addr)); ltab.limit->addr));
++ltab.limit; ++ltab.limit;
} /* for */ }
/* update sentinels: */ /* update sentinels: */
@ -462,13 +462,13 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
&& min_vma <= sentinel->end_addr) && min_vma <= sentinel->end_addr)
{ {
sentinel->end_addr = min_vma - 1; sentinel->end_addr = min_vma - 1;
} /* if */ }
sentinel = sym_lookup (&symtab, ~0); sentinel = sym_lookup (&symtab, ~0);
if (strcmp (sentinel->name, "<hicore>") == 0 && max_vma >= sentinel->addr) if (strcmp (sentinel->name, "<hicore>") == 0 && max_vma >= sentinel->addr)
{ {
sentinel->addr = max_vma + 1; sentinel->addr = max_vma + 1;
} /* if */ }
/* copy in function symbols: */ /* copy in function symbols: */
memcpy (ltab.limit, symtab.base, symtab.len * sizeof (Sym)); memcpy (ltab.limit, symtab.base, symtab.len * sizeof (Sym));
@ -480,7 +480,7 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
"%s: somebody miscounted: ltab.len=%ld instead of %d\n", "%s: somebody miscounted: ltab.len=%ld instead of %d\n",
whoami, (long) (ltab.limit - ltab.base), ltab.len); whoami, (long) (ltab.limit - ltab.base), ltab.len);
done (1); done (1);
} /* if */ }
/* finalize ltab and make it symbol table: */ /* finalize ltab and make it symbol table: */
@ -502,9 +502,7 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd)
} }
while (sym->file == sym[-1].file && while (sym->file == sym[-1].file &&
strcmp (sym->name, sym[-1].name) == 0); strcmp (sym->name, sym[-1].name) == 0);
} /* if */ }
} /* for */ }
} /* core_create_line_syms */ }
/*** end of core.c ***/

View File

@ -13,6 +13,4 @@ DEFUN (find_call, (parent, p_lowpc, p_highpc),
{ {
fprintf (stderr, "%s: -c supported on this machine architecture\n", fprintf (stderr, "%s: -c supported on this machine architecture\n",
whoami); whoami);
} /* find_call */ }
/*** end of dummy.c ***/

View File

@ -23,7 +23,7 @@ int gmon_file_version = 0; /* 0 == old (non-versioned) file format */
bfd_vma bfd_vma
DEFUN (get_vma, (abfd, addr), bfd * abfd AND bfd_byte * addr) DEFUN (get_vma, (abfd, addr), bfd * abfd AND bfd_byte * addr)
{ {
switch (sizeof (bfd_vma)) switch (sizeof (char*))
{ {
case 4: case 4:
return bfd_get_32 (abfd, addr); return bfd_get_32 (abfd, addr);
@ -31,10 +31,10 @@ DEFUN (get_vma, (abfd, addr), bfd * abfd AND bfd_byte * addr)
return bfd_get_64 (abfd, addr); return bfd_get_64 (abfd, addr);
default: default:
fprintf (stderr, "%s: bfd_vma has unexpected size of %ld bytes\n", fprintf (stderr, "%s: bfd_vma has unexpected size of %ld bytes\n",
whoami, (long) sizeof (bfd_vma)); whoami, (long) sizeof (char*));
done (1); done (1);
} /* switch */ }
} /* get_vma */ }
/* /*
@ -43,7 +43,7 @@ DEFUN (get_vma, (abfd, addr), bfd * abfd AND bfd_byte * addr)
void void
DEFUN (put_vma, (abfd, val, addr), bfd * abfd AND bfd_vma val AND bfd_byte * addr) DEFUN (put_vma, (abfd, val, addr), bfd * abfd AND bfd_vma val AND bfd_byte * addr)
{ {
switch (sizeof (bfd_vma)) switch (sizeof (char*))
{ {
case 4: case 4:
bfd_put_32 (abfd, val, addr); bfd_put_32 (abfd, val, addr);
@ -53,10 +53,10 @@ DEFUN (put_vma, (abfd, val, addr), bfd * abfd AND bfd_vma val AND bfd_byte * add
break; break;
default: default:
fprintf (stderr, "%s: bfd_vma has unexpected size of %ld bytes\n", fprintf (stderr, "%s: bfd_vma has unexpected size of %ld bytes\n",
whoami, (long) sizeof (bfd_vma)); whoami, (long) sizeof (char*));
done (1); done (1);
} /* switch */ }
} /* put_vma */ }
void void
@ -80,14 +80,14 @@ DEFUN (gmon_out_read, (filename), const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
} /* if */ }
if (fread (&ghdr, sizeof (struct gmon_hdr), 1, ifp) != 1) if (fread (&ghdr, sizeof (struct gmon_hdr), 1, ifp) != 1)
{ {
fprintf (stderr, "%s: file too short to be a gmon file\n", fprintf (stderr, "%s: file too short to be a gmon file\n",
filename); filename);
done (1); done (1);
} /* if */ }
if ((file_format == FF_MAGIC) || if ((file_format == FF_MAGIC) ||
(file_format == FF_AUTO && !strncmp (&ghdr.cookie[0], GMON_MAGIC, 4))) (file_format == FF_AUTO && !strncmp (&ghdr.cookie[0], GMON_MAGIC, 4)))
@ -97,7 +97,7 @@ DEFUN (gmon_out_read, (filename), const char *filename)
fprintf (stderr, "%s: file `%s' has bad magic cookie\n", fprintf (stderr, "%s: file `%s' has bad magic cookie\n",
whoami, filename); whoami, filename);
done (1); done (1);
} /* if */ }
/* right magic, so it's probably really a new gmon.out file */ /* right magic, so it's probably really a new gmon.out file */
@ -108,7 +108,7 @@ DEFUN (gmon_out_read, (filename), const char *filename)
"%s: file `%s' has unsupported version %d\n", "%s: file `%s' has unsupported version %d\n",
whoami, filename, gmon_file_version); whoami, filename, gmon_file_version);
done (1); done (1);
} /* if */ }
/* read in all the records: */ /* read in all the records: */
while (fread (&tag, sizeof (tag), 1, ifp) == 1) while (fread (&tag, sizeof (tag), 1, ifp) == 1)
@ -138,8 +138,8 @@ DEFUN (gmon_out_read, (filename), const char *filename)
"%s: %s: found bad tag %d (file corrupted?)\n", "%s: %s: found bad tag %d (file corrupted?)\n",
whoami, filename, tag); whoami, filename, tag);
done (1); done (1);
} /* switch */ }
} /* while */ }
} }
else if (file_format == FF_AUTO || file_format == FF_BSD) else if (file_format == FF_AUTO || file_format == FF_BSD)
{ {
@ -172,14 +172,14 @@ DEFUN (gmon_out_read, (filename), const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
if (fread (&raw, 1, sizeof (struct raw_phdr), ifp) if (fread (&raw, 1, sizeof (struct raw_phdr), ifp)
!= sizeof (struct raw_phdr)) != sizeof (struct raw_phdr))
{ {
fprintf (stderr, "%s: file too short to be a gmon file\n", fprintf (stderr, "%s: file too short to be a gmon file\n",
filename); filename);
done (1); done (1);
} /* if */ }
tmp.low_pc = get_vma (core_bfd, (bfd_byte *) & raw.low_pc[0]); tmp.low_pc = get_vma (core_bfd, (bfd_byte *) & raw.low_pc[0]);
tmp.high_pc = get_vma (core_bfd, (bfd_byte *) & raw.high_pc[0]); tmp.high_pc = get_vma (core_bfd, (bfd_byte *) & raw.high_pc[0]);
tmp.ncnt = bfd_get_32 (core_bfd, (bfd_byte *) & raw.ncnt[0]); tmp.ncnt = bfd_get_32 (core_bfd, (bfd_byte *) & raw.ncnt[0]);
@ -189,7 +189,7 @@ DEFUN (gmon_out_read, (filename), const char *filename)
fprintf (stderr, "%s: incompatible with first gmon file\n", fprintf (stderr, "%s: incompatible with first gmon file\n",
filename); filename);
done (1); done (1);
} /* if */ }
h = tmp; h = tmp;
s_lowpc = (bfd_vma) h.low_pc; s_lowpc = (bfd_vma) h.low_pc;
s_highpc = (bfd_vma) h.high_pc; s_highpc = (bfd_vma) h.high_pc;
@ -210,14 +210,14 @@ DEFUN (gmon_out_read, (filename), const char *filename)
if (hist_num_bins) if (hist_num_bins)
{ {
++nhist; ++nhist;
} /* if */ }
if (!hist_sample) if (!hist_sample)
{ {
hist_sample = hist_sample =
(int *) xmalloc (hist_num_bins * sizeof (hist_sample[0])); (int *) xmalloc (hist_num_bins * sizeof (hist_sample[0]));
memset (hist_sample, 0, hist_num_bins * sizeof (hist_sample[0])); memset (hist_sample, 0, hist_num_bins * sizeof (hist_sample[0]));
} /* if */ }
for (i = 0; i < hist_num_bins; ++i) for (i = 0; i < hist_num_bins; ++i)
{ {
@ -227,9 +227,9 @@ DEFUN (gmon_out_read, (filename), const char *filename)
"%s: unexpected EOF after reading %d/%d bins\n", "%s: unexpected EOF after reading %d/%d bins\n",
whoami, --i, hist_num_bins); whoami, --i, hist_num_bins);
done (1); done (1);
} /* if */ }
hist_sample[i] += bfd_get_16 (core_bfd, (bfd_byte *) raw_bin_count); hist_sample[i] += bfd_get_16 (core_bfd, (bfd_byte *) raw_bin_count);
} /* for */ }
/* /*
* The rest of the file consists of a bunch of <from,self,count> * The rest of the file consists of a bunch of <from,self,count>
@ -246,7 +246,7 @@ DEFUN (gmon_out_read, (filename), const char *filename)
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);
} /* while */ }
fclose (ifp); fclose (ifp);
if (hz == HZ_WRONG) if (hz == HZ_WRONG)
@ -260,15 +260,15 @@ DEFUN (gmon_out_read, (filename), const char *filename)
{ {
hz = 1; hz = 1;
fprintf (stderr, "time is in ticks, not seconds\n"); fprintf (stderr, "time is in ticks, not seconds\n");
} /* if */ }
} /* if */ }
} }
else else
{ {
fprintf (stderr, "%s: don't know how to deal with file format %d\n", fprintf (stderr, "%s: don't know how to deal with file format %d\n",
whoami, file_format); whoami, file_format);
done (1); done (1);
} /* if */ }
if (output_style & STYLE_GMON_INFO) if (output_style & STYLE_GMON_INFO)
{ {
@ -281,8 +281,8 @@ DEFUN (gmon_out_read, (filename), const char *filename)
printf ("\t%d basic-block count record%s\n", printf ("\t%d basic-block count record%s\n",
nbbs, nbbs == 1 ? "" : "s"); nbbs, nbbs == 1 ? "" : "s");
first_output = FALSE; first_output = FALSE;
} /* if */ }
} /* gmon_out_read */ }
void void
@ -296,7 +296,7 @@ DEFUN (gmon_out_write, (filename), const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
if (file_format == FF_AUTO || file_format == FF_MAGIC) if (file_format == FF_AUTO || file_format == FF_MAGIC)
{ {
@ -308,25 +308,25 @@ DEFUN (gmon_out_write, (filename), const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
/* write execution time histogram if we have one: */ /* write execution time histogram if we have one: */
if (gmon_input & INPUT_HISTOGRAM) if (gmon_input & INPUT_HISTOGRAM)
{ {
hist_write_hist (ofp, filename); hist_write_hist (ofp, filename);
} /* if */ }
/* write call graph arcs if we have any: */ /* write call graph arcs if we have any: */
if (gmon_input & INPUT_CALL_GRAPH) if (gmon_input & INPUT_CALL_GRAPH)
{ {
cg_write_arcs (ofp, filename); cg_write_arcs (ofp, filename);
} /* if */ }
/* write basic-block info if we have it: */ /* write basic-block info if we have it: */
if (gmon_input & INPUT_BB_COUNTS) if (gmon_input & INPUT_BB_COUNTS)
{ {
bb_write_blocks (ofp, filename); bb_write_blocks (ofp, filename);
} /* if */ }
} }
else if (file_format == FF_BSD) else if (file_format == FF_BSD)
{ {
@ -350,7 +350,7 @@ DEFUN (gmon_out_write, (filename), const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
/* dump the samples: */ /* dump the samples: */
@ -361,8 +361,8 @@ DEFUN (gmon_out_write, (filename), const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
} /* for */ }
/* dump the normalized raw arc information: */ /* dump the normalized raw arc information: */
@ -379,12 +379,12 @@ DEFUN (gmon_out_write, (filename), const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
DBG (SAMPLEDEBUG, DBG (SAMPLEDEBUG,
printf ("[dumpsum] frompc 0x%lx selfpc 0x%lx count %d\n", printf ("[dumpsum] frompc 0x%lx selfpc 0x%lx count %d\n",
arc->parent->addr, arc->child->addr, arc->count)); arc->parent->addr, arc->child->addr, arc->count));
} /* for */ }
} /* for */ }
fclose (ofp); fclose (ofp);
} }
else else
@ -392,7 +392,5 @@ DEFUN (gmon_out_write, (filename), const char *filename)
fprintf (stderr, "%s: don't know how to deal with file format %d\n", fprintf (stderr, "%s: don't know how to deal with file format %d\n",
whoami, file_format); whoami, file_format);
done (1); done (1);
} /* if */ }
} /* gmon_out_write */ }
/*** gmon_out.c ***/

View File

@ -27,25 +27,25 @@ struct gmon_hdr
/* types of records in this file: */ /* types of records in this file: */
typedef enum typedef enum
{ {
GMON_TAG_TIME_HIST, GMON_TAG_CG_ARC, GMON_TAG_BB_COUNT GMON_TAG_TIME_HIST = 0, GMON_TAG_CG_ARC = 1, GMON_TAG_BB_COUNT = 2
} }
GMON_Record_Tag; GMON_Record_Tag;
struct gmon_hist_hdr struct gmon_hist_hdr
{ {
char low_pc[sizeof (bfd_vma)]; /* base pc address of sample buffer */ char low_pc[sizeof (char*)]; /* base pc address of sample buffer */
char high_pc[sizeof (bfd_vma)]; /* max pc address of sampled buffer */ char high_pc[sizeof (char*)]; /* max pc address of sampled buffer */
char hist_size[4]; /* size of sample buffer */ char hist_size[4]; /* size of sample buffer */
char prof_rate[4]; /* profiling clock rate */ char prof_rate[4]; /* profiling clock rate */
char dimen[15]; /* phys. dim., usually "seconds" */ char dimen[15]; /* phys. dim., usually "seconds" */
char dimen_abbrev; /* usually 's' for "seconds" */ char dimen_abbrev; /* usually 's' for "seconds" */
}; };
struct gmon_cg_arc_record struct gmon_cg_arc_record
{ {
char from_pc[sizeof (bfd_vma)]; /* address within caller's body */ char from_pc[sizeof (char*)]; /* address within caller's body */
char self_pc[sizeof (bfd_vma)]; /* address within callee's body */ char self_pc[sizeof (char*)]; /* address within callee's body */
char count[4]; /* number of arc traversals */ char count[4]; /* number of arc traversals */
}; };
#endif /* gmon_out_h */ #endif /* gmon_out_h */

View File

@ -142,7 +142,7 @@ Usage: %s [-[abchilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\
[image-file] [profile-file...]\n", [image-file] [profile-file...]\n",
whoami); whoami);
done (status); done (status);
} /* usage */ }
int int
@ -169,7 +169,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
if (optarg) if (optarg)
{ {
sym_id_add (optarg, INCL_ANNO); sym_id_add (optarg, INCL_ANNO);
} /* if */ }
output_style |= STYLE_ANNOTATED_SOURCE; output_style |= STYLE_ANNOTATED_SOURCE;
user_specified |= STYLE_ANNOTATED_SOURCE; user_specified |= STYLE_ANNOTATED_SOURCE;
break; break;
@ -187,7 +187,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
if (optarg) if (optarg)
{ {
sym_id_add (optarg, INCL_EXEC); sym_id_add (optarg, INCL_EXEC);
} /* if */ }
output_style |= STYLE_EXEC_COUNTS; output_style |= STYLE_EXEC_COUNTS;
user_specified |= STYLE_EXEC_COUNTS; user_specified |= STYLE_EXEC_COUNTS;
break; break;
@ -200,7 +200,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
else else
{ {
debug_level = ~0; debug_level = ~0;
} /* if */ }
DBG (ANYDEBUG, printf ("[main] debug-level=0x%x\n", debug_level)); DBG (ANYDEBUG, printf ("[main] debug-level=0x%x\n", debug_level));
#ifndef DEBUG #ifndef DEBUG
printf ("%s: debugging not supported; -d ignored\n", whoami); printf ("%s: debugging not supported; -d ignored\n", whoami);
@ -240,7 +240,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
else else
{ {
output_style &= ~STYLE_ANNOTATED_SOURCE; output_style &= ~STYLE_ANNOTATED_SOURCE;
} /* if */ }
user_specified |= STYLE_ANNOTATED_SOURCE; user_specified |= STYLE_ANNOTATED_SOURCE;
break; break;
case 'k': case 'k':
@ -280,13 +280,13 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
fprintf (stderr, "%s: unknown file format %s\n", fprintf (stderr, "%s: unknown file format %s\n",
optarg, whoami); optarg, whoami);
done (1); done (1);
} /* switch */ }
break; break;
case 'p': case 'p':
if (optarg) if (optarg)
{ {
sym_id_add (optarg, INCL_FLAT); sym_id_add (optarg, INCL_FLAT);
} /* if */ }
output_style |= STYLE_FLAT_PROFILE; output_style |= STYLE_FLAT_PROFILE;
user_specified |= STYLE_FLAT_PROFILE; user_specified |= STYLE_FLAT_PROFILE;
break; break;
@ -299,7 +299,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
else else
{ {
output_style &= ~STYLE_FLAT_PROFILE; output_style &= ~STYLE_FLAT_PROFILE;
} /* if */ }
user_specified |= STYLE_FLAT_PROFILE; user_specified |= STYLE_FLAT_PROFILE;
break; break;
case 'q': case 'q':
@ -312,8 +312,8 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
else else
{ {
sym_id_add (optarg, INCL_GRAPH); sym_id_add (optarg, INCL_GRAPH);
} /* if */ }
} /* if */ }
output_style |= STYLE_CALL_GRAPH; output_style |= STYLE_CALL_GRAPH;
user_specified |= STYLE_CALL_GRAPH; user_specified |= STYLE_CALL_GRAPH;
break; break;
@ -327,13 +327,13 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
else else
{ {
sym_id_add (optarg, EXCL_GRAPH); sym_id_add (optarg, EXCL_GRAPH);
} /* if */ }
output_style |= STYLE_CALL_GRAPH; output_style |= STYLE_CALL_GRAPH;
} }
else else
{ {
output_style &= ~STYLE_CALL_GRAPH; output_style &= ~STYLE_CALL_GRAPH;
} /* if */ }
user_specified |= STYLE_CALL_GRAPH; user_specified |= STYLE_CALL_GRAPH;
break; break;
case 's': case 's':
@ -345,7 +345,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
if (bb_table_length < 0) if (bb_table_length < 0)
{ {
bb_table_length = 0; bb_table_length = 0;
} /* if */ }
break; break;
case 'T': case 'T':
bsd_style_output = TRUE; bsd_style_output = TRUE;
@ -358,7 +358,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
if (output_width < 1) if (output_width < 1)
{ {
output_width = 1; output_width = 1;
} /* if */ }
break; break;
case 'x': case 'x':
bb_annotate_all_lines = TRUE; bb_annotate_all_lines = TRUE;
@ -378,29 +378,29 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
else else
{ {
output_style &= ~STYLE_EXEC_COUNTS; output_style &= ~STYLE_EXEC_COUNTS;
} /* if */ }
user_specified |= STYLE_ANNOTATED_SOURCE; user_specified |= STYLE_ANNOTATED_SOURCE;
break; break;
default: default:
usage (stderr, 1); usage (stderr, 1);
} /* switch */ }
} /* while */ }
/* append value of GPROF_PATH to source search list if set: */ /* append value of GPROF_PATH to source search list if set: */
str = getenv ("GPROF_PATH"); str = getenv ("GPROF_PATH");
if (str) if (str)
{ {
search_list_append (&src_search_list, str); search_list_append (&src_search_list, str);
} /* if */ }
if (optind < argc) if (optind < argc)
{ {
a_out_name = argv[optind++]; a_out_name = argv[optind++];
} /* if */ }
if (optind < argc) if (optind < argc)
{ {
gmon_name = argv[optind++]; gmon_name = argv[optind++];
} /* if */ }
/* /*
* Turn off default functions: * Turn off default functions:
@ -412,7 +412,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
#ifdef __osf__ #ifdef __osf__
sym_id_add (*sp, EXCL_FLAT); sym_id_add (*sp, EXCL_FLAT);
#endif #endif
} /* for */ }
/* /*
* For line-by-line profiling, also want to keep those * For line-by-line profiling, also want to keep those
@ -423,8 +423,8 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
for (sp = &default_excluded_list[0]; *sp; sp++) for (sp = &default_excluded_list[0]; *sp; sp++)
{ {
sym_id_add (*sp, EXCL_FLAT); sym_id_add (*sp, EXCL_FLAT);
} /* for */ }
} /* if */ }
/* /*
* Read symbol table from core file: * Read symbol table from core file:
@ -438,7 +438,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
if (ignore_direct_calls) if (ignore_direct_calls)
{ {
core_get_text_space (core_bfd); core_get_text_space (core_bfd);
} /* if */ }
/* /*
* Create symbols from core image: * Create symbols from core image:
@ -450,7 +450,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
else else
{ {
core_create_function_syms (core_bfd); core_create_function_syms (core_bfd);
} /* if */ }
/* /*
* Translate sym specs into syms: * Translate sym specs into syms:
@ -469,7 +469,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
if (optind < argc) if (optind < argc)
{ {
gmon_name = argv[optind]; gmon_name = argv[optind];
} /* if */ }
} }
while (optind++ < argc); while (optind++ < argc);
#else #else
@ -490,10 +490,10 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
if (optind < argc) if (optind < argc)
{ {
gmon_name = argv[optind]; gmon_name = argv[optind];
} /* if */ }
} }
while (optind++ < argc); while (optind++ < argc);
} /* if */ }
/* /*
* If user did not specify output style, try to guess something * If user did not specify output style, try to guess something
@ -508,9 +508,9 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
else else
{ {
output_style = STYLE_EXEC_COUNTS; output_style = STYLE_EXEC_COUNTS;
} /* if */ }
output_style &= ~user_specified; output_style &= ~user_specified;
} /* if */ }
/* /*
* Dump a gmon.sum file if requested (before any other processing!): * Dump a gmon.sum file if requested (before any other processing!):
@ -518,17 +518,17 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
if (output_style & STYLE_SUMMARY_FILE) if (output_style & STYLE_SUMMARY_FILE)
{ {
gmon_out_write (GMONSUM); gmon_out_write (GMONSUM);
} /* if */ }
if (gmon_input & INPUT_HISTOGRAM) if (gmon_input & INPUT_HISTOGRAM)
{ {
hist_assign_samples (); hist_assign_samples ();
} /* if */ }
if (gmon_input & INPUT_CALL_GRAPH) if (gmon_input & INPUT_CALL_GRAPH)
{ {
cg = cg_assemble (); cg = cg_assemble ();
} /* if */ }
/* do some simple sanity checks: */ /* do some simple sanity checks: */
@ -537,45 +537,45 @@ DEFUN (main, (argc, argv), int argc AND char **argv)
{ {
fprintf (stderr, "%s: gmon.out file is missing histogram\n", whoami); fprintf (stderr, "%s: gmon.out file is missing histogram\n", whoami);
done (1); done (1);
} /* if */ }
if ((output_style & STYLE_CALL_GRAPH) && !(gmon_input & INPUT_CALL_GRAPH)) if ((output_style & STYLE_CALL_GRAPH) && !(gmon_input & INPUT_CALL_GRAPH))
{ {
fprintf (stderr, fprintf (stderr,
"%s: gmon.out file is missing call-graph data\n", whoami); "%s: gmon.out file is missing call-graph data\n", whoami);
done (1); done (1);
} /* if */ }
/* output whatever user whishes to see: */ /* output whatever user whishes to see: */
if (cg && (output_style & STYLE_CALL_GRAPH) && bsd_style_output) if (cg && (output_style & STYLE_CALL_GRAPH) && bsd_style_output)
{ {
cg_print (cg); /* print the dynamic profile */ cg_print (cg); /* print the dynamic profile */
} /* if */ }
if (output_style & STYLE_FLAT_PROFILE) if (output_style & STYLE_FLAT_PROFILE)
{ {
hist_print (); /* print the flat profile */ hist_print (); /* print the flat profile */
} /* if */ }
if (cg && (output_style & STYLE_CALL_GRAPH)) if (cg && (output_style & STYLE_CALL_GRAPH))
{ {
if (!bsd_style_output) if (!bsd_style_output)
{ {
cg_print (cg); /* print the dynamic profile */ cg_print (cg); /* print the dynamic profile */
} /* if */ }
cg_print_index (); cg_print_index ();
} /* if */ }
if (output_style & STYLE_EXEC_COUNTS) if (output_style & STYLE_EXEC_COUNTS)
{ {
print_exec_counts (); print_exec_counts ();
} /* if */ }
if (output_style & STYLE_ANNOTATED_SOURCE) if (output_style & STYLE_ANNOTATED_SOURCE)
{ {
print_annotated_source (); print_annotated_source ();
} /* if */ }
return 0; return 0;
} }

View File

@ -41,7 +41,7 @@ hertz ()
if (tim.it_interval.tv_usec < 2) if (tim.it_interval.tv_usec < 2)
{ {
return HZ_WRONG; return HZ_WRONG;
} /* if */ }
return 1000000 / tim.it_interval.tv_usec; return 1000000 / tim.it_interval.tv_usec;
#endif #endif
} /* hertz */ }

View File

@ -101,7 +101,7 @@ DEFUN (hist_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
fprintf (stderr, "%s: %s: unexpected end of file\n", fprintf (stderr, "%s: %s: unexpected end of file\n",
whoami, filename); whoami, filename);
done (1); done (1);
} /* if */ }
n_lowpc = (bfd_vma) get_vma (core_bfd, (bfd_byte *) hdr.low_pc); n_lowpc = (bfd_vma) get_vma (core_bfd, (bfd_byte *) hdr.low_pc);
n_highpc = (bfd_vma) get_vma (core_bfd, (bfd_byte *) hdr.high_pc); n_highpc = (bfd_vma) get_vma (core_bfd, (bfd_byte *) hdr.high_pc);
@ -122,7 +122,7 @@ DEFUN (hist_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
highpc = (bfd_vma) n_highpc / sizeof (UNIT); highpc = (bfd_vma) n_highpc / sizeof (UNIT);
hist_num_bins = ncnt; hist_num_bins = ncnt;
hz = profrate; hz = profrate;
} /* if */ }
DBG (SAMPLEDEBUG, DBG (SAMPLEDEBUG,
printf ("[hist_read_rec] n_lowpc 0x%lx n_highpc 0x%lx ncnt %d\n", printf ("[hist_read_rec] n_lowpc 0x%lx n_highpc 0x%lx ncnt %d\n",
@ -138,13 +138,13 @@ DEFUN (hist_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
fprintf (stderr, "%s: `%s' is incompatible with first gmon file\n", fprintf (stderr, "%s: `%s' is incompatible with first gmon file\n",
whoami, filename); whoami, filename);
done (1); done (1);
} /* if */ }
if (!hist_sample) if (!hist_sample)
{ {
hist_sample = (int *) xmalloc (hist_num_bins * sizeof (hist_sample[0])); hist_sample = (int *) xmalloc (hist_num_bins * sizeof (hist_sample[0]));
memset (hist_sample, 0, hist_num_bins * sizeof (hist_sample[0])); memset (hist_sample, 0, hist_num_bins * sizeof (hist_sample[0]));
} /* if */ }
for (i = 0; i < hist_num_bins; ++i) for (i = 0; i < hist_num_bins; ++i)
{ {
@ -154,10 +154,10 @@ DEFUN (hist_read_rec, (ifp, filename), FILE * ifp AND const char *filename)
"%s: %s: unexpected EOF after reading %d of %d samples\n", "%s: %s: unexpected EOF after reading %d of %d samples\n",
whoami, filename, i, hist_num_bins); whoami, filename, i, hist_num_bins);
done (1); done (1);
} /* if */ }
hist_sample[i] += bfd_get_16 (core_bfd, (bfd_byte *) & count[0]); hist_sample[i] += bfd_get_16 (core_bfd, (bfd_byte *) & count[0]);
} /* for */ }
} /* hist_read_rec */ }
/* /*
@ -187,7 +187,7 @@ DEFUN (hist_write_hist, (ofp, filename), FILE * ofp AND const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
for (i = 0; i < hist_num_bins; ++i) for (i = 0; i < hist_num_bins; ++i)
{ {
@ -196,9 +196,9 @@ DEFUN (hist_write_hist, (ofp, filename), FILE * ofp AND const char *filename)
{ {
perror (filename); perror (filename);
done (1); done (1);
} /* if */ }
} /* for */ }
} /* hist_write_hist */ }
/* /*
@ -230,10 +230,10 @@ DEFUN_VOID (scale_and_align_entries)
printf ("[scale_and_align_entries] pushing 0x%lx to 0x%lx\n", printf ("[scale_and_align_entries] pushing 0x%lx to 0x%lx\n",
sym->hist.scaled_addr, sym->aligned_addr + UNITS_TO_CODE)); sym->hist.scaled_addr, sym->aligned_addr + UNITS_TO_CODE));
sym->aligned_addr += UNITS_TO_CODE; sym->aligned_addr += UNITS_TO_CODE;
} /* if */ }
#endif /* OFFSET_TO_CODE > 0 */ #endif /* OFFSET_TO_CODE > 0 */
} /* for */ }
} /* scale_and_align_entries */ }
/* /*
@ -296,7 +296,7 @@ DEFUN_VOID (hist_assign_samples)
if (!bin_count) if (!bin_count)
{ {
continue; continue;
} /* if */ }
bin_low_pc = lowpc + (bfd_vma) (hist_scale * i); bin_low_pc = lowpc + (bfd_vma) (hist_scale * i);
bin_high_pc = lowpc + (bfd_vma) (hist_scale * (i + 1)); bin_high_pc = lowpc + (bfd_vma) (hist_scale * (i + 1));
time = bin_count; time = bin_count;
@ -320,7 +320,7 @@ DEFUN_VOID (hist_assign_samples)
if (bin_high_pc < sym_low_pc) if (bin_high_pc < sym_low_pc)
{ {
break; break;
} /* if */ }
/* /*
* If low end of bin is above high end of symbol, go for * If low end of bin is above high end of symbol, go for
* next symbol. * next symbol.
@ -328,7 +328,7 @@ DEFUN_VOID (hist_assign_samples)
if (bin_low_pc >= sym_high_pc) if (bin_low_pc >= sym_high_pc)
{ {
continue; continue;
} /* if */ }
overlap = overlap =
MIN (bin_high_pc, sym_high_pc) - MAX (bin_low_pc, sym_low_pc); MIN (bin_high_pc, sym_high_pc) - MAX (bin_low_pc, sym_low_pc);
if (overlap > 0) if (overlap > 0)
@ -355,13 +355,13 @@ DEFUN_VOID (hist_assign_samples)
else else
{ {
total_time -= credit; total_time -= credit;
} /* if */ }
} /* if */ }
} /* if */ }
} /* for */ }
DBG (SAMPLEDEBUG, printf ("[assign_samples] total_time %f\n", DBG (SAMPLEDEBUG, printf ("[assign_samples] total_time %f\n",
total_time)); total_time));
} /* hist_assign_samples */ }
/* /*
@ -382,26 +382,26 @@ DEFUN (print_header, (prefix), const char prefix)
{ {
printf (" for %.2f%% of %.2f %s\n\n", printf (" for %.2f%% of %.2f %s\n\n",
100.0 / total_time, total_time / hz, hist_dimension); 100.0 / total_time, total_time / hz, hist_dimension);
} /* if */ }
} }
else else
{ {
printf ("\nEach sample counts as %g %s.\n", 1.0 / hz, hist_dimension); printf ("\nEach sample counts as %g %s.\n", 1.0 / hz, hist_dimension);
} /* if */ }
if (total_time <= 0.0) if (total_time <= 0.0)
{ {
printf (" no time accumulated\n\n"); printf (" no time accumulated\n\n");
/* this doesn't hurt since all the numerators will be zero: */ /* this doesn't hurt since all the numerators will be zero: */
total_time = 1.0; total_time = 1.0;
} /* if */ }
printf ("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n", printf ("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n",
"% ", "cumulative", "self ", "", "self ", "total ", ""); "% ", "cumulative", "self ", "", "self ", "total ", "");
printf ("%5.5s %9.9s %8.8s %8.8s %8.8s %8.8s %-8.8s\n", printf ("%5.5s %9.9s %8.8s %8.8s %8.8s %8.8s %-8.8s\n",
"time", hist_dimension, hist_dimension, "calls", unit, unit, "time", hist_dimension, hist_dimension, "calls", unit, unit,
"name"); "name");
} /* print_header */ }
static void static void
@ -410,7 +410,7 @@ DEFUN (print_line, (sym, scale), Sym * sym AND double scale)
if (ignore_zeros && sym->ncalls == 0 && sym->hist.time == 0) if (ignore_zeros && sym->ncalls == 0 && sym->hist.time == 0)
{ {
return; return;
} /* if */ }
accum_time += sym->hist.time; accum_time += sym->hist.time;
if (bsd_style_output) if (bsd_style_output)
@ -424,7 +424,7 @@ DEFUN (print_line, (sym, scale), Sym * sym AND double scale)
printf ("%6.2f %9.2f %8.2f", printf ("%6.2f %9.2f %8.2f",
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 */ }
if (sym->ncalls) if (sym->ncalls)
{ {
printf (" %8d %8.2f %8.2f ", printf (" %8d %8.2f %8.2f ",
@ -434,7 +434,7 @@ DEFUN (print_line, (sym, scale), Sym * sym AND double scale)
else else
{ {
printf (" %8.8s %8.8s %8.8s ", "", "", ""); printf (" %8.8s %8.8s %8.8s ", "", "", "");
} /* if */ }
if (bsd_style_output) if (bsd_style_output)
{ {
print_name (sym); print_name (sym);
@ -442,9 +442,9 @@ DEFUN (print_line, (sym, scale), Sym * sym AND double scale)
else else
{ {
print_name_only (sym); print_name_only (sym);
} /* if */ }
printf ("\n"); printf ("\n");
} /* print_line */ }
/* /*
@ -464,24 +464,24 @@ DEFUN (cmp_time, (lp, rp), const PTR lp AND const PTR rp)
if (time_diff > 0.0) if (time_diff > 0.0)
{ {
return 1; return 1;
} /* if */ }
if (time_diff < 0.0) if (time_diff < 0.0)
{ {
return -1; return -1;
} /* if */ }
call_diff = right->ncalls - left->ncalls; call_diff = right->ncalls - left->ncalls;
if (call_diff > 0) if (call_diff > 0)
{ {
return 1; return 1;
} /* if */ }
if (call_diff < 0) if (call_diff < 0)
{ {
return -1; return -1;
} /* if */ }
return strcmp (left->name, right->name); return strcmp (left->name, right->name);
} /* cmp_time */ }
/* /*
@ -502,7 +502,7 @@ DEFUN_VOID (hist_print)
else else
{ {
printf ("\f\n"); printf ("\f\n");
} /* if */ }
accum_time = 0.0; accum_time = 0.0;
if (bsd_style_output) if (bsd_style_output)
@ -511,12 +511,12 @@ DEFUN_VOID (hist_print)
{ {
printf ("\n\n\nflat profile:\n"); printf ("\n\n\nflat profile:\n");
flat_blurb (stdout); flat_blurb (stdout);
} /* if */ }
} }
else else
{ {
printf ("Flat profile:\n"); printf ("Flat profile:\n");
} /* if */ }
/* /*
* Sort the symbol table by time (call-count and name as secondary * Sort the symbol table by time (call-count and name as secondary
* and tertiary keys): * and tertiary keys):
@ -525,7 +525,7 @@ DEFUN_VOID (hist_print)
for (index = 0; index < symtab.len; ++index) for (index = 0; index < symtab.len; ++index)
{ {
time_sorted_syms[index] = &symtab.base[index]; time_sorted_syms[index] = &symtab.base[index];
} /* for */ }
qsort (time_sorted_syms, symtab.len, sizeof (Sym *), cmp_time); qsort (time_sorted_syms, symtab.len, sizeof (Sym *), cmp_time);
if (bsd_style_output) if (bsd_style_output)
@ -551,9 +551,9 @@ DEFUN_VOID (hist_print)
{ {
top_dog = sym; top_dog = sym;
top_time = time; top_time = time;
} /* if */ }
} /* if */ }
} /* for */ }
if (top_dog && top_dog->ncalls && top_time > 0.0) if (top_dog && top_dog->ncalls && top_time > 0.0)
{ {
top_time /= hz; top_time /= hz;
@ -561,9 +561,9 @@ DEFUN_VOID (hist_print)
&& log_scale < sizeof (SItab) / sizeof (SItab[0]) - 1) && log_scale < sizeof (SItab) / sizeof (SItab[0]) - 1)
{ {
++log_scale; ++log_scale;
} /* while */ }
} /* if */ }
} /* if */ }
/* /*
* For now, the dimension is always seconds. In the future, we * For now, the dimension is always seconds. In the future, we
@ -583,14 +583,12 @@ DEFUN_VOID (hist_print)
&& !sym_lookup (&syms[EXCL_FLAT], addr))) && !sym_lookup (&syms[EXCL_FLAT], addr)))
{ {
print_line (time_sorted_syms[index], SItab[log_scale].scale); print_line (time_sorted_syms[index], SItab[log_scale].scale);
} /* if */ }
} /* for */ }
free (time_sorted_syms); free (time_sorted_syms);
if (print_descriptions && !bsd_style_output) if (print_descriptions && !bsd_style_output)
{ {
flat_blurb (stdout); flat_blurb (stdout);
} /* if */ }
} /* hist_print */ }
/*** end of hist.c ***/

View File

@ -23,7 +23,7 @@ DEFUN (search_list_append, (list, paths),
else else
{ {
len = strlen (beg); len = strlen (beg);
} /* if */ }
new_el = (Search_List_Elem *) xmalloc (sizeof (*new_el) + len); new_el = (Search_List_Elem *) xmalloc (sizeof (*new_el) + len);
memcpy (new_el->path, beg, len); memcpy (new_el->path, beg, len);
new_el->path[len] = '\0'; new_el->path[len] = '\0';
@ -37,10 +37,8 @@ DEFUN (search_list_append, (list, paths),
else else
{ {
list->head = new_el; list->head = new_el;
} /* if */ }
list->tail = new_el; list->tail = new_el;
} }
while (colon); while (colon);
} /* search_list_append */ }
/*** end of search_list.c ***/

View File

@ -28,8 +28,8 @@ DEFUN (source_file_lookup_path, (path), const char *path)
if (strcmp (path, sf->name) == 0) if (strcmp (path, sf->name) == 0)
{ {
break; break;
} /* if */ }
} /* for */ }
if (!sf) if (!sf)
{ {
/* create a new source file descriptor: */ /* create a new source file descriptor: */
@ -39,9 +39,9 @@ DEFUN (source_file_lookup_path, (path), const char *path)
sf->name = strdup (path); sf->name = strdup (path);
sf->next = first_src_file; sf->next = first_src_file;
first_src_file = sf; first_src_file = sf;
} /* if */ }
return sf; return sf;
} /* source_file_lookup_path */ }
Source_File * Source_File *
@ -65,14 +65,14 @@ DEFUN (source_file_lookup_name, (filename), const char *filename)
else else
{ {
fname = sf->name; fname = sf->name;
} /* if */ }
if (strcmp (filename, fname) == 0) if (strcmp (filename, fname) == 0)
{ {
break; break;
} /* if */ }
} /* for */ }
return sf; return sf;
} /* source_file_lookup_name */ }
FILE * FILE *
@ -98,7 +98,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
if (sf->name[0] == '/') if (sf->name[0] == '/')
{ {
sle = 0; /* don't use search list for absolute paths */ sle = 0; /* don't use search list for absolute paths */
} /* if */ }
name_only = 0; name_only = 0;
while (TRUE) while (TRUE)
{ {
@ -108,7 +108,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
if (ifp) if (ifp)
{ {
break; break;
} /* if */ }
if (!sle && !name_only) if (!sle && !name_only)
{ {
name_only = strrchr (sf->name, '/'); name_only = strrchr (sf->name, '/');
@ -117,8 +117,8 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
/* try search-list again, but this time with name only: */ /* try search-list again, but this time with name only: */
++name_only; ++name_only;
sle = src_search_list.head; sle = src_search_list.head;
} /* if */ }
} /* if */ }
if (sle) if (sle)
{ {
strcpy (fname, sle->path); strcpy (fname, sle->path);
@ -130,7 +130,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
else else
{ {
strcat (fname, sf->name); strcat (fname, sf->name);
} /* if */ }
sle = sle->next; sle = sle->next;
} }
else else
@ -143,10 +143,10 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
else else
{ {
perror (sf->name); perror (sf->name);
} /* if */ }
return 0; return 0;
} /* if */ }
} /* while */ }
ofp = stdout; ofp = stdout;
if (create_annotation_files) if (create_annotation_files)
@ -163,7 +163,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
else else
{ {
filename = sf->name; filename = sf->name;
} /* if */ }
strcpy (fname, filename); strcpy (fname, filename);
strcat (fname, EXT_ANNO); strcat (fname, EXT_ANNO);
@ -172,8 +172,8 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
{ {
perror (fname); perror (fname);
return 0; return 0;
} /* if */ }
} /* if */ }
/* /*
* Print file names if output goes to stdout and there are * Print file names if output goes to stdout and there are
@ -188,7 +188,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
else else
{ {
fputc ('\n', ofp); fputc ('\n', ofp);
} /* if */ }
if (first_output) if (first_output)
{ {
first_output = FALSE; first_output = FALSE;
@ -196,9 +196,9 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
else else
{ {
fprintf (ofp, "\f\n"); fprintf (ofp, "\f\n");
} /* if */ }
fprintf (ofp, "*** File %s:\n", sf->name); fprintf (ofp, "*** File %s:\n", sf->name);
} /* if */ }
annotation = xmalloc (max_width + 1); annotation = xmalloc (max_width + 1);
line_num = 1; line_num = 1;
@ -213,13 +213,11 @@ DEFUN (annotate_source, (sf, max_width, annote, arg),
fputs (annotation, ofp); fputs (annotation, ofp);
++line_num; ++line_num;
new_line = FALSE; new_line = FALSE;
} /* if */ }
new_line = (buf[i] == '\n'); new_line = (buf[i] == '\n');
fputc (buf[i], ofp); fputc (buf[i], ofp);
} /* for */ }
} /* while */ }
free (annotation); free (annotation);
return ofp; return ofp;
} /* annotate_source */ }
/*** end of source.c ***/

View File

@ -38,15 +38,15 @@ find_call (parent, p_lowpc, p_highpc)
if (core_text_space == 0) if (core_text_space == 0)
{ {
return; return;
} /* if */ }
if (p_lowpc < s_lowpc) if (p_lowpc < s_lowpc)
{ {
p_lowpc = s_lowpc; p_lowpc = s_lowpc;
} /* if */ }
if (p_highpc > s_highpc) if (p_highpc > s_highpc)
{ {
p_highpc = s_highpc; p_highpc = s_highpc;
} /* if */ }
DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n", DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n",
parent->name, p_lowpc, p_highpc)); parent->name, p_lowpc, p_highpc));
for (instr = (unsigned int *) (p_lowpc + delta); for (instr = (unsigned int *) (p_lowpc + delta);
@ -73,13 +73,12 @@ find_call (parent, p_lowpc, p_highpc)
/* a hit: */ /* a hit: */
arc_add (parent, child, 0); arc_add (parent, child, 0);
continue; continue;
} /* if */ }
} /* if */ }
/* /*
* Something funny going on. * Something funny going on.
*/ */
DBG (CALLDEBUG, printf ("\tbut it's a botch\n")); DBG (CALLDEBUG, printf ("\tbut it's a botch\n"));
} /* if */ }
} /* for */ }
} /* find_call */ }
/*** end of sparc.c ***/

View File

@ -64,7 +64,7 @@ DEFUN (sym_id_add, (spec, which_table),
id->next = id_list; id->next = id_list;
id_list = id; id_list = id;
} /* sym_id_add */ }
/* /*
@ -94,8 +94,8 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym)
if (!sym->file) if (!sym->file)
{ {
sym->file = &non_existent_file; sym->file = &non_existent_file;
} /* if */ }
} /* if */ }
spec = colon + 1; spec = colon + 1;
if (strlen (spec)) if (strlen (spec))
{ {
@ -106,8 +106,8 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym)
else else
{ {
sym->name = spec; sym->name = spec;
} /* if */ }
} /* if */ }
} }
else if (strlen (spec)) else if (strlen (spec))
{ {
@ -118,7 +118,7 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym)
if (!sym->file) if (!sym->file)
{ {
sym->file = &non_existent_file; sym->file = &non_existent_file;
} /* if */ }
} }
else if (isdigit (*spec)) else if (isdigit (*spec))
{ {
@ -127,9 +127,9 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym)
else if (strlen (spec)) else if (strlen (spec))
{ {
sym->name = spec; sym->name = spec;
} /* if */ }
} /* if */ }
} /* parse_spec */ }
/* /*
@ -149,7 +149,7 @@ DEFUN (parse_id, (id), struct sym_id *id)
parse_spec (slash + 1, &id->right.sym); parse_spec (slash + 1, &id->right.sym);
*slash = '\0'; *slash = '\0';
id->has_right = TRUE; id->has_right = TRUE;
} /* if */ }
parse_spec (id->spec, &id->left.sym); parse_spec (id->spec, &id->left.sym);
#ifdef DEBUG #ifdef DEBUG
@ -167,7 +167,7 @@ DEFUN (parse_id, (id), struct sym_id *id)
else else
{ {
printf ("*"); printf ("*");
} /* if */ }
if (id->has_right) if (id->has_right)
{ {
printf ("/%s:", printf ("/%s:",
@ -183,12 +183,12 @@ DEFUN (parse_id, (id), struct sym_id *id)
else else
{ {
printf ("*"); printf ("*");
} /* if */ }
} /* if */ }
printf ("\n"); printf ("\n");
} }
#endif #endif
} /* parse_id */ }
/* /*
@ -200,7 +200,7 @@ DEFUN (match, (pattern, sym), Sym * pattern AND Sym * sym)
return (pattern->file ? pattern->file == sym->file : TRUE) return (pattern->file ? pattern->file == sym->file : TRUE)
&& (pattern->line_num ? pattern->line_num == sym->line_num : TRUE) && (pattern->line_num ? pattern->line_num == sym->line_num : TRUE)
&& (pattern->name ? strcmp (pattern->name, sym->name) == 0 : TRUE); && (pattern->name ? strcmp (pattern->name, sym->name) == 0 : TRUE);
} /* match */ }
static void static void
@ -218,17 +218,17 @@ DEFUN (extend_match, (m, sym, tab, second_pass),
/* link match into match's chain: */ /* link match into match's chain: */
tab->base[tab->len].next = m->first_match; tab->base[tab->len].next = m->first_match;
m->first_match = &tab->base[tab->len]; m->first_match = &tab->base[tab->len];
} /* if */ }
++tab->len; ++tab->len;
} /* if */ }
/* extend match to include this symbol: */ /* extend match to include this symbol: */
if (second_pass) if (second_pass)
{ {
tab->base[m->prev_index].end_addr = sym->end_addr; tab->base[m->prev_index].end_addr = sym->end_addr;
} /* if */ }
m->prev_match = sym; m->prev_match = sym;
} /* extend_match */ }
/* /*
@ -253,7 +253,7 @@ DEFUN_VOID (sym_id_parse)
for (id = id_list; id; id = id->next) for (id = id_list; id; id = id->next)
{ {
parse_id (id); parse_id (id);
} /* for */ }
/* first determine size of each table: */ /* first determine size of each table: */
@ -264,13 +264,13 @@ DEFUN_VOID (sym_id_parse)
if (match (&id->left.sym, sym)) if (match (&id->left.sym, sym))
{ {
extend_match (&id->left, sym, &syms[id->which_table], FALSE); extend_match (&id->left, sym, &syms[id->which_table], FALSE);
} /* if */ }
if (id->has_right && match (&id->right.sym, sym)) if (id->has_right && match (&id->right.sym, sym))
{ {
extend_match (&id->right, sym, &right_ids, FALSE); extend_match (&id->right, sym, &right_ids, FALSE);
} /* if */ }
} /* for */ }
} /* for */ }
/* create tables of appropriate size and reset lengths: */ /* create tables of appropriate size and reset lengths: */
@ -281,14 +281,14 @@ DEFUN_VOID (sym_id_parse)
tab->base = (Sym *) xmalloc (tab->len * sizeof (Sym)); tab->base = (Sym *) xmalloc (tab->len * sizeof (Sym));
tab->limit = tab->base + tab->len; tab->limit = tab->base + tab->len;
tab->len = 0; tab->len = 0;
} /* if */ }
} /* for */ }
if (right_ids.len) if (right_ids.len)
{ {
right_ids.base = (Sym *) xmalloc (right_ids.len * sizeof (Sym)); right_ids.base = (Sym *) xmalloc (right_ids.len * sizeof (Sym));
right_ids.limit = right_ids.base + right_ids.len; right_ids.limit = right_ids.base + right_ids.len;
right_ids.len = 0; right_ids.len = 0;
} /* if */ }
/* make a second pass through symtab, creating syms as necessary: */ /* make a second pass through symtab, creating syms as necessary: */
@ -299,13 +299,13 @@ DEFUN_VOID (sym_id_parse)
if (match (&id->left.sym, sym)) if (match (&id->left.sym, sym))
{ {
extend_match (&id->left, sym, &syms[id->which_table], TRUE); extend_match (&id->left, sym, &syms[id->which_table], TRUE);
} /* if */ }
if (id->has_right && match (&id->right.sym, sym)) if (id->has_right && match (&id->right.sym, sym))
{ {
extend_match (&id->right, sym, &right_ids, TRUE); extend_match (&id->right, sym, &right_ids, TRUE);
} /* if */ }
} /* for */ }
} /* for */ }
/* go through ids creating arcs as needed: */ /* go through ids creating arcs as needed: */
@ -328,10 +328,10 @@ DEFUN_VOID (sym_id_parse)
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, 0);
} /* for */ }
} /* for */ }
} /* if */ }
} /* for */ }
/* finally, we can sort the tables and we're done: */ /* finally, we can sort the tables and we're done: */
@ -340,8 +340,8 @@ DEFUN_VOID (sym_id_parse)
DBG (IDDEBUG, printf ("[sym_id_parse] syms[%s]:\n", DBG (IDDEBUG, printf ("[sym_id_parse] syms[%s]:\n",
table_name[tab - &syms[0]])); table_name[tab - &syms[0]]));
symtab_finalize (tab); symtab_finalize (tab);
} /* for */ }
} /* sym_id_parse */ }
/* /*
@ -364,9 +364,7 @@ DEFUN (sym_id_arc_is_present, (symtab, from, to),
&& arc_lookup (sym, to)) && arc_lookup (sym, to))
{ {
return TRUE; return TRUE;
} /* if */ }
} /* for */ }
return FALSE; return FALSE;
} /* sym_id_arc_is_present */ }
/*** end of sym_ids.h ***/

View File

@ -22,7 +22,7 @@ DEFUN (sym_init, (sym), Sym * sym)
sym->cg.prop.fract = 0.0; sym->cg.prop.fract = 0.0;
sym->cg.prop.self = 0.0; sym->cg.prop.self = 0.0;
sym->cg.prop.child = 0.0; sym->cg.prop.child = 0.0;
} /* sym_init */ }
/* /*
@ -48,15 +48,15 @@ DEFUN (cmp_addr, (lp, rp), const PTR lp AND const PTR rp)
else if (left->addr < right->addr) else if (left->addr < right->addr)
{ {
return -1; return -1;
} /* if */ }
if (left->is_func != right->is_func) if (left->is_func != right->is_func)
{ {
return right->is_func - left->is_func; return right->is_func - left->is_func;
} /* if */ }
return left->is_static - right->is_static; return left->is_static - right->is_static;
} /* cmp_addr */ }
void void
@ -68,7 +68,7 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab)
if (!tab->len) if (!tab->len)
{ {
return; return;
} /* if */ }
/* /*
* Sort symbol table in order of increasing function addresses: * Sort symbol table in order of increasing function addresses:
@ -116,27 +116,27 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab)
src->name, src->is_static ? 't' : 'T', src->name, src->is_static ? 't' : 'T',
src->is_func ? 'F' : 'f'); src->is_func ? 'F' : 'f');
printf (" (addr=%lx)\n", src->addr)); printf (" (addr=%lx)\n", src->addr));
} /* if */ }
} }
else else
{ {
if (dst > tab->base && dst[-1].end_addr == 0) if (dst > tab->base && dst[-1].end_addr == 0)
{ {
dst[-1].end_addr = src->addr - 1; dst[-1].end_addr = src->addr - 1;
} /* if */ }
/* retain sym only if it has a non-empty address range: */ /* retain sym only if it has a non-empty address range: */
if (!src->end_addr || src->addr <= src->end_addr) if (!src->end_addr || src->addr <= src->end_addr)
{ {
*dst++ = *src; *dst++ = *src;
prev_addr = src->addr; prev_addr = src->addr;
} /* if */ }
} /* if */ }
} /* if */ }
if (tab->len > 0 && dst[-1].end_addr == 0) if (tab->len > 0 && dst[-1].end_addr == 0)
{ {
dst[-1].end_addr = core_text_sect->vma + core_text_sect->_raw_size - 1; dst[-1].end_addr = core_text_sect->vma + core_text_sect->_raw_size - 1;
} /* if */ }
DBG (AOUTDEBUG | IDDEBUG, DBG (AOUTDEBUG | IDDEBUG,
printf ("[symtab_finalize]: removed %d duplicate entries\n", printf ("[symtab_finalize]: removed %d duplicate entries\n",
@ -153,9 +153,9 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab)
printf ("[symtab_finalize] 0x%lx-0x%lx\t%s\n", printf ("[symtab_finalize] 0x%lx-0x%lx\t%s\n",
(long) tab->base[j].addr, (long) tab->base[j].end_addr, (long) tab->base[j].addr, (long) tab->base[j].end_addr,
tab->base[j].name); tab->base[j].name);
} /* for */ }
); );
} /* symtab_finalize */ }
#ifdef DEBUG #ifdef DEBUG
@ -179,7 +179,7 @@ DEFUN (dbg_sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address
if (sym[mid].addr <= address && sym[mid + 1].addr > address) if (sym[mid].addr <= address && sym[mid + 1].addr > address)
{ {
return &sym[mid]; return &sym[mid];
} /* if */ }
if (sym[mid].addr > address) if (sym[mid].addr > address)
{ {
high = mid; high = mid;
@ -187,11 +187,11 @@ DEFUN (dbg_sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address
else else
{ {
low = mid + 1; low = mid + 1;
} /* if */ }
} /* for */ }
fprintf (stderr, "[sym_lookup] binary search fails???\n"); fprintf (stderr, "[sym_lookup] binary search fails???\n");
return 0; return 0;
} /* dbg_sym_lookup */ }
#endif /* DEBUG */ #endif /* DEBUG */
@ -213,7 +213,7 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address)
if (!symtab->len) if (!symtab->len)
{ {
return 0; return 0;
} /* if */ }
sym = symtab->base; sym = symtab->base;
for (low = 0, high = symtab->len - 1; low != high;) for (low = 0, high = symtab->len - 1; low != high;)
@ -236,8 +236,8 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address)
printf ("[sym_lookup] %d probes (symtab->len=%d)\n", printf ("[sym_lookup] %d probes (symtab->len=%d)\n",
probes, symtab->len - 1)); probes, symtab->len - 1));
return &sym[mid]; return &sym[mid];
} /* if */ }
} /* if */ }
if (sym[mid].addr > address) if (sym[mid].addr > address)
{ {
high = mid; high = mid;
@ -245,8 +245,8 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address)
else else
{ {
low = mid + 1; low = mid + 1;
} /* if */ }
} /* for */ }
if (sym[mid + 1].addr <= address) if (sym[mid + 1].addr <= address)
{ {
if (address > sym[mid + 1].end_addr) if (address > sym[mid + 1].end_addr)
@ -259,9 +259,7 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address)
DBG (LOOKUPDEBUG, printf ("[sym_lookup] %d (%d) probes, fall off\n", DBG (LOOKUPDEBUG, printf ("[sym_lookup] %d (%d) probes, fall off\n",
probes, symtab->len - 1)); probes, symtab->len - 1));
return &sym[mid + 1]; return &sym[mid + 1];
} /* if */ }
} /* if */ }
return 0; return 0;
} /* sym_lookup */ }
/*** end of symtab.c ***/

View File

@ -206,7 +206,7 @@ find_call (parent, p_lowpc, p_highpc)
sym_init (&indirectchild); sym_init (&indirectchild);
indirectchild.cg.prop.fract = 1.0; indirectchild.cg.prop.fract = 1.0;
indirectchild.cg.cyc.head = &indirectchild; indirectchild.cg.cyc.head = &indirectchild;
} /* if */ }
if (textspace == 0) if (textspace == 0)
{ {

View File

@ -41,13 +41,13 @@ DEFUN (print_name_only, (self), Sym * self)
if (name[0] == '_' && name[1] && discard_underscores) if (name[0] == '_' && name[1] && discard_underscores)
{ {
name++; name++;
} /* if */ }
demangled = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS); demangled = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS);
if (demangled) if (demangled)
{ {
name = demangled; name = demangled;
} /* if */ }
} /* if */ }
printf ("%s", name); printf ("%s", name);
size = strlen (name); size = strlen (name);
if (line_granularity && self->file) if (line_granularity && self->file)
@ -63,21 +63,21 @@ DEFUN (print_name_only, (self), Sym * self)
else else
{ {
filename = self->file->name; filename = self->file->name;
} /* if */ }
} /* if */ }
sprintf (buf, " (%s:%d)", filename, self->line_num); sprintf (buf, " (%s:%d)", filename, self->line_num);
printf (buf); printf (buf);
size += strlen (buf); size += strlen (buf);
} /* if */ }
if (demangled) if (demangled)
{ {
free (demangled); free (demangled);
} /* if */ }
DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order)); DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order));
DBG (PROPDEBUG, printf ("%4.0f%% ", 100.0 * self->cg.prop.fract)); DBG (PROPDEBUG, printf ("%4.0f%% ", 100.0 * self->cg.prop.fract));
} /* if */ }
return size; return size;
} /* print_name_only */ }
void void
@ -88,7 +88,7 @@ DEFUN (print_name, (self), Sym * self)
if (self->cg.cyc.num != 0) if (self->cg.cyc.num != 0)
{ {
printf (" <cycle %d>", self->cg.cyc.num); printf (" <cycle %d>", self->cg.cyc.num);
} /* if */ }
if (self->cg.index != 0) if (self->cg.index != 0)
{ {
if (self->cg.print_flag) if (self->cg.print_flag)
@ -98,8 +98,6 @@ DEFUN (print_name, (self), Sym * self)
else else
{ {
printf (" (%d)", self->cg.index); printf (" (%d)", self->cg.index);
} /* if */ }
} /* if */ }
} /* print_name */ }
/*** end of utils.c ***/

View File

@ -208,7 +208,7 @@ find_call (parent, p_lowpc, p_highpc)
sym_init (&indirectchild); sym_init (&indirectchild);
indirectchild.cg.prop.fract = 1.0; indirectchild.cg.prop.fract = 1.0;
indirectchild.cg.cyc.head = &indirectchild; indirectchild.cg.cyc.head = &indirectchild;
} /* if */ }
if (core_text_space == 0) if (core_text_space == 0)
{ {