2004-05-05 Andrew Cagney <cagney@redhat.com>
[deliverable/binutils-gdb.git] / gprof / call_graph.c
index ac442cbb562fce3a7157c7d27f0a4b85237a373e..e798a0e18975890298a70f06121d572ce76dbe9b 100644 (file)
@@ -1,6 +1,6 @@
 /* call_graph.c  -  Create call graphs.
 
-   Copyright (C) 2000  Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
 
    This file is part of GNU Binutils.
 
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
    02111-1307, USA.  */
 \f
+#include "gprof.h"
+#include "search_list.h"
+#include "source.h"
+#include "symtab.h"
 #include "cg_arcs.h"
 #include "call_graph.h"
 #include "corefile.h"
 #include "gmon_io.h"
 #include "gmon_out.h"
-#include "symtab.h"
 #include "sym_ids.h"
 
-extern void
-DEFUN (cg_tally, (from_pc, self_pc, count),
-       bfd_vma from_pc AND bfd_vma self_pc AND unsigned long count)
+void
+cg_tally (from_pc, self_pc, count)
+     bfd_vma from_pc;
+     bfd_vma self_pc;
+     unsigned long count;
 {
   Sym *parent;
   Sym *child;
@@ -46,7 +51,7 @@ DEFUN (cg_tally, (from_pc, self_pc, count),
      line number in the calling routing, but the child should always
      point to a function entry point, so we back up in the symbol
      table until we find it.
-   
+
      For normal profiling, is_func will be set on all symbols, so this
      code will do nothing.  */
   while (child >= symtab.base && ! child->is_func)
@@ -75,25 +80,26 @@ 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)
+cg_read_rec (ifp, filename)
+     FILE *ifp;
+     const char *filename;
 {
   bfd_vma from_pc, self_pc;
-  struct gmon_cg_arc_record arc;
-  unsigned long count;
+  unsigned int count;
 
-  if (fread (&arc, sizeof (arc), 1, ifp) != 1)
+  if (gmon_io_read_vma (ifp, &from_pc)
+      || gmon_io_read_vma (ifp, &self_pc)
+      || gmon_io_read_32 (ifp, &count))
     {
       fprintf (stderr, _("%s: %s: unexpected end of file\n"),
               whoami, filename);
       done (1);
     }
-  
-  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 %lu\n",
-              (unsigned long) from_pc, (unsigned long) self_pc, count));
+              (unsigned long) from_pc, (unsigned long) self_pc,
+              (unsigned long) count));
   /* Add this arc:  */
   cg_tally (from_pc, self_pc, count);
 }
@@ -103,10 +109,10 @@ 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)
+cg_write_arcs (ofp, filename)
+     FILE *ofp;
+     const char *filename;
 {
-  const unsigned char tag = GMON_TAG_CG_ARC;
-  struct gmon_cg_arc_record raw_arc;
   Arc *arc;
   Sym *sym;
 
@@ -114,11 +120,10 @@ DEFUN (cg_write_arcs, (ofp, filename), FILE * ofp AND const char *filename)
     {
       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)
+         if (gmon_io_write_8 (ofp, GMON_TAG_CG_ARC)
+             || gmon_io_write_vma (ofp, arc->parent->addr)
+             || gmon_io_write_vma (ofp, arc->child->addr)
+             || gmon_io_write_32 (ofp, arc->count))
            {
              perror (filename);
              done (1);
This page took 0.024193 seconds and 4 git commands to generate.