From 03c35bcb6ec00adf7bff3a0e51370718c03d5f90 Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 14 Mar 1995 02:58:16 +0000 Subject: [PATCH] * __bb_exit_func.c: New file, from David Mosberger-Tang. Thu Feb 9 16:56:07 1995 David Mosberger-Tang * 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*). --- gprof/.Sanitize | 1 + gprof/ChangeLog | 18 +++++ gprof/TODO | 5 +- gprof/__bb_exit_func.c | 78 ++++++++++++++++++++++ gprof/alpha.c | 21 +++--- gprof/basic_blocks.c | 112 +++++++++++++++---------------- gprof/call_graph.c | 18 +++-- gprof/cg_arcs.c | 148 ++++++++++++++++++++--------------------- gprof/cg_dfn.c | 50 +++++++------- gprof/cg_print.c | 140 +++++++++++++++++++------------------- gprof/core.c | 92 +++++++++++++------------ gprof/dummy.c | 4 +- gprof/gmon_io.c | 84 ++++++++++++----------- gprof/gmon_out.h | 20 +++--- gprof/gprof.c | 82 +++++++++++------------ gprof/hertz.c | 4 +- gprof/hist.c | 102 ++++++++++++++-------------- gprof/search_list.c | 8 +-- gprof/source.c | 54 ++++++++------- gprof/sparc.c | 17 +++-- gprof/sym_ids.c | 82 +++++++++++------------ gprof/symtab.c | 52 +++++++-------- gprof/tahoe.c | 2 +- gprof/utils.c | 28 ++++---- gprof/vax.c | 2 +- 25 files changed, 647 insertions(+), 577 deletions(-) create mode 100644 gprof/__bb_exit_func.c diff --git a/gprof/.Sanitize b/gprof/.Sanitize index 39fdefd8c9..428627f2f1 100644 --- a/gprof/.Sanitize +++ b/gprof/.Sanitize @@ -25,6 +25,7 @@ Do-first: Things-to-keep: .gdbinit +__bb_exit_func.c ChangeLog Makefile.in NOTES diff --git a/gprof/ChangeLog b/gprof/ChangeLog index df2134324a..ff19a73aa5 100644 --- a/gprof/ChangeLog +++ b/gprof/ChangeLog @@ -1,3 +1,21 @@ +Mon Mar 13 21:44:24 1995 Ken Raeburn + + * __bb_exit_func.c: New file, from David Mosberger-Tang. + + Thu Feb 9 16:56:07 1995 David Mosberger-Tang + + * 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 * All *.c and *.h files: Ran "indent -gnu". Cleaned up a couple diff --git a/gprof/TODO b/gprof/TODO index 222a87d34a..30a3cb25c0 100644 --- a/gprof/TODO +++ b/gprof/TODO @@ -1,7 +1,10 @@ -Sun Feb 5 16:27:32 1995 +Thu Feb 9 16:48:04 1995 - documentation - 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 at the line-level (this is useful for the uprofile tool under DEC's OSF/1) diff --git a/gprof/__bb_exit_func.c b/gprof/__bb_exit_func.c new file mode 100644 index 0000000000..512056ed4a --- /dev/null +++ b/gprof/__bb_exit_func.c @@ -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 +#include +#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 ***/ diff --git a/gprof/alpha.c b/gprof/alpha.c index e81b3721be..e99fee53e9 100644 --- a/gprof/alpha.c +++ b/gprof/alpha.c @@ -89,20 +89,20 @@ find_call (parent, p_lowpc, p_highpc) indirect_child.name = ""; indirect_child.cg.prop.fract = 1.0; indirect_child.cg.cyc.head = &indirect_child; - } /* if */ + } if (!core_text_space) { return; - } /* if */ + } if (p_lowpc < s_lowpc) { p_lowpc = s_lowpc; - } /* if */ + } if (p_highpc > s_highpc) { p_highpc = s_highpc; - } /* if */ + } DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n", parent->name, p_lowpc, p_highpc)); for (pc = (Instruction *) (p_lowpc + delta); @@ -128,7 +128,7 @@ find_call (parent, p_lowpc, p_highpc) (bfd_vma) pc - delta, pc->j.func == Jxx_FUNC_JSR ? "" : "_coroutine")); arc_add (parent, &indirect_child, 0); - } /* if */ + } break; case OP_BSR: @@ -153,8 +153,8 @@ find_call (parent, p_lowpc, p_highpc) /* a hit: */ arc_add (parent, child, 0); continue; - } /* if */ - } /* if */ + } + } /* * Something funny going on. */ @@ -163,7 +163,6 @@ find_call (parent, p_lowpc, p_highpc) default: break; - } /* switch */ - } /* for */ -} /* find_call */ -/*** end of alpha.c ***/ + } + } +} diff --git a/gprof/basic_blocks.c b/gprof/basic_blocks.c index 3c210837e5..2502803634 100644 --- a/gprof/basic_blocks.c +++ b/gprof/basic_blocks.c @@ -47,13 +47,13 @@ DEFUN (cmp_bb, (lp, rp), const void *lp AND const void *rp) if (r) { return r; - } /* if */ + } if (left->line_num != right->line_num) { return left->line_num - right->line_num; - } /* if */ - } /* if */ + } + } if (left->addr < right->addr) { @@ -66,8 +66,8 @@ DEFUN (cmp_bb, (lp, rp), const void *lp AND const void *rp) else { return 0; - } /* if */ -} /* cmp_bb */ + } +} /* @@ -87,15 +87,15 @@ DEFUN (cmp_ncalls, (lp, rp), const void *lp AND const void *rp) else if (!right) { return -1; - } /* if */ + } if (right->ncalls != left->ncalls) { return right->ncalls - left->ncalls; - } /* if */ + } return left->line_num - right->line_num; -} /* cmp_ncalls */ +} /* @@ -111,9 +111,9 @@ DEFUN (fskip_string, (fp), FILE * fp) if (ch == '\0') { 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); done (1); - } /* if */ + } nblocks = bfd_get_32 (core_bfd, (bfd_byte *) & nblocks); if (gmon_file_version == 0) { fskip_string (ifp); - } /* if */ + } for (b = 0; b < nblocks; ++b) { @@ -157,7 +157,7 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename) { perror (filename); done (1); - } /* if */ + } } else { @@ -166,8 +166,8 @@ DEFUN (bb_read_rec, (ifp, filename), FILE * ifp AND const char *filename) { perror (filename); done (1); - } /* if */ - } /* if */ + } + } /* * 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, "%s: warning: ignoring basic-block exec counts (use -l or --line)\n", whoami); - } /* if */ - } /* if */ - } /* for */ + } + } + } return; -} /* bb_read_rec */ +} /* @@ -225,8 +225,8 @@ DEFUN (bb_write_blocks, (ofp, filename), FILE * ofp AND const char *filename) if (sym->ncalls > 0) { ++nblocks; - } /* if */ - } /* for */ + } + } /* write header: */ 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); done (1); - } /* if */ + } /* write counts: */ 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) { continue; - } /* if */ + } put_vma (core_bfd, sym->addr, (bfd_byte *) & addr); 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); done (1); - } /* if */ - } /* for */ -} /* bb_write_blocks */ + } + } +} /* @@ -277,7 +277,7 @@ DEFUN_VOID (print_exec_counts) else { printf ("\f\n"); - } /* if */ + } /* 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)))) { sorted_bbs[len++] = sym; - } /* if */ - } /* for */ + } + } qsort (sorted_bbs, len, sizeof (sorted_bbs[0]), cmp_bb); /* output basic-blocks: */ @@ -309,9 +309,9 @@ DEFUN_VOID (print_exec_counts) printf ("%s:%d: (%s:0x%lx) %d executions\n", sym->file ? sym->file->name : "", sym->line_num, sym->name, sym->addr, sym->ncalls); - } /* for */ + } free (sorted_bbs); -} /* print_exec_counts */ +} /* @@ -330,13 +330,13 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg), if (line_num == 1) { last_count = -1; - } /* if */ + } b = 0; if (line_num <= sf->num_lines) { b = sf->line[line_num - 1]; - } /* if */ + } if (!b) { cnt = -1; @@ -345,15 +345,15 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg), { ++num_executable_lines; cnt = b->ncalls; - } /* if */ + } if (cnt > 0) { ++num_lines_executed; - } /* if */ + } if (cnt < 0 && bb_annotate_all_lines) { cnt = last_count; - } /* if */ + } if (cnt < 0) { @@ -366,9 +366,9 @@ DEFUN (annotate_with_count, (buf, width, line_num, arg), else { sprintf (buf, "%12ld -> ", cnt); - } /* if */ + } last_count = cnt; -} /* annotate_with_count */ +} /* @@ -402,8 +402,8 @@ DEFUN_VOID (print_annotated_source) && !sym_lookup (&syms[EXCL_ANNO], sym->addr)))) { sym->file->num_lines = sym->line_num; - } /* if */ - } /* for */ + } + } /* allocate line descriptors: */ @@ -413,8 +413,8 @@ DEFUN_VOID (print_annotated_source) { sf->line = (void *) xmalloc (sf->num_lines * sizeof (sf->line[0])); memset (sf->line, 0, sf->num_lines * sizeof (sf->line[0])); - } /* if */ - } /* for */ + } + } /* count executions per line: */ @@ -445,9 +445,9 @@ DEFUN_VOID (print_annotated_source) new_line->addr = 0; new_line->ncalls += sym->ncalls; sym->file->line[sym->line_num - 1] = new_line; - } /* if */ - } /* if */ - } /* for */ + } + } + } /* plod over source files, annotating them: */ @@ -456,14 +456,14 @@ DEFUN_VOID (print_annotated_source) if (!sf->num_lines || (ignore_zeros && sf->ncalls == 0)) { continue; - } /* if */ + } num_executable_lines = num_lines_executed = 0; ofp = annotate_source (sf, 16, annotate_with_count, sf); if (!ofp) { continue; - } /* if */ + } if (bb_table_length > 0) { @@ -476,17 +476,17 @@ DEFUN_VOID (print_annotated_source) if (table_len > sf->num_lines) { table_len = sf->num_lines; - } /* if */ + } for (i = 0; i < table_len; ++i) { sym = sf->line[i]; if (!sym || sym->ncalls <= 0) { break; - } /* if */ + } fprintf (ofp, "%9d %10d\n", sym->line_num, sym->ncalls); - } /* for */ - } /* if */ + } + } free (sf->line); sf->line = 0; @@ -507,8 +507,6 @@ DEFUN_VOID (print_annotated_source) if (ofp != stdout) { fclose (ofp); - } /* if */ - } /* for */ -} /* print_annotated_source */ - -/*** end of basic_block.c ***/ + } + } +} diff --git a/gprof/call_graph.c b/gprof/call_graph.c index bd2a4715b7..a61dd837d0 100644 --- a/gprof/call_graph.c +++ b/gprof/call_graph.c @@ -29,8 +29,8 @@ DEFUN (cg_tally, (from_pc, self_pc, count), printf ("[cg_tally] arc from %s to %s traversed %d times\n", parent->name, child->name, 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", whoami, filename); done (1); - } /* if */ + } from_pc = get_vma (core_bfd, (bfd_byte *) arc.from_pc); self_pc = get_vma (core_bfd, (bfd_byte *) arc.self_pc); 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)); /* add this arc: */ 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); done (1); - } /* if */ + } DBG (SAMPLEDEBUG, printf ("[cg_write_arcs] frompc 0x%lx selfpc 0x%lx count %d\n", arc->parent->addr, arc->child->addr, arc->count)); - } /* for */ - } /* for */ -} /* cg_write_arcs */ - -/*** end of call_graph.c ***/ + } + } +} diff --git a/gprof/cg_arcs.c b/gprof/cg_arcs.c index 5c2c806e4f..8b6184b6bc 100644 --- a/gprof/cg_arcs.c +++ b/gprof/cg_arcs.c @@ -41,7 +41,7 @@ DEFUN (arc_lookup, (parent, child), Sym * parent AND Sym * child) { printf ("[arc_lookup] parent == 0 || child == 0\n"); return 0; - } /* if */ + } DBG (LOOKUPDEBUG, printf ("[arc_lookup] parent %s child %s\n", parent->name, child->name)); 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) { return arc; - } /* if */ - } /* for */ + } + } return 0; -} /* arc_lookup */ +} /* @@ -79,7 +79,7 @@ DEFUN (arc_add, (parent, child, count), arc->count, count)); arc->count += count; return; - } /* if */ + } arc = (Arc *) xmalloc (sizeof (*arc)); arc->parent = parent; arc->child = child; @@ -92,7 +92,7 @@ DEFUN (arc_add, (parent, child, count), /* prepend this parent to the parents of this child: */ arc->next_parent = child->cg.parents; child->cg.parents = arc; -} /* arc_add */ +} static int @@ -102,7 +102,7 @@ DEFUN (cmp_topo, (lp, rp), const PTR lp AND const PTR rp) const Sym *right = *(const Sym **) rp; return left->cg.top_order - right->cg.top_order; -} /* cmp_topo */ +} static void @@ -115,7 +115,7 @@ DEFUN (propagate_time, (parent), Sym * parent) if (parent->cg.prop.fract == 0.0) { return; - } /* if */ + } /* 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) { continue; - } /* if */ + } if (child->cg.cyc.head != child) { if (parent->cg.cyc.num == child->cg.cyc.num) { continue; - } /* if */ + } if (parent->cg.top_order <= child->cg.top_order) { fprintf (stderr, "[propagate] toporder botches\n"); - } /* if */ + } child = child->cg.cyc.head; } else @@ -144,12 +144,12 @@ DEFUN (propagate_time, (parent), Sym * parent) { fprintf (stderr, "[propagate] toporder botches\n"); continue; - } /* if */ - } /* if */ + } + } if (child->ncalls == 0) { continue; - } /* if */ + } /* distribute time for this arc: */ 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.prop.child += prop_share; - } /* if */ + } DBG (PROPDEBUG, printf ("[prop_time] child \t"); print_name (child); @@ -181,8 +181,8 @@ DEFUN (propagate_time, (parent), Sym * parent) printf ("[prop_time] parent\t"); print_name (parent); printf ("\n[prop_time] share %f\n", share)); - } /* for */ -} /* propagate_time */ + } +} /* @@ -205,12 +205,12 @@ DEFUN_VOID (cycle_time) * that were excluded with -E. */ continue; - } /* if */ + } cyc->hist.time += member->hist.time; - } /* for */ + } cyc->cg.prop.self = cyc->cg.prop.fract * cyc->hist.time; - } /* for */ -} /* cycle_time */ + } +} static void @@ -229,8 +229,8 @@ DEFUN_VOID (cycle_link) if (sym->cg.cyc.head == sym && sym->cg.cyc.next) { ++num_cycles; - } /* if */ - } /* for */ + } + } /* * 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)) { continue; - } /* if */ + } ++num; ++cyc; sym_init (cyc); @@ -267,7 +267,7 @@ DEFUN_VOID (cycle_link) { member->cg.cyc.num = num; member->cg.cyc.head = cyc; - } /* for */ + } /* * Count calls from outside the cycle and those among cycle @@ -280,7 +280,7 @@ DEFUN_VOID (cycle_link) if (arc->parent == member) { continue; - } /* if */ + } if (arc->parent->cg.cyc.num == num) { cyc->cg.self_calls += arc->count; @@ -288,11 +288,11 @@ DEFUN_VOID (cycle_link) else { cyc->ncalls += arc->count; - } /* if */ - } /* for */ - } /* for */ - } /* for */ -} /* cycle_link */ + } + } + } + } +} /* @@ -319,7 +319,7 @@ DEFUN (inherit_flags, (child), Sym * child) if (child == parent) { continue; - } /* if */ + } child->cg.print_flag |= parent->cg.print_flag; /* * 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 * (((double) arc->count) / ((double) child->ncalls)); - } /* if */ - } /* for */ + } + } } else { @@ -348,7 +348,7 @@ DEFUN (inherit_flags, (child), Sym * child) if (arc->parent->cg.cyc.head == head) { continue; - } /* if */ + } parent = arc->parent; 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 * (((double) arc->count) / ((double) head->ncalls)); - } /* if */ - } /* for */ - } /* for */ + } + } + } for (member = head; member; member = member->cg.cyc.next) { member->cg.print_flag = head->cg.print_flag; 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; inherit_flags (child); - } /* if */ + } DBG (PROPDEBUG, printf ("[prop_flags] "); print_name (child); @@ -417,7 +417,7 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols) && !sym_lookup (&syms[EXCL_GRAPH], child->addr))) { child->cg.print_flag = TRUE; - } /* if */ + } } else { @@ -430,8 +430,8 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols) && sym_lookup (&syms[EXCL_GRAPH], child->addr)) { child->cg.print_flag = FALSE; - } /* if */ - } /* if */ + } + } if (child->cg.prop.fract == 0.0) { /* @@ -444,7 +444,7 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols) && !sym_lookup (&syms[EXCL_TIME], child->addr))) { child->cg.prop.fract = 1.0; - } /* if */ + } } else { @@ -458,8 +458,8 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols) && sym_lookup (&syms[EXCL_TIME], child->addr)) { child->cg.prop.fract = 0.0; - } /* if */ - } /* if */ + } + } child->cg.prop.self = child->hist.time * child->cg.prop.fract; print_time += child->cg.prop.self; DBG (PROPDEBUG, @@ -469,8 +469,8 @@ DEFUN (propagate_flags, (symbols), Sym ** symbols) child->cg.print_flag, child->cg.prop.fract); printf ("[prop_flags] time %f propself %f print_time %f\n", 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) { return 1; - } /* if */ + } if (diff > 0.0) { return -1; - } /* if */ + } if (!left->name && left->cg.cyc.num != 0) { return -1; - } /* if */ + } if (!right->name && right->cg.cyc.num != 0) { return 1; - } /* if */ + } if (!left->name) { return -1; - } /* if */ + } if (!right->name) { return 1; - } /* if */ + } if (left->name[0] != '_' && right->name[0] == '_') { return -1; - } /* if */ + } if (left->name[0] == '_' && right->name[0] != '_') { return 1; - } /* if */ + } if (left->ncalls > right->ncalls) { return -1; - } /* if */ + } if (left->ncalls < right->ncalls) { return 1; - } /* if */ + } return strcmp (left->name, right->name); -} /* cmp_total */ +} /* @@ -562,7 +562,7 @@ DEFUN_VOID (cg_assemble) else { parent->cg.self_calls = 0; - } /* if */ + } parent->cg.prop.fract = 0.0; parent->cg.prop.self = 0.0; parent->cg.prop.child = 0.0; @@ -574,8 +574,8 @@ DEFUN_VOID (cg_assemble) if (ignore_direct_calls) { find_call (parent, parent->addr, (parent + 1)->addr); - } /* if */ - } /* for */ + } + } /* * Topologically order things. If any node is unnumbered, number * it and any of its descendents. @@ -585,8 +585,8 @@ DEFUN_VOID (cg_assemble) if (parent->cg.top_order == DFN_NAN) { cg_dfn (parent); - } /* if */ - } /* for */ + } + } /* link together nodes on the same cycle: */ cycle_link (); @@ -596,7 +596,7 @@ DEFUN_VOID (cg_assemble) for (index = 0; index < symtab.len; ++index) { top_sorted_syms[index] = &symtab.base[index]; - } /* for */ + } qsort (top_sorted_syms, symtab.len, sizeof (Sym *), cmp_topo); DBG (DFNDEBUG, printf ("[cg_assemble] topological sort listing\n"); @@ -606,7 +606,7 @@ DEFUN_VOID (cg_assemble) printf ("%d:", top_sorted_syms[index]->cg.top_order); print_name (top_sorted_syms[index]); printf ("\n"); - } /* for */ + } ); /* * Starting from the topological top, propagate print flags to @@ -624,7 +624,7 @@ DEFUN_VOID (cg_assemble) for (index = 0; index < symtab.len; ++index) { propagate_time (top_sorted_syms[index]); - } /* for */ + } free (top_sorted_syms); @@ -636,18 +636,16 @@ DEFUN_VOID (cg_assemble) for (index = 0; index < symtab.len; index++) { time_sorted_syms[index] = &symtab.base[index]; - } /* if */ + } for (index = 1; index <= num_cycles; index++) { time_sorted_syms[symtab.len + index - 1] = &cycle_header[index]; - } /* for */ + } qsort (time_sorted_syms, symtab.len + num_cycles, sizeof (Sym *), cmp_total); for (index = 0; index < symtab.len + num_cycles; index++) { time_sorted_syms[index]->cg.index = index + 1; - } /* for */ + } return time_sorted_syms; -} /* cg_assemble */ - -/*** end of cg_arcs.c ***/ +} diff --git a/gprof/cg_dfn.c b/gprof/cg_dfn.c index 29eb64c64b..c9e37ab29e 100644 --- a/gprof/cg_dfn.c +++ b/gprof/cg_dfn.c @@ -44,7 +44,7 @@ static bool DEFUN (is_numbered, (child), Sym * child) { 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) { return FALSE; - } /* if */ + } return TRUE; -} /* is_busy */ +} /* @@ -81,17 +81,17 @@ DEFUN (find_cycle, (child), Sym * child) if (child == head) { break; - } /* if */ + } if (child->cg.cyc.head != child && child->cg.cyc.head == head) { break; - } /* if */ - } /* for */ + } + } if (cycle_top <= 0) { fprintf (stderr, "[find_cycle] couldn't find head of cycle\n"); done (1); - } /* if */ + } #ifdef DEBUG if (debug_level & DFNDEBUG) { @@ -104,7 +104,7 @@ DEFUN (find_cycle, (child), Sym * child) else { printf (""); - } /* if */ + } printf ("\n"); } #endif @@ -137,7 +137,7 @@ DEFUN (find_cycle, (child), Sym * child) printf ("[find_cycle] tail "); print_name (tail); printf ("\n")); - } /* for */ + } /* * 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 @@ -149,7 +149,7 @@ DEFUN (find_cycle, (child), Sym * child) DBG (DFNDEBUG, printf ("[find_cycle] new cyclehead "); print_name (head); printf ("\n")); - } /* if */ + } for (index = cycle_top + 1; index <= dfn_depth; ++index) { child = dfn_stack[index].sym; @@ -174,16 +174,16 @@ DEFUN (find_cycle, (child), Sym * child) printf (" onto "); print_name (head); printf ("\n")); - } /* for */ + } } else if (child->cg.cyc.head != head /* firewall */ ) { fprintf (stderr, "[find_cycle] glommed, but not to head\n"); 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"); done (1); - } /* if */ + } dfn_stack[dfn_depth].sym = parent; dfn_stack[dfn_depth].cycle_top = dfn_depth; parent->cg.top_order = DFN_BUSY; DBG (DFNDEBUG, printf ("[pre_visit]\t\t%d:", dfn_depth); print_name (parent); printf ("\n")); -} /* pre_visit */ +} /* @@ -233,14 +233,14 @@ DEFUN (post_visit, (parent), Sym * parent) DBG (DFNDEBUG, printf ("[post_visit]\t\tmember "); print_name (member); printf ("-> cg.top_order = %d\n", dfn_counter)); - } /* for */ + } } else { DBG (DFNDEBUG, printf ("[post_visit]\t\tis part of a cycle\n")); - } /* if */ + } --dfn_depth; -} /* post_visit */ +} /* @@ -260,7 +260,7 @@ DEFUN (cg_dfn, (parent), Sym * parent) if (is_numbered (parent)) { return; - } /* if */ + } /* * If we're already busy, must be a cycle: */ @@ -268,7 +268,7 @@ DEFUN (cg_dfn, (parent), Sym * parent) { find_cycle (parent); return; - } /* if */ + } pre_visit (parent); /* * Recursively visit children: @@ -276,8 +276,6 @@ DEFUN (cg_dfn, (parent), Sym * parent) for (arc = parent->cg.children; arc; arc = arc->next_child) { cg_dfn (arc->child); - } /* for */ + } post_visit (parent); -} /* cg_dfn */ - -/*** end of cg_dfn.c ***/ +} diff --git a/gprof/cg_print.c b/gprof/cg_print.c index cbff366217..d83fbb73fe 100644 --- a/gprof/cg_print.c +++ b/gprof/cg_print.c @@ -28,7 +28,7 @@ DEFUN_VOID (print_header) else { printf ("\f\n"); - } /* if */ + } if (!bsd_style_output) { if (print_descriptions) @@ -38,8 +38,8 @@ DEFUN_VOID (print_header) else { printf ("\t\t\tCall graph\n\n"); - } /* if */ - } /* if */ + } + } printf ("\ngranularity: each sample hit covers %ld byte(s)", (long) hist_scale * sizeof (UNIT)); 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: */ print_time = 1.0; - } /* if */ + } if (bsd_style_output) { 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 { printf ("index %% time self children called name\n"); - } /* if */ -} /* print_header */ + } +} /* @@ -92,9 +92,9 @@ DEFUN (print_cycle, (cyc), Sym * cyc) else { printf (" %7.7s", ""); - } /* if */ + } printf (" \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) { return GREATERTHAN; - } /* if */ + } if (left_time < right_time) { return LESSTHAN; - } /* if */ + } if (left_calls > right_calls) { return GREATERTHAN; - } /* if */ + } if (left_calls < right_calls) { return LESSTHAN; - } /* if */ + } return EQUALTO; -} /* cmp_member */ +} /* @@ -151,12 +151,12 @@ DEFUN (sort_members, (cyc), Sym * cyc) if (cmp_member (doing, prev->cg.cyc.next) == GREATERTHAN) { break; - } /* if */ - } /* for */ + } + } doing->cg.cyc.next = prev->cg.cyc.next; prev->cg.cyc.next = doing; - } /* for */ -} /* sort_members */ + } +} /* @@ -180,12 +180,12 @@ DEFUN (print_members, (cyc), Sym * cyc) else { printf (" %7.7s", ""); - } /* if */ + } printf (" "); print_name (member); printf ("\n"); - } /* for */ -} /* print_members */ + } +} /* @@ -224,11 +224,11 @@ DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right) if (left_parent == left_child) { return LESSTHAN; /* left is a self call */ - } /* if */ + } if (right_parent == right_child) { return GREATERTHAN; /* right is a self call */ - } /* if */ + } if (left_parent->cg.cyc.num != 0 && left_child->cg.cyc.num != 0 && 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) { return LESSTHAN; - } /* if */ + } if (left->count > right->count) { return GREATERTHAN; - } /* if */ + } return EQUALTO; } else { /* right isn't a call within the cycle */ return LESSTHAN; - } /* if */ + } } else { @@ -271,23 +271,23 @@ DEFUN (cmp_arc, (left, right), Arc * left AND Arc * right) if (left_time < right_time) { return LESSTHAN; - } /* if */ + } if (left_time > right_time) { return GREATERTHAN; - } /* if */ + } if (left->count < right->count) { return LESSTHAN; - } /* if */ + } if (left->count > right->count) { return GREATERTHAN; - } /* if */ + } return EQUALTO; - } /* if */ - } /* if */ -} /* cmp_arc */ + } + } +} static void @@ -314,15 +314,15 @@ DEFUN (sort_parents, (child), Sym * child) if (cmp_arc (arc, prev->next_parent) != GREATERTHAN) { break; - } /* if */ - } /* for */ + } + } arc->next_parent = prev->next_parent; prev->next_parent = arc; - } /* for */ + } /* reattach sorted arcs to child: */ child->cg.parents = sorted.next_parent; -} /* sort_parents */ +} static void @@ -339,7 +339,7 @@ DEFUN (print_parents, (child), Sym * child) else { cycle_head = child; - } /* if */ + } if (!child->cg.parents) { 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 \n", "", "", "", "", "", ""); return; - } /* if */ + } sort_parents (child); 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); print_name (parent); printf ("\n"); - } /* if */ - } /* for */ -} /* print_parents */ + } + } +} static void @@ -403,15 +403,15 @@ DEFUN (sort_children, (parent), Sym * parent) if (cmp_arc (arc, prev->next_child) != LESSTHAN) { break; - } /* if */ - } /* for */ + } + } arc->next_child = prev->next_child; prev->next_child = arc; - } /* for */ + } /* reattach sorted children to parent: */ parent->cg.children = sorted.next_child; -} /* sort_children */ +} static void @@ -447,9 +447,9 @@ DEFUN (print_children, (parent), Sym * parent) arc->count, child->cg.cyc.head->ncalls); print_name (child); printf ("\n"); - } /* if */ - } /* for */ -} /* print_children */ + } + } +} static void @@ -473,15 +473,15 @@ DEFUN (print_line, (np), Sym * np) else { printf (" %7.7s ", ""); - } /* if */ + } } else { printf (" %7.7s %7.7s ", "", ""); - } /* if */ + } print_name (np); printf ("\n"); -} /* print_line */ +} /* @@ -496,7 +496,7 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym) if (print_descriptions && bsd_style_output) { bsd_callg_blurb (stdout); - } /* if */ + } print_header (); @@ -509,7 +509,7 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym) || !parent->cg.print_flag) { continue; - } /* if */ + } if (!parent->name && parent->cg.cyc.num != 0) { /* cycle header: */ @@ -521,7 +521,7 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym) print_parents (parent); print_line (parent); print_children (parent); - } /* if */ + } if (bsd_style_output) printf ("\n"); printf ("-----------------------------------------------\n"); @@ -533,7 +533,7 @@ DEFUN (cg_print, (timesortsym), Sym ** timesortsym) { fsf_callg_blurb (stdout); } -} /* cg_print */ +} static int @@ -543,7 +543,7 @@ DEFUN (cmp_name, (left, right), const PTR left AND const PTR right) const Sym **npp2 = (const Sym **) right; return strcmp ((*npp1)->name, (*npp2)->name); -} /* cmp_name */ +} void @@ -565,14 +565,14 @@ DEFUN_VOID (cg_print_index) && symtab.base[index].hist.time == 0) { continue; - } /* if */ + } name_sorted_syms[nnames++] = &symtab.base[index]; - } /* for */ + } qsort (name_sorted_syms, nnames, sizeof (Sym *), cmp_name); for (index = 1, todo = nnames; index <= num_cycles; index++) { name_sorted_syms[todo++] = &cycle_header[index]; - } /* for */ + } printf ("\f\nIndex by function name\n\n"); index = (todo + 2) / 3; for (i = 0; i < index; i++) @@ -589,7 +589,7 @@ DEFUN_VOID (cg_print_index) else { sprintf (buf, "(%d)", sym->cg.index); - } /* if */ + } if (j < nnames) { if (bsd_style_output) @@ -602,7 +602,7 @@ DEFUN_VOID (cg_print_index) for (; col < starting_col + 5; ++col) { putchar (' '); - } /* for */ + } printf (" %s ", buf); col += print_name_only (sym); if (!line_granularity && sym->is_static && sym->file) @@ -618,24 +618,22 @@ DEFUN_VOID (cg_print_index) else { filename = sym->file->name; - } /* if */ - } /* if */ + } + } printf (" (%s)", filename); col += strlen (filename) + 3; - } /* if */ - } /* if */ + } + } } else { printf ("%6.6s ", buf); sprintf (buf, "", sym->cg.cyc.num); printf ("%-19.19s", buf); - } /* if */ + } starting_col += column_width; - } /* for */ + } printf ("\n"); - } /* for */ + } free (name_sorted_syms); -} /* cg_print_index */ - -/*** end of cg_print.c ***/ +} diff --git a/gprof/core.c b/gprof/core.c index a525c60e97..bb849e788b 100644 --- a/gprof/core.c +++ b/gprof/core.c @@ -19,13 +19,13 @@ DEFUN (core_init, (a_out_name), const char *a_out_name) { perror (a_out_name); done (1); - } /* if */ + } if (!bfd_check_format (core_bfd, bfd_object)) { fprintf (stderr, "%s: %s: not in a.out format\n", whoami, a_out_name); done (1); - } /* if */ + } /* get core's text section: */ 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", whoami, a_out_name); done (1); - } /* if */ - } /* if */ + } + } /* 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, bfd_errmsg (bfd_get_error ())); done (1); - } /* if */ + } core_syms = (asymbol **) xmalloc (core_num_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, bfd_errmsg (bfd_get_error ())); 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", whoami, core_text_sect->_raw_size); done (1); - } /* if */ + } if (!bfd_get_section_contents (core_bfd, core_text_sect, core_text_space, 0, core_text_sect->_raw_size)) { bfd_perror ("bfd_get_section_contents"); free (core_text_space); core_text_space = 0; - } /* if */ + } if (!core_text_space) { 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) { return 0; - } /* if */ + } if (ignore_static_funcs && (sym->flags & BSF_LOCAL)) { DBG (AOUTDEBUG, printf ("[core_sym_class] %s: not a function\n", sym->name)); return 0; - } /* if */ + } bfd_get_symbol_info (core_bfd, sym, &syminfo); i = syminfo.type; @@ -126,7 +126,7 @@ DEFUN (core_sym_class, (sym), asymbol * sym) if (i == 'T') { return i; /* it's a global symbol */ - } /* if */ + } 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", sym->name, i)); return 0; - } /* if */ + } /* do some more filtering on static function-names: */ if (ignore_static_funcs) { return 0; - } /* if */ + } /* * Can't zero-length name or funny characters in name, where * `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') { return 0; - } /* if */ + } for (name = sym->name; *name; ++name) { if (*name == '.' || *name == '$') { return 0; - } /* if */ - } /* if */ + } + } /* * On systems where the C compiler adds an underscore to all * 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)) { return 0; - } /* if */ + } 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 : "", l, func_name ? func_name : "")); 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])) { continue; - } /* if */ + } ++symtab.len; - } /* for */ + } if (symtab.len == 0) { fprintf (stderr, "%s: file `%s' has no symbols\n", whoami, a_out_name); done (1); - } /* if */ + } /* the "+ 2" is for the sentinels: */ 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", core_syms[i]->value, core_syms[i]->name)); continue; - } /* if */ + } 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", symtab.limit->name, func_name)); continue; - } /* if */ - } /* if */ + } + } #endif symtab.limit->is_func = TRUE; @@ -303,7 +303,7 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd) if (class == 't') { symtab.limit->is_static = TRUE; - } /* if */ + } min_vma = MIN (symtab.limit->addr, min_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) { discard_underscores = 0; - } /* if */ + } DBG (AOUTDEBUG, printf ("[core_create_function_syms] %ld %s 0x%lx\n", (long) (symtab.limit - symtab.base), symtab.limit->name, symtab.limit->addr)); ++symtab.limit; - } /* for */ + } /* create sentinels: */ @@ -340,7 +340,7 @@ DEFUN (core_create_function_syms, (core_bfd), bfd * core_bfd) symtab.len = symtab.limit - symtab.base; 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)) { continue; - } /* if */ + } ++ltab.len; 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) { min_dist = offset - prev_offset; - } /* if */ + } prev_offset = offset; min_vma = MIN (vma, min_vma); max_vma = MAX (vma, max_vma); - } /* for */ + } 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)) { continue; - } /* if */ + } /* make name pointer a malloc'ed string: */ 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) { discard_underscores = 0; - } /* if */ + } DBG (AOUTDEBUG, printf ("[core_create_line_syms] %d %s 0x%lx\n", ltab.len, ltab.limit->name, ltab.limit->addr)); ++ltab.limit; - } /* for */ + } /* update sentinels: */ @@ -462,13 +462,13 @@ DEFUN (core_create_line_syms, (core_bfd), bfd * core_bfd) && min_vma <= sentinel->end_addr) { sentinel->end_addr = min_vma - 1; - } /* if */ + } sentinel = sym_lookup (&symtab, ~0); if (strcmp (sentinel->name, "") == 0 && max_vma >= sentinel->addr) { sentinel->addr = max_vma + 1; - } /* if */ + } /* copy in function symbols: */ 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", whoami, (long) (ltab.limit - ltab.base), ltab.len); done (1); - } /* if */ + } /* 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 && strcmp (sym->name, sym[-1].name) == 0); - } /* if */ - } /* for */ - -} /* core_create_line_syms */ + } + } -/*** end of core.c ***/ +} diff --git a/gprof/dummy.c b/gprof/dummy.c index 7fa2fd6ae5..db7d7496ad 100644 --- a/gprof/dummy.c +++ b/gprof/dummy.c @@ -13,6 +13,4 @@ DEFUN (find_call, (parent, p_lowpc, p_highpc), { fprintf (stderr, "%s: -c supported on this machine architecture\n", whoami); -} /* find_call */ - -/*** end of dummy.c ***/ +} diff --git a/gprof/gmon_io.c b/gprof/gmon_io.c index cec19736f0..82c3caa37a 100644 --- a/gprof/gmon_io.c +++ b/gprof/gmon_io.c @@ -23,7 +23,7 @@ int gmon_file_version = 0; /* 0 == old (non-versioned) file format */ bfd_vma DEFUN (get_vma, (abfd, addr), bfd * abfd AND bfd_byte * addr) { - switch (sizeof (bfd_vma)) + switch (sizeof (char*)) { case 4: 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); default: fprintf (stderr, "%s: bfd_vma has unexpected size of %ld bytes\n", - whoami, (long) sizeof (bfd_vma)); + whoami, (long) sizeof (char*)); done (1); - } /* switch */ -} /* get_vma */ + } +} /* @@ -43,7 +43,7 @@ DEFUN (get_vma, (abfd, addr), bfd * abfd AND bfd_byte * addr) void 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: 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; default: fprintf (stderr, "%s: bfd_vma has unexpected size of %ld bytes\n", - whoami, (long) sizeof (bfd_vma)); + whoami, (long) sizeof (char*)); done (1); - } /* switch */ -} /* put_vma */ + } +} void @@ -80,14 +80,14 @@ DEFUN (gmon_out_read, (filename), const char *filename) { perror (filename); done (1); - } /* if */ - } /* if */ + } + } if (fread (&ghdr, sizeof (struct gmon_hdr), 1, ifp) != 1) { fprintf (stderr, "%s: file too short to be a gmon file\n", filename); done (1); - } /* if */ + } if ((file_format == FF_MAGIC) || (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", whoami, filename); done (1); - } /* if */ + } /* 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", whoami, filename, gmon_file_version); done (1); - } /* if */ + } /* read in all the records: */ 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", whoami, filename, tag); done (1); - } /* switch */ - } /* while */ + } + } } else if (file_format == FF_AUTO || file_format == FF_BSD) { @@ -172,14 +172,14 @@ DEFUN (gmon_out_read, (filename), const char *filename) { perror (filename); done (1); - } /* if */ + } if (fread (&raw, 1, sizeof (struct raw_phdr), ifp) != sizeof (struct raw_phdr)) { fprintf (stderr, "%s: file too short to be a gmon file\n", filename); done (1); - } /* if */ + } 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.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", filename); done (1); - } /* if */ + } h = tmp; s_lowpc = (bfd_vma) h.low_pc; s_highpc = (bfd_vma) h.high_pc; @@ -210,14 +210,14 @@ DEFUN (gmon_out_read, (filename), const char *filename) if (hist_num_bins) { ++nhist; - } /* if */ + } if (!hist_sample) { hist_sample = (int *) xmalloc (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) { @@ -227,9 +227,9 @@ DEFUN (gmon_out_read, (filename), const char *filename) "%s: unexpected EOF after reading %d/%d bins\n", whoami, --i, hist_num_bins); done (1); - } /* if */ + } hist_sample[i] += bfd_get_16 (core_bfd, (bfd_byte *) raw_bin_count); - } /* for */ + } /* * The rest of the file consists of a bunch of @@ -246,7 +246,7 @@ DEFUN (gmon_out_read, (filename), const char *filename) from_pc, self_pc, count)); /* add this arc: */ cg_tally (from_pc, self_pc, count); - } /* while */ + } fclose (ifp); if (hz == HZ_WRONG) @@ -260,15 +260,15 @@ DEFUN (gmon_out_read, (filename), const char *filename) { hz = 1; fprintf (stderr, "time is in ticks, not seconds\n"); - } /* if */ - } /* if */ + } + } } else { fprintf (stderr, "%s: don't know how to deal with file format %d\n", whoami, file_format); done (1); - } /* if */ + } 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", nbbs, nbbs == 1 ? "" : "s"); first_output = FALSE; - } /* if */ -} /* gmon_out_read */ + } +} void @@ -296,7 +296,7 @@ DEFUN (gmon_out_write, (filename), const char *filename) { perror (filename); done (1); - } /* if */ + } if (file_format == FF_AUTO || file_format == FF_MAGIC) { @@ -308,25 +308,25 @@ DEFUN (gmon_out_write, (filename), const char *filename) { perror (filename); done (1); - } /* if */ + } /* write execution time histogram if we have one: */ if (gmon_input & INPUT_HISTOGRAM) { hist_write_hist (ofp, filename); - } /* if */ + } /* write call graph arcs if we have any: */ if (gmon_input & INPUT_CALL_GRAPH) { cg_write_arcs (ofp, filename); - } /* if */ + } /* write basic-block info if we have it: */ if (gmon_input & INPUT_BB_COUNTS) { bb_write_blocks (ofp, filename); - } /* if */ + } } else if (file_format == FF_BSD) { @@ -350,7 +350,7 @@ DEFUN (gmon_out_write, (filename), const char *filename) { perror (filename); done (1); - } /* if */ + } /* dump the samples: */ @@ -361,8 +361,8 @@ DEFUN (gmon_out_write, (filename), const char *filename) { perror (filename); done (1); - } /* if */ - } /* for */ + } + } /* dump the normalized raw arc information: */ @@ -379,12 +379,12 @@ DEFUN (gmon_out_write, (filename), const char *filename) { perror (filename); done (1); - } /* if */ + } DBG (SAMPLEDEBUG, printf ("[dumpsum] frompc 0x%lx selfpc 0x%lx count %d\n", arc->parent->addr, arc->child->addr, arc->count)); - } /* for */ - } /* for */ + } + } fclose (ofp); } 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", whoami, file_format); done (1); - } /* if */ -} /* gmon_out_write */ - -/*** gmon_out.c ***/ + } +} diff --git a/gprof/gmon_out.h b/gprof/gmon_out.h index d0d8ec54fd..2144fb5954 100644 --- a/gprof/gmon_out.h +++ b/gprof/gmon_out.h @@ -27,25 +27,25 @@ struct gmon_hdr /* types of records in this file: */ 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; struct gmon_hist_hdr { - char low_pc[sizeof (bfd_vma)]; /* base pc address of sample buffer */ - char high_pc[sizeof (bfd_vma)]; /* max pc address of sampled buffer */ - char hist_size[4]; /* size of sample buffer */ - char prof_rate[4]; /* profiling clock rate */ - char dimen[15]; /* phys. dim., usually "seconds" */ - char dimen_abbrev; /* usually 's' for "seconds" */ + char low_pc[sizeof (char*)]; /* base pc address of sample buffer */ + char high_pc[sizeof (char*)]; /* max pc address of sampled buffer */ + char hist_size[4]; /* size of sample buffer */ + char prof_rate[4]; /* profiling clock rate */ + char dimen[15]; /* phys. dim., usually "seconds" */ + char dimen_abbrev; /* usually 's' for "seconds" */ }; struct gmon_cg_arc_record { - char from_pc[sizeof (bfd_vma)]; /* address within caller's body */ - char self_pc[sizeof (bfd_vma)]; /* address within callee's body */ - char count[4]; /* number of arc traversals */ + char from_pc[sizeof (char*)]; /* address within caller's body */ + char self_pc[sizeof (char*)]; /* address within callee's body */ + char count[4]; /* number of arc traversals */ }; #endif /* gmon_out_h */ diff --git a/gprof/gprof.c b/gprof/gprof.c index 1e3226fb8b..b54600b095 100644 --- a/gprof/gprof.c +++ b/gprof/gprof.c @@ -142,7 +142,7 @@ Usage: %s [-[abchilLsTvwxyz]] [-[ACeEfFJnNOpPqQZ][name]] [-I dirs]\n\ [image-file] [profile-file...]\n", whoami); done (status); -} /* usage */ +} int @@ -169,7 +169,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) if (optarg) { sym_id_add (optarg, INCL_ANNO); - } /* if */ + } output_style |= STYLE_ANNOTATED_SOURCE; user_specified |= STYLE_ANNOTATED_SOURCE; break; @@ -187,7 +187,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) if (optarg) { sym_id_add (optarg, INCL_EXEC); - } /* if */ + } output_style |= STYLE_EXEC_COUNTS; user_specified |= STYLE_EXEC_COUNTS; break; @@ -200,7 +200,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) else { debug_level = ~0; - } /* if */ + } DBG (ANYDEBUG, printf ("[main] debug-level=0x%x\n", debug_level)); #ifndef DEBUG printf ("%s: debugging not supported; -d ignored\n", whoami); @@ -240,7 +240,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) else { output_style &= ~STYLE_ANNOTATED_SOURCE; - } /* if */ + } user_specified |= STYLE_ANNOTATED_SOURCE; break; case 'k': @@ -280,13 +280,13 @@ DEFUN (main, (argc, argv), int argc AND char **argv) fprintf (stderr, "%s: unknown file format %s\n", optarg, whoami); done (1); - } /* switch */ + } break; case 'p': if (optarg) { sym_id_add (optarg, INCL_FLAT); - } /* if */ + } output_style |= STYLE_FLAT_PROFILE; user_specified |= STYLE_FLAT_PROFILE; break; @@ -299,7 +299,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) else { output_style &= ~STYLE_FLAT_PROFILE; - } /* if */ + } user_specified |= STYLE_FLAT_PROFILE; break; case 'q': @@ -312,8 +312,8 @@ DEFUN (main, (argc, argv), int argc AND char **argv) else { sym_id_add (optarg, INCL_GRAPH); - } /* if */ - } /* if */ + } + } output_style |= STYLE_CALL_GRAPH; user_specified |= STYLE_CALL_GRAPH; break; @@ -327,13 +327,13 @@ DEFUN (main, (argc, argv), int argc AND char **argv) else { sym_id_add (optarg, EXCL_GRAPH); - } /* if */ + } output_style |= STYLE_CALL_GRAPH; } else { output_style &= ~STYLE_CALL_GRAPH; - } /* if */ + } user_specified |= STYLE_CALL_GRAPH; break; case 's': @@ -345,7 +345,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) if (bb_table_length < 0) { bb_table_length = 0; - } /* if */ + } break; case 'T': bsd_style_output = TRUE; @@ -358,7 +358,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) if (output_width < 1) { output_width = 1; - } /* if */ + } break; case 'x': bb_annotate_all_lines = TRUE; @@ -378,29 +378,29 @@ DEFUN (main, (argc, argv), int argc AND char **argv) else { output_style &= ~STYLE_EXEC_COUNTS; - } /* if */ + } user_specified |= STYLE_ANNOTATED_SOURCE; break; default: usage (stderr, 1); - } /* switch */ - } /* while */ + } + } /* append value of GPROF_PATH to source search list if set: */ str = getenv ("GPROF_PATH"); if (str) { search_list_append (&src_search_list, str); - } /* if */ + } if (optind < argc) { a_out_name = argv[optind++]; - } /* if */ + } if (optind < argc) { gmon_name = argv[optind++]; - } /* if */ + } /* * Turn off default functions: @@ -412,7 +412,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) #ifdef __osf__ sym_id_add (*sp, EXCL_FLAT); #endif - } /* for */ + } /* * 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++) { sym_id_add (*sp, EXCL_FLAT); - } /* for */ - } /* if */ + } + } /* * Read symbol table from core file: @@ -438,7 +438,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) if (ignore_direct_calls) { core_get_text_space (core_bfd); - } /* if */ + } /* * Create symbols from core image: @@ -450,7 +450,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) else { core_create_function_syms (core_bfd); - } /* if */ + } /* * Translate sym specs into syms: @@ -469,7 +469,7 @@ DEFUN (main, (argc, argv), int argc AND char **argv) if (optind < argc) { gmon_name = argv[optind]; - } /* if */ + } } while (optind++ < argc); #else @@ -490,10 +490,10 @@ DEFUN (main, (argc, argv), int argc AND char **argv) if (optind < argc) { gmon_name = argv[optind]; - } /* if */ + } } while (optind++ < argc); - } /* if */ + } /* * 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 { output_style = STYLE_EXEC_COUNTS; - } /* if */ + } output_style &= ~user_specified; - } /* if */ + } /* * 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) { gmon_out_write (GMONSUM); - } /* if */ + } if (gmon_input & INPUT_HISTOGRAM) { hist_assign_samples (); - } /* if */ + } if (gmon_input & INPUT_CALL_GRAPH) { cg = cg_assemble (); - } /* if */ + } /* 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); done (1); - } /* if */ + } if ((output_style & STYLE_CALL_GRAPH) && !(gmon_input & INPUT_CALL_GRAPH)) { fprintf (stderr, "%s: gmon.out file is missing call-graph data\n", whoami); done (1); - } /* if */ + } /* output whatever user whishes to see: */ if (cg && (output_style & STYLE_CALL_GRAPH) && bsd_style_output) { cg_print (cg); /* print the dynamic profile */ - } /* if */ + } if (output_style & STYLE_FLAT_PROFILE) { hist_print (); /* print the flat profile */ - } /* if */ + } if (cg && (output_style & STYLE_CALL_GRAPH)) { if (!bsd_style_output) { cg_print (cg); /* print the dynamic profile */ - } /* if */ + } cg_print_index (); - } /* if */ + } if (output_style & STYLE_EXEC_COUNTS) { print_exec_counts (); - } /* if */ + } if (output_style & STYLE_ANNOTATED_SOURCE) { print_annotated_source (); - } /* if */ + } return 0; } diff --git a/gprof/hertz.c b/gprof/hertz.c index 5391041188..9dbc89ffc6 100644 --- a/gprof/hertz.c +++ b/gprof/hertz.c @@ -41,7 +41,7 @@ hertz () if (tim.it_interval.tv_usec < 2) { return HZ_WRONG; - } /* if */ + } return 1000000 / tim.it_interval.tv_usec; #endif -} /* hertz */ +} diff --git a/gprof/hist.c b/gprof/hist.c index 2b015a4102..69cc3ea004 100644 --- a/gprof/hist.c +++ b/gprof/hist.c @@ -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", whoami, filename); done (1); - } /* if */ + } 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); @@ -122,7 +122,7 @@ DEFUN (hist_read_rec, (ifp, filename), FILE * ifp AND const char *filename) highpc = (bfd_vma) n_highpc / sizeof (UNIT); hist_num_bins = ncnt; hz = profrate; - } /* if */ + } DBG (SAMPLEDEBUG, 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", whoami, filename); done (1); - } /* if */ + } if (!hist_sample) { hist_sample = (int *) xmalloc (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) { @@ -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", whoami, filename, i, hist_num_bins); done (1); - } /* if */ + } 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); done (1); - } /* if */ + } 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); 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", sym->hist.scaled_addr, sym->aligned_addr + UNITS_TO_CODE)); sym->aligned_addr += UNITS_TO_CODE; - } /* if */ + } #endif /* OFFSET_TO_CODE > 0 */ - } /* for */ -} /* scale_and_align_entries */ + } +} /* @@ -296,7 +296,7 @@ DEFUN_VOID (hist_assign_samples) if (!bin_count) { continue; - } /* if */ + } bin_low_pc = lowpc + (bfd_vma) (hist_scale * i); bin_high_pc = lowpc + (bfd_vma) (hist_scale * (i + 1)); time = bin_count; @@ -320,7 +320,7 @@ DEFUN_VOID (hist_assign_samples) if (bin_high_pc < sym_low_pc) { break; - } /* if */ + } /* * If low end of bin is above high end of symbol, go for * next symbol. @@ -328,7 +328,7 @@ DEFUN_VOID (hist_assign_samples) if (bin_low_pc >= sym_high_pc) { continue; - } /* if */ + } overlap = MIN (bin_high_pc, sym_high_pc) - MAX (bin_low_pc, sym_low_pc); if (overlap > 0) @@ -355,13 +355,13 @@ DEFUN_VOID (hist_assign_samples) else { total_time -= credit; - } /* if */ - } /* if */ - } /* if */ - } /* for */ + } + } + } + } DBG (SAMPLEDEBUG, printf ("[assign_samples] total_time %f\n", total_time)); -} /* hist_assign_samples */ +} /* @@ -382,26 +382,26 @@ DEFUN (print_header, (prefix), const char prefix) { printf (" for %.2f%% of %.2f %s\n\n", 100.0 / total_time, total_time / hz, hist_dimension); - } /* if */ + } } else { printf ("\nEach sample counts as %g %s.\n", 1.0 / hz, hist_dimension); - } /* if */ + } if (total_time <= 0.0) { printf (" no time accumulated\n\n"); /* this doesn't hurt since all the numerators will be zero: */ total_time = 1.0; - } /* if */ + } printf ("%5.5s %10.10s %8.8s %8.8s %8.8s %8.8s %-8.8s\n", "% ", "cumulative", "self ", "", "self ", "total ", ""); printf ("%5.5s %9.9s %8.8s %8.8s %8.8s %8.8s %-8.8s\n", "time", hist_dimension, hist_dimension, "calls", unit, unit, "name"); -} /* print_header */ +} 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) { return; - } /* if */ + } accum_time += sym->hist.time; 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", total_time > 0.0 ? 100 * sym->hist.time / total_time : 0.0, accum_time / hz, sym->hist.time / hz); - } /* if */ + } if (sym->ncalls) { printf (" %8d %8.2f %8.2f ", @@ -434,7 +434,7 @@ DEFUN (print_line, (sym, scale), Sym * sym AND double scale) else { printf (" %8.8s %8.8s %8.8s ", "", "", ""); - } /* if */ + } if (bsd_style_output) { print_name (sym); @@ -442,9 +442,9 @@ DEFUN (print_line, (sym, scale), Sym * sym AND double scale) else { print_name_only (sym); - } /* if */ + } 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) { return 1; - } /* if */ + } if (time_diff < 0.0) { return -1; - } /* if */ + } call_diff = right->ncalls - left->ncalls; if (call_diff > 0) { return 1; - } /* if */ + } if (call_diff < 0) { return -1; - } /* if */ + } return strcmp (left->name, right->name); -} /* cmp_time */ +} /* @@ -502,7 +502,7 @@ DEFUN_VOID (hist_print) else { printf ("\f\n"); - } /* if */ + } accum_time = 0.0; if (bsd_style_output) @@ -511,12 +511,12 @@ DEFUN_VOID (hist_print) { printf ("\n\n\nflat profile:\n"); flat_blurb (stdout); - } /* if */ + } } else { printf ("Flat profile:\n"); - } /* if */ + } /* * Sort the symbol table by time (call-count and name as secondary * and tertiary keys): @@ -525,7 +525,7 @@ DEFUN_VOID (hist_print) for (index = 0; index < symtab.len; ++index) { time_sorted_syms[index] = &symtab.base[index]; - } /* for */ + } qsort (time_sorted_syms, symtab.len, sizeof (Sym *), cmp_time); if (bsd_style_output) @@ -551,9 +551,9 @@ DEFUN_VOID (hist_print) { top_dog = sym; top_time = time; - } /* if */ - } /* if */ - } /* for */ + } + } + } if (top_dog && top_dog->ncalls && top_time > 0.0) { top_time /= hz; @@ -561,9 +561,9 @@ DEFUN_VOID (hist_print) && log_scale < sizeof (SItab) / sizeof (SItab[0]) - 1) { ++log_scale; - } /* while */ - } /* if */ - } /* if */ + } + } + } /* * 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))) { print_line (time_sorted_syms[index], SItab[log_scale].scale); - } /* if */ - } /* for */ + } + } free (time_sorted_syms); if (print_descriptions && !bsd_style_output) { flat_blurb (stdout); - } /* if */ -} /* hist_print */ - -/*** end of hist.c ***/ + } +} diff --git a/gprof/search_list.c b/gprof/search_list.c index e49cc8a6c0..d475dbf6a4 100644 --- a/gprof/search_list.c +++ b/gprof/search_list.c @@ -23,7 +23,7 @@ DEFUN (search_list_append, (list, paths), else { len = strlen (beg); - } /* if */ + } new_el = (Search_List_Elem *) xmalloc (sizeof (*new_el) + len); memcpy (new_el->path, beg, len); new_el->path[len] = '\0'; @@ -37,10 +37,8 @@ DEFUN (search_list_append, (list, paths), else { list->head = new_el; - } /* if */ + } list->tail = new_el; } while (colon); -} /* search_list_append */ - -/*** end of search_list.c ***/ +} diff --git a/gprof/source.c b/gprof/source.c index 1fb0e533c6..b0c6ecdb47 100644 --- a/gprof/source.c +++ b/gprof/source.c @@ -28,8 +28,8 @@ DEFUN (source_file_lookup_path, (path), const char *path) if (strcmp (path, sf->name) == 0) { break; - } /* if */ - } /* for */ + } + } if (!sf) { /* create a new source file descriptor: */ @@ -39,9 +39,9 @@ DEFUN (source_file_lookup_path, (path), const char *path) sf->name = strdup (path); sf->next = first_src_file; first_src_file = sf; - } /* if */ + } return sf; -} /* source_file_lookup_path */ +} Source_File * @@ -65,14 +65,14 @@ DEFUN (source_file_lookup_name, (filename), const char *filename) else { fname = sf->name; - } /* if */ + } if (strcmp (filename, fname) == 0) { break; - } /* if */ - } /* for */ + } + } return sf; -} /* source_file_lookup_name */ +} FILE * @@ -98,7 +98,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), if (sf->name[0] == '/') { sle = 0; /* don't use search list for absolute paths */ - } /* if */ + } name_only = 0; while (TRUE) { @@ -108,7 +108,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), if (ifp) { break; - } /* if */ + } if (!sle && !name_only) { 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: */ ++name_only; sle = src_search_list.head; - } /* if */ - } /* if */ + } + } if (sle) { strcpy (fname, sle->path); @@ -130,7 +130,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), else { strcat (fname, sf->name); - } /* if */ + } sle = sle->next; } else @@ -143,10 +143,10 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), else { perror (sf->name); - } /* if */ + } return 0; - } /* if */ - } /* while */ + } + } ofp = stdout; if (create_annotation_files) @@ -163,7 +163,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), else { filename = sf->name; - } /* if */ + } strcpy (fname, filename); strcat (fname, EXT_ANNO); @@ -172,8 +172,8 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), { perror (fname); return 0; - } /* if */ - } /* if */ + } + } /* * Print file names if output goes to stdout and there are @@ -188,7 +188,7 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), else { fputc ('\n', ofp); - } /* if */ + } if (first_output) { first_output = FALSE; @@ -196,9 +196,9 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), else { fprintf (ofp, "\f\n"); - } /* if */ + } fprintf (ofp, "*** File %s:\n", sf->name); - } /* if */ + } annotation = xmalloc (max_width + 1); line_num = 1; @@ -213,13 +213,11 @@ DEFUN (annotate_source, (sf, max_width, annote, arg), fputs (annotation, ofp); ++line_num; new_line = FALSE; - } /* if */ + } new_line = (buf[i] == '\n'); fputc (buf[i], ofp); - } /* for */ - } /* while */ + } + } free (annotation); return ofp; -} /* annotate_source */ - -/*** end of source.c ***/ +} diff --git a/gprof/sparc.c b/gprof/sparc.c index b78ef43a7e..b12420ae80 100644 --- a/gprof/sparc.c +++ b/gprof/sparc.c @@ -38,15 +38,15 @@ find_call (parent, p_lowpc, p_highpc) if (core_text_space == 0) { return; - } /* if */ + } if (p_lowpc < s_lowpc) { p_lowpc = s_lowpc; - } /* if */ + } if (p_highpc > s_highpc) { p_highpc = s_highpc; - } /* if */ + } DBG (CALLDEBUG, printf ("[find_call] %s: 0x%lx to 0x%lx\n", parent->name, p_lowpc, p_highpc)); for (instr = (unsigned int *) (p_lowpc + delta); @@ -73,13 +73,12 @@ find_call (parent, p_lowpc, p_highpc) /* a hit: */ arc_add (parent, child, 0); continue; - } /* if */ - } /* if */ + } + } /* * Something funny going on. */ DBG (CALLDEBUG, printf ("\tbut it's a botch\n")); - } /* if */ - } /* for */ -} /* find_call */ -/*** end of sparc.c ***/ + } + } +} diff --git a/gprof/sym_ids.c b/gprof/sym_ids.c index fdc958bb58..efee6ef30a 100644 --- a/gprof/sym_ids.c +++ b/gprof/sym_ids.c @@ -64,7 +64,7 @@ DEFUN (sym_id_add, (spec, which_table), id->next = id_list; id_list = id; -} /* sym_id_add */ +} /* @@ -94,8 +94,8 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym) if (!sym->file) { sym->file = &non_existent_file; - } /* if */ - } /* if */ + } + } spec = colon + 1; if (strlen (spec)) { @@ -106,8 +106,8 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym) else { sym->name = spec; - } /* if */ - } /* if */ + } + } } else if (strlen (spec)) { @@ -118,7 +118,7 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym) if (!sym->file) { sym->file = &non_existent_file; - } /* if */ + } } else if (isdigit (*spec)) { @@ -127,9 +127,9 @@ DEFUN (parse_spec, (spec, sym), char *spec AND Sym * sym) else if (strlen (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); *slash = '\0'; id->has_right = TRUE; - } /* if */ + } parse_spec (id->spec, &id->left.sym); #ifdef DEBUG @@ -167,7 +167,7 @@ DEFUN (parse_id, (id), struct sym_id *id) else { printf ("*"); - } /* if */ + } if (id->has_right) { printf ("/%s:", @@ -183,12 +183,12 @@ DEFUN (parse_id, (id), struct sym_id *id) else { printf ("*"); - } /* if */ - } /* if */ + } + } printf ("\n"); } #endif -} /* parse_id */ +} /* @@ -200,7 +200,7 @@ DEFUN (match, (pattern, sym), Sym * pattern AND Sym * sym) return (pattern->file ? pattern->file == sym->file : TRUE) && (pattern->line_num ? pattern->line_num == sym->line_num : TRUE) && (pattern->name ? strcmp (pattern->name, sym->name) == 0 : TRUE); -} /* match */ +} static void @@ -218,17 +218,17 @@ DEFUN (extend_match, (m, sym, tab, second_pass), /* link match into match's chain: */ tab->base[tab->len].next = m->first_match; m->first_match = &tab->base[tab->len]; - } /* if */ + } ++tab->len; - } /* if */ + } /* extend match to include this symbol: */ if (second_pass) { tab->base[m->prev_index].end_addr = sym->end_addr; - } /* if */ + } m->prev_match = sym; -} /* extend_match */ +} /* @@ -253,7 +253,7 @@ DEFUN_VOID (sym_id_parse) for (id = id_list; id; id = id->next) { parse_id (id); - } /* for */ + } /* first determine size of each table: */ @@ -264,13 +264,13 @@ DEFUN_VOID (sym_id_parse) if (match (&id->left.sym, sym)) { extend_match (&id->left, sym, &syms[id->which_table], FALSE); - } /* if */ + } if (id->has_right && match (&id->right.sym, sym)) { extend_match (&id->right, sym, &right_ids, FALSE); - } /* if */ - } /* for */ - } /* for */ + } + } + } /* 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->limit = tab->base + tab->len; tab->len = 0; - } /* if */ - } /* for */ + } + } if (right_ids.len) { right_ids.base = (Sym *) xmalloc (right_ids.len * sizeof (Sym)); right_ids.limit = right_ids.base + right_ids.len; right_ids.len = 0; - } /* if */ + } /* 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)) { extend_match (&id->left, sym, &syms[id->which_table], TRUE); - } /* if */ + } if (id->has_right && match (&id->right.sym, sym)) { extend_match (&id->right, sym, &right_ids, TRUE); - } /* if */ - } /* for */ - } /* for */ + } + } + } /* go through ids creating arcs as needed: */ @@ -328,10 +328,10 @@ DEFUN_VOID (sym_id_parse) right->end_addr, table_name[id->which_table])); arc_add (left, right, 0); - } /* for */ - } /* for */ - } /* if */ - } /* for */ + } + } + } + } /* 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", table_name[tab - &syms[0]])); symtab_finalize (tab); - } /* for */ -} /* sym_id_parse */ + } +} /* @@ -364,9 +364,7 @@ DEFUN (sym_id_arc_is_present, (symtab, from, to), && arc_lookup (sym, to)) { return TRUE; - } /* if */ - } /* for */ + } + } return FALSE; -} /* sym_id_arc_is_present */ - -/*** end of sym_ids.h ***/ +} diff --git a/gprof/symtab.c b/gprof/symtab.c index aab4ca269e..6fd48c3c8f 100644 --- a/gprof/symtab.c +++ b/gprof/symtab.c @@ -22,7 +22,7 @@ DEFUN (sym_init, (sym), Sym * sym) sym->cg.prop.fract = 0.0; sym->cg.prop.self = 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) { return -1; - } /* if */ + } if (left->is_func != right->is_func) { return right->is_func - left->is_func; - } /* if */ + } return left->is_static - right->is_static; -} /* cmp_addr */ +} void @@ -68,7 +68,7 @@ DEFUN (symtab_finalize, (tab), Sym_Table * tab) if (!tab->len) { return; - } /* if */ + } /* * 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->is_func ? 'F' : 'f'); printf (" (addr=%lx)\n", src->addr)); - } /* if */ + } } else { if (dst > tab->base && dst[-1].end_addr == 0) { dst[-1].end_addr = src->addr - 1; - } /* if */ + } /* retain sym only if it has a non-empty address range: */ if (!src->end_addr || src->addr <= src->end_addr) { *dst++ = *src; prev_addr = src->addr; - } /* if */ - } /* if */ - } /* if */ + } + } + } if (tab->len > 0 && dst[-1].end_addr == 0) { dst[-1].end_addr = core_text_sect->vma + core_text_sect->_raw_size - 1; - } /* if */ + } DBG (AOUTDEBUG | IDDEBUG, 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", (long) tab->base[j].addr, (long) tab->base[j].end_addr, tab->base[j].name); - } /* for */ + } ); -} /* symtab_finalize */ +} #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) { return &sym[mid]; - } /* if */ + } if (sym[mid].addr > address) { high = mid; @@ -187,11 +187,11 @@ DEFUN (dbg_sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address else { low = mid + 1; - } /* if */ - } /* for */ + } + } fprintf (stderr, "[sym_lookup] binary search fails???\n"); return 0; -} /* dbg_sym_lookup */ +} #endif /* DEBUG */ @@ -213,7 +213,7 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) if (!symtab->len) { return 0; - } /* if */ + } sym = symtab->base; 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", probes, symtab->len - 1)); return &sym[mid]; - } /* if */ - } /* if */ + } + } if (sym[mid].addr > address) { high = mid; @@ -245,8 +245,8 @@ DEFUN (sym_lookup, (symtab, address), Sym_Table * symtab AND bfd_vma address) else { low = mid + 1; - } /* if */ - } /* for */ + } + } if (sym[mid + 1].addr <= address) { 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", probes, symtab->len - 1)); return &sym[mid + 1]; - } /* if */ - } /* if */ + } + } return 0; -} /* sym_lookup */ - -/*** end of symtab.c ***/ +} diff --git a/gprof/tahoe.c b/gprof/tahoe.c index e02bbb02e8..967ea01957 100644 --- a/gprof/tahoe.c +++ b/gprof/tahoe.c @@ -206,7 +206,7 @@ find_call (parent, p_lowpc, p_highpc) sym_init (&indirectchild); indirectchild.cg.prop.fract = 1.0; indirectchild.cg.cyc.head = &indirectchild; - } /* if */ + } if (textspace == 0) { diff --git a/gprof/utils.c b/gprof/utils.c index 19ea34b0ac..2402fe4ee6 100644 --- a/gprof/utils.c +++ b/gprof/utils.c @@ -41,13 +41,13 @@ DEFUN (print_name_only, (self), Sym * self) if (name[0] == '_' && name[1] && discard_underscores) { name++; - } /* if */ + } demangled = cplus_demangle (name, DMGL_ANSI | DMGL_PARAMS); if (demangled) { name = demangled; - } /* if */ - } /* if */ + } + } printf ("%s", name); size = strlen (name); if (line_granularity && self->file) @@ -63,21 +63,21 @@ DEFUN (print_name_only, (self), Sym * self) else { filename = self->file->name; - } /* if */ - } /* if */ + } + } sprintf (buf, " (%s:%d)", filename, self->line_num); printf (buf); size += strlen (buf); - } /* if */ + } if (demangled) { free (demangled); - } /* if */ + } DBG (DFNDEBUG, printf ("{%d} ", self->cg.top_order)); DBG (PROPDEBUG, printf ("%4.0f%% ", 100.0 * self->cg.prop.fract)); - } /* if */ + } return size; -} /* print_name_only */ +} void @@ -88,7 +88,7 @@ DEFUN (print_name, (self), Sym * self) if (self->cg.cyc.num != 0) { printf (" ", self->cg.cyc.num); - } /* if */ + } if (self->cg.index != 0) { if (self->cg.print_flag) @@ -98,8 +98,6 @@ DEFUN (print_name, (self), Sym * self) else { printf (" (%d)", self->cg.index); - } /* if */ - } /* if */ -} /* print_name */ - -/*** end of utils.c ***/ + } + } +} diff --git a/gprof/vax.c b/gprof/vax.c index 8b706999a9..9d7fa835d0 100644 --- a/gprof/vax.c +++ b/gprof/vax.c @@ -208,7 +208,7 @@ find_call (parent, p_lowpc, p_highpc) sym_init (&indirectchild); indirectchild.cg.prop.fract = 1.0; indirectchild.cg.cyc.head = &indirectchild; - } /* if */ + } if (core_text_space == 0) { -- 2.34.1