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