Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

/users/u3/mtikir/PMaCInstrumentor_v1601/src/Auxilary.C

Go to the documentation of this file.
00001 #include <Instruction.h>
00002 #include <DemangleWrapper.h>
00003 #include <SymbolTable.h>
00004 #include <StringTable.h>
00005 #include <SectHeader.h>
00006 #include <RawSection.h>
00007 #include <Auxilary.h>
00008 #include <BinaryFile.h>
00009 
00010 const char* Auxilary::getTypeName(){
00011     switch(getAuxilaryType()) {
00012         case Type__Auxilary_Symbol_No_Type : return "NO_TYPE";
00013         case Type__Auxilary_Symbol_Section : return "SECTION";
00014         case Type__Auxilary_Symbol_Exception : return "EXCEPTION";
00015         case Type__Auxilary_Symbol_Function : return "FUNCTION";
00016         case Type__Auxilary_Symbol_Block : return "BLOCK";
00017         case Type__Auxilary_Symbol_File : return "FILE";
00018         case Type__Auxilary_Symbol_CSect : return "CSECT";
00019         default: 
00020             PRINT_DEBUG("Some auxilary symbol that is not known");
00021             ASSERT(false);
00022             return "UNK";
00023     }
00024     return NULL;
00025 }
00026 
00027 void Auxilary::print(StringTable* stringTable,
00028                      DebugSection* debugRawSect,bool followAux)
00029 {
00030     PRINT_INFOR("\tAUX\t%10s [%7d]",getTypeName(),getIndex());
00031 }
00032 
00033 void AuxilarySection::print(StringTable* stringTable,
00034            DebugSection* debugRawSect,
00035            bool followAux)
00036 {
00037     PRINT_INFOR("\t^\t%10s [%7d] (length %d) (#reloc %d) (#line %d)",
00038                     getTypeName(),getIndex(),
00039                     GET_A(x_scnlen,x_scn),
00040                     GET_A(x_nreloc,x_scn),
00041                     GET_A(x_nlinno,x_scn));
00042 }
00043 void AuxilaryException::print(StringTable* stringTable,
00044            DebugSection* debugRawSect,
00045            bool followAux)
00046 {
00047     PRINT_INFOR("\tAUX\t%10s [%7d] (exptr %lld) (fsize %d) (nextsym %d)",
00048                     getTypeName(),getIndex(),
00049                     GET_A(x_exptr,x_except),
00050                     GET_A(x_fsize,x_except),
00051                     GET_A(x_endndx,x_except));
00052 }
00053 
00054 void AuxilaryException::changeExptrCopy(uint64_t exptr,char* buff){
00055     AUXENT_64 newEntry;
00056     newEntry = entry;
00057     newEntry.x_except.x_exptr = exptr;
00058     memcpy(buff,&newEntry,Size__NN_bit_SymbolTable_Entry);
00059 }
00060 
00061 void AuxilaryBlock::print(StringTable* stringTable,
00062            DebugSection* debugRawSect,
00063            bool followAux)
00064 {
00065     PRINT_INFOR("\tAUX\t%10s [%7d] (lineno %d)",
00066                     getTypeName(),getIndex(),
00067                     GET_A(x_lnno,x_misc));
00068 }
00069 
00070 void AuxilaryFile::print(StringTable* stringTable,
00071            DebugSection* debugRawSect,
00072            bool followAux)
00073 {
00074     char* name = GET_A(x_fname,x_file);
00075     uint32_t zeroes = GET_A(x_zeroes,x_file);
00076     if(!zeroes){
00077         name = stringTable->getString(GET_A(x_offset,x_file));
00078     }
00079     PRINT_INFOR("\tAUX\t%10s [%7d] (fname %s)",
00080                     getTypeName(),getIndex(),
00081                     name);
00082 }
00083 
00084 void AuxilaryFunction::print(StringTable* stringTable,
00085            DebugSection* debugRawSect,
00086            bool followAux)
00087 {
00088     PRINT_INFOR("\tAUX\t%10s [%7d] (exptr %d) (fsize %d) (linptr %lld) (nextsym %d)",
00089                     getTypeName(),getIndex(),
00090                     GET_A(x_exptr,x_fcn),
00091                     GET_A(x_fsize,x_fcn),
00092                     GET_A(x_lnnoptr,x_fcn),
00093                     GET_A(x_endndx,x_fcn));
00094 }
00095 
00096 void AuxilaryFunction32::changeExptrLnnoptrCopy(uint32_t exptr,uint64_t lnnoptr,char* buff){
00097     AUXENT newEntry;
00098     newEntry = entry;
00099     newEntry.x_sym.x_exptr = exptr;
00100     newEntry.x_sym.x_fcnary.x_fcn.x_lnnoptr = lnnoptr;
00101     memcpy(buff,&newEntry,Size__NN_bit_SymbolTable_Entry);
00102 }
00103 
00104 void AuxilaryFunction64::changeExptrLnnoptrCopy(uint32_t exptr,uint64_t lnnoptr,char* buff){
00105     AUXENT_64 newEntry;
00106     newEntry = entry;
00107     newEntry.x_fcn.x_lnnoptr = lnnoptr;
00108     memcpy(buff,&newEntry,Size__NN_bit_SymbolTable_Entry);
00109 }
00110 
00111 void AuxilaryCSect::print(StringTable* stringTable,
00112            DebugSection* debugRawSect,
00113            bool followAux)
00114 {
00115     uint64_t length = getLength();
00116 
00117     bool isInSymTable = false;
00118 
00119     uint8_t smtype = GET_A(x_smtyp,x_csect);
00120     uint32_t lengthMod = smtype & 0x7;
00121     uint32_t alignment = (smtype >> 3) & 0x1f;
00122     alignment = 1 << alignment;
00123 
00124     char* ptr = "";
00125     switch(lengthMod){
00126         case XTY_SD: 
00127             ptr = "SD"; 
00128             break;
00129         case XTY_LD: 
00130             isInSymTable = true; 
00131             ptr = "LD"; 
00132             break;
00133         case XTY_CM: 
00134             ptr = "CM"; 
00135             break;
00136         case XTY_ER: 
00137             ptr = "ER"; 
00138             ASSERT((length == 0) && "FATAL : For this type the length should be 0");
00139             break;
00140         default:
00141             break;
00142     }
00143 
00144     PRINT_INFOR("\tAUX\t%10s [%7d] (scnlen %lld) (parmhash %d) (snhash %d) (type %#x) (cls %d) %s (%d,%d)",
00145                     getTypeName(),getIndex(),
00146                     length,GET_A(x_parmhash,x_csect),GET_A(x_snhash,x_csect),
00147                     GET_A(x_smtyp,x_csect),GET_A(x_smclas,x_csect),ptr,lengthMod,alignment);
00148 }
00149 
00150 uint64_t AuxilaryCSect32::getLength(){
00151     return GET_A(x_scnlen,x_csect);
00152 }
00153 
00154 uint64_t AuxilaryCSect64::getLength(){
00155     uint64_t lo = GET_A(x_scnlen_lo,x_csect);
00156     uint64_t hi = GET_A(x_scnlen_hi,x_csect);
00157     return ((hi << 32) | lo);
00158 }

Generated on Mon Jan 28 11:08:32 2008 for PMaCInstrumentor by doxygen 1.3.5