diff options
author | Ken Raeburn <raeburn@cygnus> | 1995-02-08 02:35:44 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@cygnus> | 1995-02-08 02:35:44 +0000 |
commit | 12516a373c27abe4516c2a3c84cfe9d94f02e18f (patch) | |
tree | 20c1b81fb9d0ec20120f35bb71eb436f652788c8 /gprof/call_graph.c | |
parent | 28860f46fa46ce73225d72ad6a0f72739ca8295c (diff) | |
download | gdb-12516a373c27abe4516c2a3c84cfe9d94f02e18f.zip gdb-12516a373c27abe4516c2a3c84cfe9d94f02e18f.tar.gz gdb-12516a373c27abe4516c2a3c84cfe9d94f02e18f.tar.bz2 |
ran "indent -gnu"; have not fixed block comment style
Diffstat (limited to 'gprof/call_graph.c')
-rw-r--r-- | gprof/call_graph.c | 119 |
1 files changed, 61 insertions, 58 deletions
diff --git a/gprof/call_graph.c b/gprof/call_graph.c index bba8b8c..bd2a471 100644 --- a/gprof/call_graph.c +++ b/gprof/call_graph.c @@ -7,30 +7,30 @@ #include "sym_ids.h" extern void -DEFUN(cg_tally, (from_pc, self_pc, count), - bfd_vma from_pc AND bfd_vma self_pc AND int count) +DEFUN (cg_tally, (from_pc, self_pc, count), + bfd_vma from_pc AND bfd_vma self_pc AND int count) { - Sym *parent; - Sym *child; + Sym *parent; + Sym *child; - parent = sym_lookup(&symtab, from_pc); - child = sym_lookup(&symtab, self_pc); + parent = sym_lookup (&symtab, from_pc); + child = sym_lookup (&symtab, self_pc); - /* - * Keep arc if it is on INCL_ARCS table or if the INCL_ARCS table - * is empty and it is not in the EXCL_ARCS table. - */ - if (sym_id_arc_is_present(&syms[INCL_ARCS], parent, child) - || (syms[INCL_ARCS].len == 0 - && !sym_id_arc_is_present(&syms[EXCL_ARCS], parent, child))) + /* + * Keep arc if it is on INCL_ARCS table or if the INCL_ARCS table + * is empty and it is not in the EXCL_ARCS table. + */ + if (sym_id_arc_is_present (&syms[INCL_ARCS], parent, child) + || (syms[INCL_ARCS].len == 0 + && !sym_id_arc_is_present (&syms[EXCL_ARCS], parent, child))) { - child->ncalls += count; - DBG(TALLYDEBUG, - printf("[cg_tally] arc from %s to %s traversed %d times\n", + child->ncalls += count; + DBG (TALLYDEBUG, + 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 */ + arc_add (parent, child, count); + } /* if */ +} /* cg_tally */ /* @@ -40,26 +40,27 @@ DEFUN(cg_tally, (from_pc, self_pc, count), * for formatting error-messages only. */ void -DEFUN(cg_read_rec, (ifp, filename), FILE *ifp AND CONST char *filename) +DEFUN (cg_read_rec, (ifp, filename), FILE * ifp AND CONST char *filename) { - bfd_vma from_pc, self_pc; - struct gmon_cg_arc_record arc; - int count; + bfd_vma from_pc, self_pc; + struct gmon_cg_arc_record arc; + int count; - if (fread(&arc, sizeof(arc), 1, ifp) != 1) { - 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); - DBG(SAMPLEDEBUG, - printf("[cg_read_rec] frompc 0x%lx selfpc 0x%lx count %d\n", + if (fread (&arc, sizeof (arc), 1, ifp) != 1) + { + 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); + DBG (SAMPLEDEBUG, + printf ("[cg_read_rec] frompc 0x%lx selfpc 0x%lx count %d\n", from_pc, self_pc, count)); - /* add this arc: */ - cg_tally(from_pc, self_pc, count); -} /* cg_read_rec */ + /* add this arc: */ + cg_tally (from_pc, self_pc, count); +} /* cg_read_rec */ /* @@ -68,29 +69,31 @@ DEFUN(cg_read_rec, (ifp, filename), FILE *ifp AND CONST char *filename) * only. */ void -DEFUN(cg_write_arcs, (ofp, filename), FILE *ofp AND const char *filename) +DEFUN (cg_write_arcs, (ofp, filename), FILE * ofp AND const char *filename) { - const unsigned char tag = GMON_TAG_CG_ARC; - struct gmon_cg_arc_record raw_arc; - Arc *arc; - Sym *sym; + const unsigned char tag = GMON_TAG_CG_ARC; + struct gmon_cg_arc_record raw_arc; + Arc *arc; + Sym *sym; - for (sym = symtab.base; sym < symtab.limit; sym++) { - for (arc = sym->cg.children; arc; arc = arc->next_child) { - put_vma(core_bfd, arc->parent->addr, (bfd_byte*) raw_arc.from_pc); - put_vma(core_bfd, arc->child->addr, (bfd_byte*) raw_arc.self_pc); - bfd_put_32(core_bfd, arc->count, (bfd_byte*) raw_arc.count); - if (fwrite(&tag, sizeof(tag), 1, ofp) != 1 - || fwrite(&raw_arc, sizeof(raw_arc), 1, ofp) != 1) + for (sym = symtab.base; sym < symtab.limit; sym++) + { + for (arc = sym->cg.children; arc; arc = arc->next_child) + { + put_vma (core_bfd, arc->parent->addr, (bfd_byte *) raw_arc.from_pc); + put_vma (core_bfd, arc->child->addr, (bfd_byte *) raw_arc.self_pc); + bfd_put_32 (core_bfd, arc->count, (bfd_byte *) raw_arc.count); + if (fwrite (&tag, sizeof (tag), 1, ofp) != 1 + || fwrite (&raw_arc, sizeof (raw_arc), 1, ofp) != 1) { - 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 */ + 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 ***/ +/*** end of call_graph.c ***/ |