1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef LINE_NUMBER_PROGRAM_H 6 #define LINE_NUMBER_PROGRAM_H 7 8 #include "DataReader.h" 9 #include "Types.h" 10 11 12 class LineNumberProgram { 13 public: 14 struct State; 15 16 public: 17 LineNumberProgram(uint8 addressSize); 18 ~LineNumberProgram(); 19 20 status_t Init(const void* program, size_t programSize, 21 uint8 minInstructionLength, 22 bool defaultIsStatement, int8 lineBase, 23 uint8 lineRange, uint8 opcodeBase, 24 const uint8* standardOpcodeLengths); 25 26 bool IsValid() const { return fProgram != NULL; } 27 void GetInitialState(State& state) const; 28 bool GetNextRow(State& state) const; 29 30 private: 31 void _SetToInitial(State& state) const; 32 33 private: 34 const void* fProgram; 35 size_t fProgramSize; 36 uint8 fMinInstructionLength; 37 bool fDefaultIsStatement; 38 int8 fLineBase; 39 uint8 fLineRange; 40 uint8 fOpcodeBase; 41 uint8 fAddressSize; 42 const uint8* fStandardOpcodeLengths; 43 }; 44 45 46 struct LineNumberProgram::State { 47 target_addr_t address; 48 int32 file; 49 int32 line; 50 int32 column; 51 bool isStatement; 52 bool isBasicBlock; 53 bool isSequenceEnd; 54 bool isPrologueEnd; 55 bool isEpilogueBegin; 56 uint32 instructionSet; 57 uint32 discriminator; 58 59 // when file is set to -1 60 const char* explicitFile; 61 uint32 explicitFileDirIndex; 62 63 DataReader dataReader; 64 }; 65 66 67 #endif // LINE_NUMBER_PROGRAM_H 68