PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Source/Core/Common/SymbolDB.cpp

https://github.com/bunnei/dolphin
C++ | 56 lines | 44 code | 8 blank | 4 comment | 5 complexity | d660fd88ed762f5a68258be9d311451d MD5 | raw file
Possible License(s): GPL-2.0
  1. // Copyright 2013 Dolphin Emulator Project
  2. // Licensed under GPLv2
  3. // Refer to the license.txt file included.
  4. #include <cstring>
  5. #include <map>
  6. #include <string>
  7. #include <utility>
  8. #include "Common/Common.h"
  9. #include "Common/SymbolDB.h"
  10. void SymbolDB::List()
  11. {
  12. for (const auto& func : functions)
  13. {
  14. DEBUG_LOG(OSHLE, "%s @ %08x: %i bytes (hash %08x) : %i calls",
  15. func.second.name.c_str(), func.second.address,
  16. func.second.size, func.second.hash,
  17. func.second.numCalls);
  18. }
  19. INFO_LOG(OSHLE, "%lu functions known in this program above.",
  20. (unsigned long)functions.size());
  21. }
  22. void SymbolDB::Clear(const char *prefix)
  23. {
  24. // TODO: honor prefix
  25. functions.clear();
  26. checksumToFunction.clear();
  27. }
  28. void SymbolDB::Index()
  29. {
  30. int i = 0;
  31. for (auto& func : functions)
  32. {
  33. func.second.index = i++;
  34. }
  35. }
  36. Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
  37. {
  38. for (auto& func : functions)
  39. {
  40. if (func.second.name == name)
  41. return &func.second;
  42. }
  43. return nullptr;
  44. }
  45. void SymbolDB::AddCompleteSymbol(const Symbol &symbol)
  46. {
  47. functions.insert(std::pair<u32, Symbol>(symbol.address, symbol));
  48. }