-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathTSymbolList.h
160 lines (138 loc) · 4.1 KB
/
TSymbolList.h
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// ==============================
// File: TSymbolList.h
// Project: Einstein
//
// Copyright 2003-2007 by Paul Guyot (pguyot@kallisys.net).
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// ==============================
// $Id$
// ==============================
#ifndef _TSYMBOLLIST_H
#define _TSYMBOLLIST_H
#include <K/Defines/KDefinitions.h>
#include <stdio.h>
///
/// Class for a list of symbols. The symbol file format is:
/// addr name[\tcommment]
/// where addr is a 32 bit hex number, and the optional comment is preceeded
/// by a tab character. The file sorted by addr.
///
/// \author Paul Guyot <pguyot@kallisys.net>
/// \version $Revision: 113 $
///
/// \test aucun test défini.
///
class TSymbolList
{
public:
static const KUInt32 kNoSymbol = 0xFFFFFFFF;
static TSymbolList* List;
///
/// Constructor from a path.
///
TSymbolList(const char* inSymbolPath);
///
/// Destructor.
///
~TSymbolList(void);
///
/// Find symbol at or preceeding a given address
///
void GetNearestSymbolByAddress(
KUInt32 inValue,
char* outSymbol,
char* outComment,
int* outOffset);
///
/// Find symbol at a given address
///
bool GetSymbolByAddress(
KUInt32 inValue,
char* outSymbol,
char* outComment = NULL,
int* outOffset = NULL);
///
/// Find a symbol by name and return its address
///
KUInt32 GetSymbolByName(const char* inName);
///
/// Find the next symbol for a give address
///
KUInt32 GetNextSymbol(KUInt32 inValue);
private:
struct SSymbolStruct {
KUInt32 fAddress;
char* fName;
char* fComment;
};
///
/// Constructeur par copie volontairement indisponible.
///
/// \param inCopy objet à copier
///
TSymbolList(const TSymbolList& inCopy);
///
/// Opérateur d'assignation volontairement indisponible.
///
/// \param inCopy objet à copier
///
TSymbolList& operator=(const TSymbolList& inCopy);
///
/// Load symbols.
///
void LoadSymbols(void);
///
/// Copy symbol name and comment strings out of an SSymbolStruct
//
void CopySymbolStrings(
SSymbolStruct* symbol,
char* outSymbol,
char* outComment);
///
/// Read data for a symbol from the symbol file
//
void ReadSymbolData(
FILE* inFile,
char* outSymbol,
char* outComment);
///
/// Add one symbol with value and comment
///
void AddSymbol(
KUInt32 inValue,
const char* inSymbol,
const char* inComment = NULL);
///
/// Return -1, 0, or 1 if the symbol position is less, equal, or greater
static int QSortCallback(const void* left, const void* right);
/// \name Variables
SSymbolStruct* mSymbolOffsets;
KUInt32 mSymbolCount;
KUInt32 mSymbolCapacity;
FILE* mFile;
};
#endif
// _TSYMBOLLIST_H
// ============================================================================== //
// The programmers of old were mysterious and profound. We cannot fathom //
// their thoughts, so all we do is describe their appearance. //
// Aware, like a fox crossing the water. Alert, like a general on the //
// battlefield. Kind, like a hostess greeting her guests. Simple, like uncarved //
// blocks of wood. Opaque, like black pools in darkened caves. //
// Who can tell the secrets of their hearts and minds? //
// The answer exists only in the Tao. //
// -- Geoffrey James, "The Tao of Programming" //
// ============================================================================== //