Commit | Line | Data |
---|---|---|
5489fcc3 KR |
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 | * Common information: | |
26 | * | |
27 | * In the symbol-table, fields ADDR and FUNC_NAME are guaranteed | |
28 | * to contain valid information. FILE may be 0, if unknown and | |
29 | * LINE_NUM maybe 0 if unknown. | |
30 | */ | |
31 | bfd_vma addr; /* address of entry point */ | |
32 | bfd_vma end_addr; /* end-address */ | |
33 | const char *name; /* name of function this sym is from */ | |
34 | Source_File *file; /* source file symbol comes from */ | |
35 | int line_num; /* source line number */ | |
36 | unsigned int is_func : 1, /* is this a function entry point? */ | |
37 | is_static : 1, /* is this a local (static) symbol? */ | |
38 | is_bb_head : 1; /* is this the head of a basic-blk? */ | |
39 | int ncalls; /* how many times executed */ | |
40 | struct sym *next; /* for building chains of syms */ | |
41 | ||
42 | /* profile-specific information: */ | |
43 | ||
44 | /* histogram specific info: */ | |
45 | struct { | |
46 | double time; /* (weighted) ticks in this routine */ | |
47 | bfd_vma scaled_addr; /* scaled entry point */ | |
48 | } hist; | |
49 | ||
50 | /* call-graph specific info: */ | |
51 | struct { | |
52 | int self_calls; /* how many calls to self */ | |
53 | double child_time; /* cumulative ticks in children */ | |
54 | int index; /* index in the graph list */ | |
55 | int top_order; /* graph call chain top-sort order */ | |
56 | bool print_flag; /* should this be printed? */ | |
57 | struct { | |
58 | double fract; /* what % of time propagates */ | |
59 | double self; /* how much self time propagates */ | |
60 | double child; /* how much child time propagates */ | |
61 | } prop; | |
62 | struct { | |
63 | int num; /* internal number of cycle on */ | |
64 | struct sym *head; /* head of cycle */ | |
65 | struct sym *next; /* next member of cycle */ | |
66 | } cyc; | |
67 | struct arc *parents; /* list of caller arcs */ | |
68 | struct arc *children; /* list of callee arcs */ | |
69 | } cg; | |
70 | } Sym; | |
71 | ||
72 | /* | |
73 | * Symbol-tables are always assumed to be sorted in increasing order | |
74 | * of addresses: | |
75 | */ | |
76 | typedef struct { | |
77 | int len; /* # of symbols in this table */ | |
78 | Sym *base; /* first element in symbol table */ | |
79 | Sym *limit; /* limit = base + len */ | |
80 | } Sym_Table; | |
81 | ||
82 | extern Sym_Table symtab; /* the symbol table */ | |
83 | ||
84 | extern void sym_init PARAMS((Sym *sym)); | |
85 | extern void symtab_finalize PARAMS((Sym_Table *symtab)); | |
86 | extern Sym *sym_lookup PARAMS((Sym_Table *symtab, bfd_vma address)); | |
87 | ||
88 | #endif /* symtab_h */ |