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
12class LineNumberProgram {
13public:
14	struct State;
15
16public:
17								LineNumberProgram(uint8 addressSize, bool isBigEndian);
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
30private:
31			void				_SetToInitial(State& state) const;
32
33private:
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			bool				fIsBigEndian;
43			const uint8*		fStandardOpcodeLengths;
44};
45
46
47struct LineNumberProgram::State {
48	target_addr_t	address;
49	int32			file;
50	int32			line;
51	int32			column;
52	bool			isStatement;
53	bool			isBasicBlock;
54	bool			isSequenceEnd;
55	bool			isPrologueEnd;
56	bool			isEpilogueBegin;
57	uint32			instructionSet;
58	uint32			discriminator;
59
60	// when file is set to -1
61	const char*		explicitFile;
62	uint32			explicitFileDirIndex;
63
64	DataReader		dataReader;
65};
66
67
68#endif	// LINE_NUMBER_PROGRAM_H
69