Mon Mar 17 10:54:47 1997 David Mosberger-Tang <davidm@azstarnet.com>
[external/binutils.git] / gprof / symtab.h
1 #ifndef symtab_h
2 #define symtab_h
3
4 #include "bfd.h"
5 #include "gprof.h"
6
7 /*
8  * For a profile to be intelligible to a human user, it is necessary
9  * to map code-addresses into source-code information.  Source-code
10  * information can be any combination of: (i) function-name, (ii)
11  * source file-name, and (iii) source line number.
12  *
13  * The symbol table is used to map addresses into source-code
14  * information.
15  */
16
17 #include "source.h"
18
19 /*
20  * Symbol-entry.  For each external in the specified file we gather
21  * its address, the number of calls and compute its share of cpu time.
22  */
23 typedef struct sym
24   {
25     /*
26      * Common information:
27      *
28      * In the symbol-table, fields ADDR and FUNC_NAME are guaranteed
29      * to contain valid information.  FILE may be 0, if unknown and
30      * LINE_NUM maybe 0 if unknown.
31      */
32     bfd_vma addr;               /* address of entry point */
33     bfd_vma end_addr;           /* end-address */
34     const char *name;           /* name of function this sym is from */
35     Source_File *file;          /* source file symbol comes from */
36     int line_num;               /* source line number */
37     unsigned int is_func:1,     /* is this a function entry point? */
38       is_static:1,              /* is this a local (static) symbol? */
39       is_bb_head:1,             /* is this the head of a basic-blk? */
40       mapped:1,                 /* this symbol was mapped to another name */
41       has_been_placed:1;        /* have we placed this symbol?  */
42     int ncalls;                 /* how many times executed */
43     int nuses;                  /* how many times this symbol appears in
44                                    a particular context */
45     struct sym *next;           /* for building chains of syms */
46     struct sym *prev;           /* for building chains of syms */
47
48     /* profile-specific information: */
49
50     /* histogram specific info: */
51     struct
52       {
53         double time;            /* (weighted) ticks in this routine */
54         bfd_vma scaled_addr;    /* scaled entry point */
55       }
56     hist;
57
58     /* call-graph specific info: */
59     struct
60       {
61         int self_calls;         /* how many calls to self */
62         double child_time;      /* cumulative ticks in children */
63         int index;              /* index in the graph list */
64         int top_order;          /* graph call chain top-sort order */
65         bool print_flag;        /* should this be printed? */
66         struct
67           {
68             double fract;       /* what % of time propagates */
69             double self;        /* how much self time propagates */
70             double child;       /* how much child time propagates */
71           }
72         prop;
73         struct
74           {
75             int num;            /* internal number of cycle on */
76             struct sym *head;   /* head of cycle */
77             struct sym *next;   /* next member of cycle */
78           }
79         cyc;
80         struct arc *parents;    /* list of caller arcs */
81         struct arc *children;   /* list of callee arcs */
82       }
83     cg;
84   }
85 Sym;
86
87 /*
88  * Symbol-tables are always assumed to be sorted in increasing order
89  * of addresses:
90  */
91 typedef struct
92   {
93     int len;                    /* # of symbols in this table */
94     Sym *base;                  /* first element in symbol table */
95     Sym *limit;                 /* limit = base + len */
96   }
97 Sym_Table;
98
99 extern Sym_Table symtab;        /* the symbol table */
100
101 extern void sym_init PARAMS ((Sym * sym));
102 extern void symtab_finalize PARAMS ((Sym_Table * symtab));
103 extern Sym *sym_lookup PARAMS ((Sym_Table * symtab, bfd_vma address));
104
105 extern void find_call PARAMS ((Sym *, bfd_vma, bfd_vma));
106
107 #endif /* symtab_h */