Back to index

cell-binutils  2.17cvs20070401
symtab.h
Go to the documentation of this file.
00001 /* symtab.h
00002 
00003    Copyright 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
00004 
00005 This file is part of GNU Binutils.
00006 
00007 This program is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2 of the License, or
00010 (at your option) any later version.
00011 
00012 This program is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with this program; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
00020 
00021 #ifndef symtab_h
00022 #define symtab_h
00023 
00024 /* For a profile to be intelligible to a human user, it is necessary
00025    to map code-addresses into source-code information.  Source-code
00026    information can be any combination of: (i) function-name, (ii)
00027    source file-name, and (iii) source line number.
00028 
00029    The symbol table is used to map addresses into source-code
00030    information.  */
00031 
00032 #define NBBS 10
00033 
00034 /* Symbol-entry.  For each external in the specified file we gather
00035    its address, the number of calls and compute its share of cpu time.  */
00036 typedef struct sym
00037   {
00038     /* Common information:
00039 
00040        In the symbol-table, fields ADDR and FUNC_NAME are guaranteed
00041        to contain valid information.  FILE may be 0, if unknown and
00042        LINE_NUM maybe 0 if unknown.  */
00043 
00044     bfd_vma addr;           /* Address of entry point.  */
00045     bfd_vma end_addr;              /* End-address.  */
00046     const char *name;              /* Name of function this sym is from.  */
00047     Source_File *file;             /* Source file symbol comes from.  */
00048     int line_num;           /* Source line number.  */
00049     unsigned int            /* Boolean fields:  */
00050       is_func:1,            /*  Is this a function entry point?  */
00051       is_static:1,          /*  Is this a local (static) symbol?  */
00052       is_bb_head:1,         /*  Is this the head of a basic-blk?  */
00053       mapped:1,                    /*  This symbol was mapped to another name.  */
00054       has_been_placed:1;    /*  Have we placed this symbol?  */
00055     unsigned long ncalls;   /* How many times executed  */
00056     int nuses;                     /* How many times this symbol appears in
00057                                a particular context.  */
00058     bfd_vma bb_addr[NBBS];  /* Address of basic-block start.  */
00059     unsigned long bb_calls[NBBS];/* How many times basic-block was called.  */
00060     struct sym *next;              /* For building chains of syms.  */
00061     struct sym *prev;              /* For building chains of syms.  */
00062 
00063     /* Profile specific information:  */
00064 
00065     /* Histogram specific information:  */
00066     struct
00067       {
00068        double time;         /* (Weighted) ticks in this routine.  */
00069        bfd_vma scaled_addr; /* Scaled entry point.  */
00070       }
00071     hist;
00072 
00073     /* Call-graph specific information:  */
00074     struct
00075       {
00076        unsigned long self_calls; /* How many calls to self.  */
00077        double child_time;   /* Cumulative ticks in children.  */
00078        int index;           /* Index in the graph list.  */
00079        int top_order;              /* Graph call chain top-sort order.  */
00080        bfd_boolean print_flag;     /* Should this be printed?  */
00081        struct
00082          {
00083            double fract;    /* What % of time propagates.  */
00084            double self;     /* How much self time propagates.  */
00085            double child;    /* How much child time propagates.  */
00086          }
00087        prop;
00088        struct
00089          {
00090            int num;         /* Internal number of cycle on.  */
00091            struct sym *head;       /* Head of cycle.  */
00092            struct sym *next;       /* Next member of cycle.  */
00093          }
00094        cyc;
00095        struct arc *parents; /* List of caller arcs.  */
00096        struct arc *children;       /* List of callee arcs.  */
00097       }
00098     cg;
00099   }
00100 Sym;
00101 
00102 /* Symbol-tables are always assumed to be sorted
00103    in increasing order of addresses.  */
00104 typedef struct
00105   {
00106     unsigned int len;              /* # of symbols in this table.  */
00107     Sym *base;                     /* First element in symbol table.  */
00108     Sym *limit;                    /* Limit = base + len.  */
00109   }
00110 Sym_Table;
00111 
00112 extern Sym_Table symtab;    /* The symbol table.  */
00113 
00114 extern void sym_init        (Sym *);
00115 extern void symtab_finalize (Sym_Table *);
00116 #ifdef DEBUG
00117 extern Sym *dbg_sym_lookup  (Sym_Table *, bfd_vma);
00118 #endif
00119 extern Sym *sym_lookup      (Sym_Table *, bfd_vma);
00120 extern void find_call       (Sym *, bfd_vma, bfd_vma);
00121 
00122 #endif /* symtab_h */