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