From d046cfbba1dd2bcdad4ace3be706dadf3f6cc288 Mon Sep 17 00:00:00 2001 From: Mathieu Vaillancourt Date: Sat, 12 Apr 2014 18:57:58 -0400 Subject: [PATCH] Add symbols map --- src/common/common.vcxproj | 2 ++ src/common/common.vcxproj.filters | 2 ++ src/common/symbols.cpp | 57 +++++++++++++++++++++++++++++++ src/common/symbols.h | 39 +++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 src/common/symbols.cpp create mode 100644 src/common/symbols.h 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 @@ + @@ -205,6 +206,7 @@ + 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 @@ + @@ -56,6 +57,7 @@ + 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 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#include "common/symbols.h" + +TSymbolsMap g_symbols; + +namespace Symbols +{ + bool HasSymbol(u32 _address) + { + return g_symbols.find(_address) != g_symbols.end(); + } + + void Add(u32 _address, const std::string& _name, u32 _size, u32 _type) + { + if (!HasSymbol(_address)) + { + TSymbol symbol; + symbol.address = _address; + symbol.name = _name; + symbol.size = _size; + symbol.type = _type; + + g_symbols.insert(TSymbolsPair(_address, symbol)); + } + } + + TSymbol GetSymbol(u32 _address) + { + TSymbolsMap::iterator foundSymbolItr; + TSymbol symbol; + + foundSymbolItr = g_symbols.find(_address); + if (foundSymbolItr != g_symbols.end()) + { + symbol = (*foundSymbolItr).second; + } + + return symbol; + } + const std::string& GetName(u32 _address) + { + return GetSymbol(_address).name; + } + + void Remove(u32 _address) + { + g_symbols.erase(_address); + } + + void Clear() + { + g_symbols.clear(); + } +} \ 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 @@ +// Copyright 2014 Citra Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "common/common.h" + +class DebugInterface; + +struct TSymbol +{ + TSymbol() : + address(0), + size(0), + type(0) + {} + u32 address; + std::string name; + u32 size; + u32 type; +}; + +typedef std::map TSymbolsMap; +typedef std::pair TSymbolsPair; + +namespace Symbols +{ + bool HasSymbol(u32 _address); + + void Add(u32 _address, const std::string& _name, u32 _size, u32 _type); + TSymbol GetSymbol(u32 _address); + const std::string& GetName(u32 _address); + void Remove(u32 _address); + void Clear(); +}; +