forked from farbrausch/fr_public
-
Notifications
You must be signed in to change notification settings - Fork 2
/
debuginfo.hpp
115 lines (90 loc) · 2.08 KB
/
debuginfo.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Written by Fabian "ryg" Giesen.
// I hereby place this code in the public domain.
#ifndef __DEBUGINFO_HPP__
#define __DEBUGINFO_HPP__
#include "_types.hpp"
/****************************************************************************/
#define DIC_END 0
#define DIC_CODE 1
#define DIC_DATA 2
#define DIC_UNKNOWN 3
union DIString
{
sInt Index;
sChar *String;
};
struct DISymFile
{
DIString Name;
sF32 PackedSize;
sU32 Size;
};
struct DISymNameSp // Namespace
{
DIString Name;
sF32 PackedSize;
sU32 Size;
};
struct DISymbol
{
DIString Name;
DIString MangledName;
sInt NameSpNum;
sInt FileNum;
sU32 VA;
sU32 Size;
sInt Class;
sF64 PackedSize;
sU32 sourcePos;
};
class DebugInfo
{
sArray<sInt> Strings;
sArray<sChar> StringData;
sU32 Address;
sU32 BaseAddress;
class ReorderBuffer *Reorder;
public:
sArray<DISymbol> Symbols;
sArray<DISymFile> Files;
sArray<DISymNameSp> NameSps;
void Init();
void Exit();
// only use those before reading is finished!!
sInt MakeString(sChar *string);
sChar* GetStringPrep(sInt index) { return &StringData[index]; }
void SetBaseAddress(sU32 base) { BaseAddress = base; }
void FinishedReading();
void Rebase(sU32 newBase);
sInt GetFile(sInt name);
sInt GetFileByName(sChar *name);
sInt GetNameSpace(sInt name);
sInt GetNameSpaceByName(sChar *name);
void StartAnalyze(sU32 startAddress,class ReorderBuffer *reorder=0);
static void TokenizeCallback(void *user,sInt uncompSize,sF32 compSize);
void FinishAnalyze();
sBool FindSymbol(sU32 VA,DISymbol **sym);
sChar *WriteReport();
};
class DebugInfoReader
{
public:
virtual sBool ReadDebugInfo(sChar *fileName,DebugInfo &to) = 0;
};
struct ReorderItem
{
sU32 NewVA,NewSize;
sU32 OldVA,OldSize;
};
class ReorderBuffer
{
public:
ReorderBuffer();
~ReorderBuffer();
sArray<ReorderItem> Reorder;
void Add(sU32 newVA,sU32 newSize,sU32 oldVA,sU32 oldSize);
void Finish();
sBool Find(sU32 addr,ReorderItem **reord);
};
/****************************************************************************/
#endif