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

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

Go to the documentation of this file.
00001 #ifndef _RawSection_h_
00002 #define _RawSection_h_
00003 
00004 #include <Base.h>
00005 #include <defines/RawSection.d>
00006 
00007 class SectHeader;
00008 class SymbolTable;
00009 class Symbol;
00010 
00011 class LSHeader;
00012 class LSSymbol;
00013 class LSRelocation;
00014 class LSFileNameTable;
00015 class LSStringTable;
00016 class AddressIterator;
00017 class Function;
00018 class XCoffFile;
00019 class BasicBlock;
00020 class LineInfoFinder;
00021 class Loop;
00022 
00023 class RawSection : public Base {
00024 protected:
00025     SectHeader* header;
00026     char* rawDataPtr;
00027     SymbolTable* xCoffSymbolTable;
00028     HashCode hashCode;
00029     XCoffFile* xCoffFile;
00030 
00031     ~RawSection() {}
00032 public:
00033 
00034     RawSection(SectHeader* h,XCoffFile* xcoff);
00035     static RawSection* newRawSection(SectHeader* h,XCoffFile* xcoff);
00036 
00037     SECTRAW_MACROS_BASIS("For the get_X field macros check the defines directory");
00038 
00039     uint32_t read(BinaryInputFile* b);
00040     void print();
00041     uint64_t readBytes(AddressIterator* ait);
00042     Instruction readInstruction(AddressIterator* ait);
00043 
00044     bool inRange(uint64_t addr) { return header->inRange(addr); }
00045 
00046     void setSymbolTable(SymbolTable* st) { xCoffSymbolTable = st; }
00047     SymbolTable*  getSymbolTable() { return xCoffSymbolTable; }
00048 
00049     virtual void findFunctions();
00050     virtual void generateCFGs();
00051     virtual void findMemoryFloatOps();
00052     virtual void displaySymbols(Symbol** symbols,uint32_t symbolCount);
00053     virtual char* getContentVisually(Symbol** symbols,uint32_t symbolCount,uint64_t content);
00054 
00055     virtual AddressIterator getAddressIterator();
00056 
00057     uint16_t getIndex() { return header->getIndex(); }
00058     SectHeader* getSectHeader() { return header; }
00059 
00060     XCoffFile* getXCoffFile() { return xCoffFile; }
00061 
00062     virtual uint32_t getNumberOfFunctions() { return 0; }
00063     virtual uint32_t getNumberOfBlocks()    { return 0; }
00064     virtual uint32_t getNumberOfMemoryOps() { return 0; }
00065     virtual uint32_t getNumberOfFloatPOps() { return 0; }
00066     virtual Function* getFunction(uint32_t idx) { return NULL; }
00067     virtual uint32_t getAllBlocks(BasicBlock** arr) { return 0; }
00068 
00069     char* getRawDataPtr() { return rawDataPtr; } 
00070 
00071     const char* briefName() { return "RawSection"; }
00072 
00073     uint32_t instrument(char* buffer,XCoffFileGen* xCoffGen,BaseGen* gen);
00074     uint32_t getInstrumentationSize(XCoffFileGen* xCoffGen);
00075 
00076     virtual void buildLineInfoFinder() {}
00077     virtual LineInfoFinder* getLineInfoFinder() { return NULL; }
00078 
00079     virtual void buildLoops() {}
00080 
00081 };
00082 
00083 class DebugSection : public RawSection {
00084 protected:
00085 
00086     ~DebugSection() {}
00087 
00088 public:
00089     DebugSection(SectHeader* h,XCoffFile* xcoff) : RawSection(h,xcoff) {}
00090 
00091     char* getString(uint32_t offset);
00092 
00093     void print();
00094 
00095     const char* briefName() { return "DebugSection"; }
00096 };
00097 
00098 class TypeCommSection : public RawSection {
00099 protected:
00100     ~TypeCommSection() {}
00101 
00102 public:
00103     TypeCommSection(SectHeader* h,XCoffFile* xcoff) : RawSection(h,xcoff) {}
00104 
00105     void print();
00106 
00107     char* getString(uint32_t offset);
00108 
00109     const char* briefName() { return "TypeCommSection"; }
00110 };
00111 
00112 class Exception {
00113 protected:
00114     virtual ~Exception() {}
00115 public:
00116     virtual char* charStream() { __SHOULD_NOT_ARRIVE; return NULL; }
00117     virtual void print(SymbolTable* symbolTable,uint32_t index);
00118 
00119     EXCEPTIONRAW_MACROS_BASIS("For the get_X field macros check the defines directory");
00120 
00121 };
00122 
00123 class Exception32 : public Exception {
00124 protected:
00125     EXCEPTAB entry;
00126 public:
00127     Exception32() {}
00128     ~Exception32() {}
00129     char* charStream() { return (char*)&entry; }
00130 
00131     EXCEPTIONRAW_MACROS_CLASS("For the get_X field macros check the defines directory");
00132 };
00133 
00134 class Exception64 : public Exception {
00135 protected:
00136     EXCEPTAB_64 entry;
00137 public:
00138     Exception64() {}
00139     ~Exception64() {}
00140     char* charStream() { return (char*)&entry; }
00141 
00142     EXCEPTIONRAW_MACROS_CLASS("For the get_X field macros check the defines directory");
00143 };
00144 
00145 class ExceptionSection : public RawSection {
00146 protected:
00147     Exception** exceptions;
00148     uint32_t numberOfExceptions;
00149 
00150     ~ExceptionSection() {}
00151 
00152 public:
00153     ExceptionSection(SectHeader* h,XCoffFile* xcoff);
00154 
00155     uint32_t read(BinaryInputFile* b);
00156     void print();
00157 
00158     const char* briefName() { return "ExceptionSection"; }
00159 
00160     uint32_t instrument(char* buffer,XCoffFileGen* xCoffGen,BaseGen* gen);
00161 };
00162 
00163 class LoaderSection : public RawSection {
00164 protected:
00165     LSHeader* header;
00166 
00167     uint32_t numberOfSymbols;
00168     LSSymbol** symbolTable;
00169     char* symbolTablePtr;
00170 
00171     uint32_t numberOfRelocations;
00172     LSRelocation** relocationTable;
00173     char* relocationTablePtr;
00174 
00175     LSFileNameTable* fileNameTable;
00176     LSStringTable* stringTable;
00177 
00178     ~LoaderSection() {}
00179 
00180 public:
00181     LoaderSection(SectHeader* h,XCoffFile* xcoff) : RawSection(h,xcoff),
00182                       header(NULL),
00183                       numberOfSymbols(0),symbolTable(NULL),symbolTablePtr(NULL),
00184                       numberOfRelocations(0),relocationTable(NULL),relocationTablePtr(NULL),
00185                       fileNameTable(NULL),
00186                       stringTable(NULL) {}
00187 
00188     uint32_t read(BinaryInputFile* b);
00189     void print();
00190 
00191     const char* briefName() { return "LoaderSection"; }
00192 
00193     uint32_t getInstrumentationSize(XCoffFileGen* xCoffGen);
00194     uint32_t instrument(char* buffer,XCoffFileGen* xCoffGen,BaseGen* gen);
00195     uint32_t getBSSRelocations(uint64_t* addrs);
00196     uint32_t getRelocationCount() { return numberOfRelocations; }
00197 };
00198 
00199 class TextSection : public RawSection {
00200 protected:
00201 
00202     Function** functions;    
00203     uint32_t numOfFunctions;
00204     LineInfoFinder* lineInfoFinder;
00205 
00206     ~TextSection() {}
00207 
00208 public:
00209 
00210     TextSection(SectHeader* h,XCoffFile* xcoff) : RawSection(h,xcoff),functions(NULL),
00211                                         numOfFunctions(0),lineInfoFinder(NULL)  {}
00212     void print();
00213     void findFunctions();
00214     void generateCFGs();
00215     void findMemoryFloatOps();
00216     char* getContentVisually(Symbol** symbols,uint32_t symbolCount,uint64_t content);
00217     AddressIterator getAddressIterator();
00218 
00219     uint32_t getNumberOfFunctions();
00220     uint32_t getNumberOfBlocks();
00221     uint32_t getNumberOfMemoryOps();
00222     uint32_t getNumberOfFloatPOps();
00223 
00224     Function* getFunction(uint32_t idx) { return (idx < numOfFunctions ? functions[idx] : NULL); }
00225 
00226     uint32_t getAllBlocks(BasicBlock** arr);
00227 
00228     const char* briefName() { return "TextSection"; }
00229 
00230     uint32_t getInstrumentationSize(XCoffFileGen* xCoffGen);
00231     uint32_t instrument(char* buffer,XCoffFileGen* xCoffGen,BaseGen* gen);
00232 
00233     void buildLineInfoFinder();
00234     LineInfoFinder* getLineInfoFinder() { return lineInfoFinder; }
00235 
00236     void buildLoops();
00237 
00238 };
00239 
00240 class DataSection : public RawSection {
00241 protected:
00242 
00243     ~DataSection() {}
00244 
00245 public:
00246 
00247     DataSection(SectHeader* h,XCoffFile* xcoff) : RawSection(h,xcoff) {}
00248     char* getContentVisually(Symbol** symbols,uint32_t symbolCount,uint64_t content);
00249     AddressIterator getAddressIterator();
00250 
00251     const char* briefName() { return "DataSection"; }
00252 
00253     uint32_t getInstrumentationSize(XCoffFileGen* xCoffGen);
00254     uint32_t instrument(char* buffer,XCoffFileGen* xCoffGen,BaseGen* gen);
00255 };
00256 
00257 
00258 class BSSSection : public RawSection {
00259 protected:
00260 
00261     ~BSSSection() {}
00262 
00263 public:
00264 
00265     BSSSection(SectHeader* h,XCoffFile* xcoff) : RawSection(h,xcoff) {}
00266     void displaySymbols(Symbol** symbols,uint32_t symbolCount);
00267 
00268     const char* briefName() { return "BSSSection"; }
00269 };
00270 #endif

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