diff options
| -rw-r--r-- | src/common/common.vcxproj | 2 | ||||
| -rw-r--r-- | src/common/common.vcxproj.filters | 2 | ||||
| -rw-r--r-- | src/common/symbols.cpp | 57 | ||||
| -rw-r--r-- | src/common/symbols.h | 39 |
4 files changed, 100 insertions, 0 deletions
diff --git a/src/common/common.vcxproj b/src/common/common.vcxproj index 32d735a09..202d00d18 100644 --- a/src/common/common.vcxproj +++ b/src/common/common.vcxproj | |||
| @@ -186,6 +186,7 @@ | |||
| 186 | <ClInclude Include="std_thread.h" /> | 186 | <ClInclude Include="std_thread.h" /> |
| 187 | <ClInclude Include="string_util.h" /> | 187 | <ClInclude Include="string_util.h" /> |
| 188 | <ClInclude Include="swap.h" /> | 188 | <ClInclude Include="swap.h" /> |
| 189 | <ClInclude Include="symbols.h" /> | ||
| 189 | <ClInclude Include="thread.h" /> | 190 | <ClInclude Include="thread.h" /> |
| 190 | <ClInclude Include="thunk.h" /> | 191 | <ClInclude Include="thunk.h" /> |
| 191 | <ClInclude Include="timer.h" /> | 192 | <ClInclude Include="timer.h" /> |
| @@ -205,6 +206,7 @@ | |||
| 205 | <ClCompile Include="misc.cpp" /> | 206 | <ClCompile Include="misc.cpp" /> |
| 206 | <ClCompile Include="msg_handler.cpp" /> | 207 | <ClCompile Include="msg_handler.cpp" /> |
| 207 | <ClCompile Include="string_util.cpp" /> | 208 | <ClCompile Include="string_util.cpp" /> |
| 209 | <ClCompile Include="symbols.cpp" /> | ||
| 208 | <ClCompile Include="thread.cpp" /> | 210 | <ClCompile Include="thread.cpp" /> |
| 209 | <ClCompile Include="timer.cpp" /> | 211 | <ClCompile Include="timer.cpp" /> |
| 210 | <ClCompile Include="utf8.cpp" /> | 212 | <ClCompile Include="utf8.cpp" /> |
diff --git a/src/common/common.vcxproj.filters b/src/common/common.vcxproj.filters index 3bdaa973f..bd4d27b58 100644 --- a/src/common/common.vcxproj.filters +++ b/src/common/common.vcxproj.filters | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | <ClInclude Include="thunk.h" /> | 37 | <ClInclude Include="thunk.h" /> |
| 38 | <ClInclude Include="timer.h" /> | 38 | <ClInclude Include="timer.h" /> |
| 39 | <ClInclude Include="utf8.h" /> | 39 | <ClInclude Include="utf8.h" /> |
| 40 | <ClInclude Include="symbols.h" /> | ||
| 40 | </ItemGroup> | 41 | </ItemGroup> |
| 41 | <ItemGroup> | 42 | <ItemGroup> |
| 42 | <ClCompile Include="break_points.cpp" /> | 43 | <ClCompile Include="break_points.cpp" /> |
| @@ -56,6 +57,7 @@ | |||
| 56 | <ClCompile Include="timer.cpp" /> | 57 | <ClCompile Include="timer.cpp" /> |
| 57 | <ClCompile Include="utf8.cpp" /> | 58 | <ClCompile Include="utf8.cpp" /> |
| 58 | <ClCompile Include="version.cpp" /> | 59 | <ClCompile Include="version.cpp" /> |
| 60 | <ClCompile Include="symbols.cpp" /> | ||
| 59 | </ItemGroup> | 61 | </ItemGroup> |
| 60 | <ItemGroup> | 62 | <ItemGroup> |
| 61 | <Text Include="CMakeLists.txt" /> | 63 | <Text Include="CMakeLists.txt" /> |
diff --git a/src/common/symbols.cpp b/src/common/symbols.cpp new file mode 100644 index 000000000..dcc9eeac5 --- /dev/null +++ b/src/common/symbols.cpp | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/symbols.h" | ||
| 6 | |||
| 7 | TSymbolsMap g_symbols; | ||
| 8 | |||
| 9 | namespace Symbols | ||
| 10 | { | ||
| 11 | bool HasSymbol(u32 _address) | ||
| 12 | { | ||
| 13 | return g_symbols.find(_address) != g_symbols.end(); | ||
| 14 | } | ||
| 15 | |||
| 16 | void Add(u32 _address, const std::string& _name, u32 _size, u32 _type) | ||
| 17 | { | ||
| 18 | if (!HasSymbol(_address)) | ||
| 19 | { | ||
| 20 | TSymbol symbol; | ||
| 21 | symbol.address = _address; | ||
| 22 | symbol.name = _name; | ||
| 23 | symbol.size = _size; | ||
| 24 | symbol.type = _type; | ||
| 25 | |||
| 26 | g_symbols.insert(TSymbolsPair(_address, symbol)); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | TSymbol GetSymbol(u32 _address) | ||
| 31 | { | ||
| 32 | TSymbolsMap::iterator foundSymbolItr; | ||
| 33 | TSymbol symbol; | ||
| 34 | |||
| 35 | foundSymbolItr = g_symbols.find(_address); | ||
| 36 | if (foundSymbolItr != g_symbols.end()) | ||
| 37 | { | ||
| 38 | symbol = (*foundSymbolItr).second; | ||
| 39 | } | ||
| 40 | |||
| 41 | return symbol; | ||
| 42 | } | ||
| 43 | const std::string& GetName(u32 _address) | ||
| 44 | { | ||
| 45 | return GetSymbol(_address).name; | ||
| 46 | } | ||
| 47 | |||
| 48 | void Remove(u32 _address) | ||
| 49 | { | ||
| 50 | g_symbols.erase(_address); | ||
| 51 | } | ||
| 52 | |||
| 53 | void Clear() | ||
| 54 | { | ||
| 55 | g_symbols.clear(); | ||
| 56 | } | ||
| 57 | } \ No newline at end of file | ||
diff --git a/src/common/symbols.h b/src/common/symbols.h new file mode 100644 index 000000000..b76749654 --- /dev/null +++ b/src/common/symbols.h | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include <map> | ||
| 8 | |||
| 9 | #include "common/common.h" | ||
| 10 | |||
| 11 | class DebugInterface; | ||
| 12 | |||
| 13 | struct TSymbol | ||
| 14 | { | ||
| 15 | TSymbol() : | ||
| 16 | address(0), | ||
| 17 | size(0), | ||
| 18 | type(0) | ||
| 19 | {} | ||
| 20 | u32 address; | ||
| 21 | std::string name; | ||
| 22 | u32 size; | ||
| 23 | u32 type; | ||
| 24 | }; | ||
| 25 | |||
| 26 | typedef std::map<u32, TSymbol> TSymbolsMap; | ||
| 27 | typedef std::pair<u32, TSymbol> TSymbolsPair; | ||
| 28 | |||
| 29 | namespace Symbols | ||
| 30 | { | ||
| 31 | bool HasSymbol(u32 _address); | ||
| 32 | |||
| 33 | void Add(u32 _address, const std::string& _name, u32 _size, u32 _type); | ||
| 34 | TSymbol GetSymbol(u32 _address); | ||
| 35 | const std::string& GetName(u32 _address); | ||
| 36 | void Remove(u32 _address); | ||
| 37 | void Clear(); | ||
| 38 | }; | ||
| 39 | |||