Back to index

cell-binutils  2.17cvs20070401
pef-traceback.h
Go to the documentation of this file.
00001 /* PowerPC traceback table support for BFD.
00002    Copyright 1993, 1998, 1999, 2000, 2001, 2002, 2005
00003    Free Software Foundation, Inc.
00004 
00005    This file is part of BFD, the Binary File Descriptor library.
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 /* Originally written by Ira Ruben, 06/28/93 */
00022 
00023 /*  This is a compiler independent representation of the AIX Version 3 traceback table (in
00024     sys/debug.h), which occurs, usually, one per procedure (routine). The table is marked by
00025     a multiple of 4 32-bit word of zeroes in the instruction space. The traceback table is
00026     also referred to as "procedure-end table".
00027  
00028     The AIX traceback table representation on which this header is based is defined as a
00029     series of bit field struct specifications. Bit fields are compiler dependent! Thus,
00030     the definitions presented here follow the original header and the existing documentation
00031     (such as it is), but define the fields as BIT MASKS and other macros. The mask names,
00032     however, where chosen as the original field names to give some compatibility with the 
00033     original header and to agree with the documentation.  */
00034 
00035 #ifndef __TRACEBACK__
00036 #define __TRACEBACK__
00037 
00038 #define TB_C 0U                    /* C */
00039 #define TB_FORTRAN 1U              /* FORTRAN */
00040 #define TB_PASCAL 2U        /* Pascal */
00041 #define TB_ADA 3U           /* ADA */
00042 #define TB_PL1 4U           /* PL1 */
00043 #define TB_BASIC 5U         /* Basic */
00044 #define TB_LISP 6U          /* Lisp */
00045 #define TB_COBOL 7U         /* eCobol */
00046 #define TB_MODULA2 8U              /* Modula2 */
00047 #define TB_CPLUSPLUS 9U            /* C++ */
00048 #define TB_RPG 10U          /* RPG */
00049 #define TB_PL8 11U          /* PL8 */
00050 #define TB_ASM 12U          /* Asm */
00051  
00052 /* Flags 1.  */
00053 
00054 #define TB_GLOBALLINK 0x80U /* Routine is Global Linkage.  */
00055 #define TB_is_eprol 0x40U   /* Out-of-line prolog or epilog routine.  */
00056 #define TB_HAS_TBOFF 0x20U  /* tb_offset set (extension field).  */
00057 #define TB_INT_PROC 0x10U   /* Internal leaf routine.  */
00058 #define TB_HAS_CTL 0x08U    /* Has controlled automatic storage.  */
00059 #define TB_TOCLESS 0X04U    /* Routine has no TOC.  */
00060 #define TB_FP_PRESENT 0x02U /* Routine has floating point ops.  */ 
00061 #define TB_LOG_ABORT 0x01U  /* fp_present && log/abort compiler opt.  */
00062  
00063 /* Flags 2.  */
00064 
00065 #define TB_INT_HNDL 0x80U   /* Routine is an interrupt handler.  */
00066 #define TB_NAME_PRESENT 0x40U      /* Name_len/name set (extension field).  */
00067 #define TB_USES_ALLOCA 0x20U       /* Uses alloca() to allocate storage.  */
00068 #define TB_CL_DIS_inv 0x1CU /* On-condition directives (see below).  */
00069 #define TB_SAVES_CR 0x02U   /* Routine saves the CR.  */
00070 #define TB_SAVES_LR 0x01U   /* Routine saves the LR.  */
00071   
00072 /* cl_dis_inv "on condition" settings:  */
00073  
00074 #define TB_CL_DIS_INV(x) (((x) & cl_dis_inv) >> 2U)
00075 
00076 #define TB_WALK_ONCOND 0U   /* Walk stack without restoring state.  */
00077 #define TB_DISCARD_ONCOND 1U       /* Walk stack and discard.  */
00078 #define TB_INVOKE_ONCOND 2U /* Invoke a specific system routine.  */
00079  
00080 /* Flags 3.  */
00081 
00082 #define TB_STORES_BC 0x80U  /* Routine saves frame ptr of caller.  */
00083 #define TB_SPARE2 0X40U            /* Spare bit.  */
00084 #define TB_FPR_SAVED 0x3fU  /* Number of FPRs saved (max of 32).  */
00085                             /* (Last reg saved is ALWAYS fpr31).  */
00086 
00087 #define TB_NUM_FPR_SAVED(x) ((x) & fpr_saved)
00088  
00089 /* Flags 4.  */
00090 
00091 #define TB_HAS_VEC_INFO 0x80U      /* Routine uses vectors.  */
00092 #define TB_SPARE3 0X40U            /* Spare bit.  */
00093 #define TB_GPR_SAVED 0x3fU  /* Number of GPRs saved (max of 32).  */
00094                             /* (Last reg saved is ALWAYS gpr31).  */
00095 
00096 #define TB_NUM_GPR_SAVED(x) ((x) & gpr_saved)
00097  
00098 /* Flags 5.  */
00099 
00100 #define TB_FLOATPARAMS 0xfeU       /* Number of floating point parameters.  */
00101 #define TB_PARAMSONSTK 0X01U       /* All parameters are on the stack.  */
00102  
00103 #define TB_NUM_FLOATPARAMS(X) (((x) & floatparams) >> 1U)
00104 
00105 /* Traceback_table (fixed portion).  */
00106 
00107 struct traceback_table
00108 {
00109   /* Traceback table layout (fixed portion):  */
00110 
00111   unsigned char version;    /* Traceback format version.  */
00112   unsigned char lang;              /* Language indicators:  */
00113   unsigned char flags1;            /* Flag bits #1:  */
00114   unsigned char flags2;            /* Flag bits #2:  */
00115   unsigned char flags3;            /* Flag bits #3:  */
00116   unsigned char flags4;            /* Flag bits #4:  */
00117   unsigned char fixedparams;       /* Number of fixed point parameters.  */
00118   unsigned char flags5;            /* Flag bits #5:  */
00119 };
00120 
00121 /* traceback_table (optional) extensions.  */
00122 
00123 /* Optional portions exist independently in the order presented below,
00124    not as a structure or a union. Whether or not portions exist is
00125    determinable from bit-fields within the fixed portion above.  */
00126 
00127 /* The following is present only if fixedparams or floatparams are non
00128    zero and it immediately follows the fixed portion of the traceback
00129    table...  */
00130 
00131 /* Order and type encoding of parameters:  */
00132 struct traceback_table_fixedparams
00133 {
00134   unsigned long paraminfo;         
00135 };
00136 
00137 /* Left-justified bit-encoding as follows:  */
00138 #define FIXED_PARAM 0              /* '0'  ==> fixed param (1 gpr or word).  */
00139 #define SPFP_PARAM 2        /* '10' ==> single-precision float param.  */
00140 #define DPFP_PARAM 3        /* '11' ==> double-precision float param.  */
00141 
00142 #define PARAM_ENCODING(x, bit) /* Yields xxx_PARAM as a function of "bit".  */             \
00143  ((((x)&(1UL<<(31UL-(bit++))))==0UL) /* Values 0:31 (left-to-right). "bit" is */    \
00144  ? FIXED_PARAM /* an L-value that's left incremented to */                          \
00145  : ((((x)&(1UL<<(31UL-(bit++))))==0)/* the next bit position for the next */        \
00146  ? SPFP_PARAM /* parameter.  This will be 1 or 2 bit */                             \
00147  : DPFP_PARAM)) /* positions later.  */
00148 
00149 /* The following is present only if has_tboff (in flags1) in fixed part is present...  */
00150 
00151 /* Offset from start of code to TracebackTbl.  */
00152 struct traceback_table_tboff
00153 {
00154   unsigned long tb_offset;
00155 };
00156 
00157 /* The following is present only if int_hndl (in flags2) in fixed part is present ...  */
00158 
00159 /* What interrupts are handled by the routine.  */
00160 struct traceback_table_interrupts
00161 {
00162   long hand_mask;
00163 };
00164 
00165 /* The following are present only if has_ctl (in flags1) in fixed part is present...  */
00166 
00167 /* Controlled automatic storage info:  */
00168 struct traceback_table_anchors
00169 {
00170   unsigned long ctl_info;   /* Number of controlled automatic anchors.  */ 
00171   long ctl_info_disp[1];    /* Array of stack displacements where each.  */
00172 };                          /* Anchor is located (array STARTS here).  */
00173 
00174 /* The following are present only if name_present (in flags2) in fixed
00175    part is present...  */
00176 
00177 /* Routine name:  */
00178 struct traceback_table_routine
00179 {
00180   unsigned short name_len;  /* Length of name that follows.  */
00181   char name[1];                    /* Name starts here (NOT null terminated).  */
00182 };
00183 
00184 /* The following are present only if uses_alloca (in flags2) in fixed
00185    part is present...  */
00186 
00187 /* Register auto storage when alloca() is used.  */
00188 struct traceback_table_alloca
00189 {
00190   char alloca_reg;
00191 };
00192 
00193 /* The following are present only if has_vec_info (in flags4) in fixed
00194    part is present...  */
00195 
00196 /* Vector info:  */
00197 struct traceback_table_vector
00198 {
00199   unsigned char vec_flags1; /* Vec info bits #1:  */
00200 
00201 #define TB_VR_SAVED 0xFCU   /* Number of saved vector registers.  */
00202 #define TB_SAVES_VRSAVE 0x02U      /* Saves VRsave.  */
00203 #define TB_HAS_VARARGS 0x01U       /* Routine has a variable argument list.  */
00204 
00205 #define TB_NUM_VR_SAVED(x) (((x) & TB_VR_SAVED) >> 2U)
00206  
00207   unsigned char vec_flags2; /* Vec info bits #2:  */
00208 
00209 #define TB_VECTORPARAMS 0xfeU      /* Number of vector parameters.  */
00210 #define TB_VEC_PRESENT 0x01U       /* Routine uses at least one vec instr.  */
00211  
00212 #define VECPARAMS(x) (((x) & TB_VECTORPARAMS) >> 1U)
00213 };
00214 
00215 #endif