SymbolRegistry.h Source File
Back to the index.
src
include
SymbolRegistry.h
Go to the documentation of this file.
1
#ifndef SYMBOLREGISTRY_H
2
#define SYMBOLREGISTRY_H
3
4
/*
5
* Copyright (C) 2009-2010 Anders Gavare. All rights reserved.
6
*
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
*
10
* 1. Redistributions of source code must retain the above copyright
11
* notice, this list of conditions and the following disclaimer.
12
* 2. Redistributions in binary form must reproduce the above copyright
13
* notice, this list of conditions and the following disclaimer in the
14
* documentation and/or other materials provided with the distribution.
15
* 3. The name of the author may not be used to endorse or promote products
16
* derived from this software without specific prior written permission.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28
* SUCH DAMAGE.
29
*/
30
31
#include "
misc.h
"
32
33
#include "
UnitTest.h
"
34
35
36
/**
37
* \brief A registry for loaded symbols.
38
*/
39
class
SymbolRegistry
40
:
public
UnitTestable
41
{
42
public
:
43
/**
44
* \brief Constructs a SymbolRegistry.
45
*/
46
SymbolRegistry
();
47
48
/**
49
* \brief Clears the registry.
50
*/
51
void
Clear
();
52
53
/**
54
* \brief Adds a symbol to the registry.
55
*
56
* @param symbol The symbol name.
57
* @param vaddr The virtual address.
58
*/
59
void
AddSymbol
(
const
string
&
symbol
, uint64_t vaddr);
60
61
/**
62
* \brief Looks up an address.
63
*
64
* The returned address may be of the format "symbol+offset", where
65
* offset is a hexadecimal number, if allowOffset is true.
66
*
67
* @param vaddr The virtual address.
68
* @param allowOffset If false, the address must be found exactly.
69
* If true, a symbol which almost matches the address, plus an
70
* offset, may be returned.
71
* @return A string representing the address, or an empty string
72
* if no suitable match was found.
73
*/
74
string
LookupAddress
(uint64_t vaddr,
bool
allowOffset)
const
;
75
76
77
/********************************************************************/
78
79
static
void
RunUnitTests
(
int
& nSucceeded,
int
& nFailures);
80
81
private
:
82
typedef
map<uint64_t,string> SymbolMap;
83
SymbolMap m_map;
84
};
85
86
87
#endif // SYMBOLREGISTRY_H
SymbolRegistry::Clear
void Clear()
Clears the registry.
Definition:
SymbolRegistry.cc:36
SymbolRegistry::RunUnitTests
static void RunUnitTests(int &nSucceeded, int &nFailures)
SymbolRegistry::AddSymbol
void AddSymbol(const string &symbol, uint64_t vaddr)
Adds a symbol to the registry.
Definition:
SymbolRegistry.cc:42
misc.h
SymbolRegistry
A registry for loaded symbols.
Definition:
SymbolRegistry.h:41
SymbolRegistry::SymbolRegistry
SymbolRegistry()
Constructs a SymbolRegistry.
Definition:
SymbolRegistry.cc:31
SymbolRegistry::LookupAddress
string LookupAddress(uint64_t vaddr, bool allowOffset) const
Looks up an address.
Definition:
SymbolRegistry.cc:48
UnitTest.h
symbol
Definition:
symbol.h:37
UnitTestable
Base class for unit testable classes.
Definition:
UnitTest.h:75
Generated on Tue Aug 25 2020 19:25:06 for GXemul by
1.8.18