Home | History | Annotate | Download | only in gprof
      1 /* symtab.h
      2 
      3    Copyright (C) 2000-2014 Free Software Foundation, Inc.
      4 
      5    This file is part of GNU Binutils.
      6 
      7    This program is free software; you can redistribute it and/or modify
      8    it under the terms of the GNU General Public License as published by
      9    the Free Software Foundation; either version 3 of the License, or
     10    (at your option) any later version.
     11 
     12    This program is distributed in the hope that it will be useful,
     13    but WITHOUT ANY WARRANTY; without even the implied warranty of
     14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15    GNU General Public License for more details.
     16 
     17    You should have received a copy of the GNU General Public License
     18    along with this program; if not, write to the Free Software
     19    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     20    MA 02110-1301, USA.  */
     21 
     22 #ifndef symtab_h
     24 #define symtab_h
     25 
     26 /* For a profile to be intelligible to a human user, it is necessary
     27    to map code-addresses into source-code information.  Source-code
     28    information can be any combination of: (i) function-name, (ii)
     29    source file-name, and (iii) source line number.
     30 
     31    The symbol table is used to map addresses into source-code
     32    information.  */
     33 
     34 #define NBBS 10
     35 
     36 /* Symbol-entry.  For each external in the specified file we gather
     37    its address, the number of calls and compute its share of cpu time.  */
     38 typedef struct sym
     39   {
     40     /* Common information:
     41 
     42        In the symbol-table, fields ADDR and FUNC_NAME are guaranteed
     43        to contain valid information.  FILE may be 0, if unknown and
     44        LINE_NUM maybe 0 if unknown.  */
     45 
     46     bfd_vma addr;		/* Address of entry point.  */
     47     bfd_vma end_addr;		/* End-address.  */
     48     const char *name;		/* Name of function this sym is from.  */
     49     Source_File *file;		/* Source file symbol comes from.  */
     50     int line_num;		/* Source line number.  */
     51     unsigned int		/* Boolean fields:  */
     52       is_func:1,		/*  Is this a function entry point?  */
     53       is_static:1,		/*  Is this a local (static) symbol?  */
     54       is_bb_head:1,		/*  Is this the head of a basic-blk?  */
     55       mapped:1,			/*  This symbol was mapped to another name.  */
     56       has_been_placed:1;	/*  Have we placed this symbol?  */
     57     unsigned long ncalls;	/* How many times executed  */
     58     int nuses;			/* How many times this symbol appears in
     59 				   a particular context.  */
     60     bfd_vma bb_addr[NBBS];	/* Address of basic-block start.  */
     61     unsigned long bb_calls[NBBS];/* How many times basic-block was called.  */
     62     struct sym *next;		/* For building chains of syms.  */
     63     struct sym *prev;		/* For building chains of syms.  */
     64 
     65     /* Profile specific information:  */
     66 
     67     /* Histogram specific information:  */
     68     struct
     69       {
     70 	double time;		/* (Weighted) ticks in this routine.  */
     71 	bfd_vma scaled_addr;	/* Scaled entry point.  */
     72       }
     73     hist;
     74 
     75     /* Call-graph specific information:  */
     76     struct
     77       {
     78 	unsigned long self_calls; /* How many calls to self.  */
     79 	double child_time;	/* Cumulative ticks in children.  */
     80 	int index;		/* Index in the graph list.  */
     81 	int top_order;		/* Graph call chain top-sort order.  */
     82 	bfd_boolean print_flag;	/* Should this be printed?  */
     83 	struct
     84 	  {
     85 	    double fract;	/* What % of time propagates.  */
     86 	    double self;	/* How much self time propagates.  */
     87 	    double child;	/* How much child time propagates.  */
     88 	  }
     89 	prop;
     90 	struct
     91 	  {
     92 	    int num;		/* Internal number of cycle on.  */
     93 	    struct sym *head;	/* Head of cycle.  */
     94 	    struct sym *next;	/* Next member of cycle.  */
     95 	  }
     96 	cyc;
     97 	struct arc *parents;	/* List of caller arcs.  */
     98 	struct arc *children;	/* List of callee arcs.  */
     99       }
    100     cg;
    101   }
    102 Sym;
    103 
    104 /* Symbol-tables are always assumed to be sorted
    105    in increasing order of addresses.  */
    106 typedef struct
    107   {
    108     unsigned int len;		/* # of symbols in this table.  */
    109     Sym *base;			/* First element in symbol table.  */
    110     Sym *limit;			/* Limit = base + len.  */
    111   }
    112 Sym_Table;
    113 
    114 extern Sym_Table symtab;	/* The symbol table.  */
    115 
    116 extern void sym_init        (Sym *);
    117 extern void symtab_finalize (Sym_Table *);
    118 #ifdef DEBUG
    119 extern Sym *dbg_sym_lookup  (Sym_Table *, bfd_vma);
    120 #endif
    121 extern Sym *sym_lookup      (Sym_Table *, bfd_vma);
    122 extern void find_call       (Sym *, bfd_vma, bfd_vma);
    123 
    124 #endif /* symtab_h */
    125