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

/users/u3/mtikir/PMaCInstrumentor_v1601/include/SymbolTable.h

Go to the documentation of this file.
00001 #ifndef _SymbolTable_h_
00002 #define _SymbolTable_h_
00003 
00004 #include <Base.h>
00005 #include <defines/SymbolTable.d>
00006 
00007 class StringTable;
00008 class DebugSection;
00009 class Symbol;
00010 class SectHeader;
00011 class XCoffFile;
00012 
00013 class SymbolBase {
00014 private:
00015     SymbolBase* next;    
00016     SymbolBase* prev;
00017     uint32_t index;
00018 protected:
00019 public:
00020     SymbolBase(uint32_t idx) : next(NULL),prev(NULL),index(idx) {}
00021     virtual ~SymbolBase() {}
00022     SymbolBase* getNext() { return next; }
00023     SymbolBase* getPrev() { return prev; }
00024     void setPrev(SymbolBase* p) { prev = p; }
00025     void setNext(SymbolBase* n) { next = n; }
00026 
00027     virtual bool isAuxilary() { __SHOULD_NOT_ARRIVE; return false; }
00028     virtual char* charStream() { __SHOULD_NOT_ARRIVE; return NULL; }
00029     virtual void print(StringTable* stringTable,DebugSection* debugRawSect,bool followAux)
00030                         { __SHOULD_NOT_ARRIVE; }
00031     virtual char* getName(StringTable* stringTable,DebugSection* debugRawSect)
00032                         { __SHOULD_NOT_ARRIVE; return NULL; }
00033     virtual const char* getTypeName() {  __SHOULD_NOT_ARRIVE; return NULL; }
00034 
00035     uint32_t getIndex() { return index; }
00036 
00037 };
00038 
00039 class Symbol : public SymbolBase {
00040 public:
00041 
00042     Symbol(uint32_t idx) : SymbolBase(idx) {}
00043     ~Symbol() {}
00044     bool isAuxilary() { return false; }
00045 
00046     SYMBOL_MACROS_BASIS("For the get_X field macros check the defines directory");
00047 
00048     bool unknownSymbol();
00049     bool stringInDebugSection();
00050     const char* getTypeName();
00051     char* getName(StringTable* stringTable,DebugSection* debugRawSect);
00052 
00053     void print(StringTable* stringTable,DebugSection* debugRawSect,bool followAux);
00054 
00055     virtual uint32_t getNameOffset() { __SHOULD_NOT_ARRIVE; return 0; }
00056     virtual char* getNameStringTable(StringTable* stringTable) { __SHOULD_NOT_ARRIVE; return NULL; }
00057     virtual char* getNameDebugSection(DebugSection* rawDebugSect) { __SHOULD_NOT_ARRIVE; return NULL; }
00058 
00059     static bool isSorted(Symbol** symbols,uint32_t symbolCount) { return true; }
00060     static bool builtinSaveRestore(char* ptr);
00061     static Symbol* findSymbol(Symbol** symbols,uint32_t symbolCount,uint64_t value);
00062 
00063     virtual void changeValueCopy(uint64_t value,char* buff) { __SHOULD_NOT_ARRIVE; }
00064 };
00065 
00066 class Symbol32 : public Symbol {
00067 private:
00068     SYMENT entry;
00069 protected:
00070 public:
00071     Symbol32(uint32_t idx) : Symbol(idx){}
00072     ~Symbol32() {}
00073     char* charStream() { return (char*)&entry; }
00074 
00075     SYMBOL_MACROS_CLASS("For the get_X field macros check the defines directory");
00076     GET_FIELD_CLASS(char*,n_name); 
00077     GET_FIELD_CLASS(uint32_t,n_zeroes);
00078 
00079     uint32_t getNameOffset();
00080     char* getNameStringTable(StringTable* stringTable);
00081     char* getNameDebugSection(DebugSection* rawDebugSect);
00082 
00083     void changeValueCopy(uint64_t value,char* buff);
00084 };
00085 
00086 class Symbol64 : public Symbol {
00087 private:
00088     SYMENT_64 entry;
00089 protected:
00090 public:
00091     Symbol64(uint32_t idx) : Symbol(idx) {}
00092     ~Symbol64() {}
00093     char* charStream() { return (char*)&entry; }
00094 
00095     SYMBOL_MACROS_CLASS("For the get_X field macros check the defines directory");
00096 
00097     uint32_t getNameOffset();
00098     char* getNameStringTable(StringTable* stringTable);
00099     char* getNameDebugSection(DebugSection* rawDebugSect);
00100 
00101     void changeValueCopy(uint64_t value,char* buff);
00102 };
00103 
00104 class SymbolTable : public Base {
00105 protected:
00106     char* symbolTablePtr;
00107     uint32_t numberOfSymbols;
00108     SymbolBase** symbols;
00109     StringTable* stringTable;
00110     DebugSection* debugRawSect;
00111 
00112     XCoffFile* xCoffFile;
00113 
00114 public:
00115 
00116     SymbolTable(char* ptr,uint32_t nsyms,XCoffFile* xcoff);
00117     ~SymbolTable();
00118 
00119     char* getSymbolTablePtr() { return symbolTablePtr; }
00120     uint32_t getNumberOfSymbols() { return numberOfSymbols; }
00121 
00122     void print();
00123     void printSymbol(uint32_t index);
00124     void printSymbol(SymbolBase* sym);
00125     uint32_t read(BinaryInputFile* b);
00126 
00127     void setStringTable(StringTable* st) { stringTable = st; }
00128     void setDebugSection(DebugSection* ds) { debugRawSect = ds; }
00129 
00130     SymbolBase* getSymbol(uint32_t index) { ASSERT(index < numberOfSymbols); return symbols[index]; }
00131     char* getSymbolName(SymbolBase* sym) { return sym->getName(stringTable,debugRawSect); }
00132     char* getSymbolName(uint32_t index) { return getSymbolName(getSymbol(index)); }
00133 
00134     static SymbolBase* newSymbol(SymbolBase* lastSymbol,
00135                                  uint8_t remaningAux,BinaryInputFile* binaryInputFile,uint32_t index,
00136                                  XCoffFile* xcoff);
00137 
00138     uint64_t getSymbolLength(SymbolBase* symBase);
00139     uint8_t getStorageMapping(SymbolBase* symBase);
00140 
00141     uint32_t filterSortAddressSymbols(Symbol** symbolArray,uint32_t arrayLength);
00142     uint32_t filterSortFuncSymbols(Symbol** symbolArray,uint32_t arrayLength,SectHeader* header);
00143     uint32_t filterSortBSSSymbols(Symbol** symbolArray,uint32_t arrayLength);
00144 
00145     XCoffFile* getXCoffFile() { return xCoffFile; }
00146 
00147     const char* briefName() { return "SymbolTable"; }
00148 
00149     uint32_t instrument(char* buffer,XCoffFileGen* xCoffGen,BaseGen* gen);
00150 
00151 };
00152 
00153 extern int searchSymbolValue(const void* arg1,const void* arg2);
00154 
00155 #endif /* _SymbolTable_h_ */

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