SymbolDB.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2009 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/CommonTypes.h"
  9. #include "Common/SymbolDB.h"
  10. #include "Common/Logging/Log.h"
  11. void SymbolDB::List()
  12. {
  13. for (const auto& func : functions)
  14. {
  15. DEBUG_LOG(OSHLE, "%s @ %08x: %i bytes (hash %08x) : %i calls",
  16. func.second.name.c_str(), func.second.address,
  17. func.second.size, func.second.hash,
  18. func.second.numCalls);
  19. }
  20. INFO_LOG(OSHLE, "%lu functions known in this program above.",
  21. (unsigned long)functions.size());
  22. }
  23. void SymbolDB::Clear(const char *prefix)
  24. {
  25. // TODO: honor prefix
  26. functions.clear();
  27. checksumToFunction.clear();
  28. }
  29. void SymbolDB::Index()
  30. {
  31. int i = 0;
  32. for (auto& func : functions)
  33. {
  34. func.second.index = i++;
  35. }
  36. }
  37. Symbol* SymbolDB::GetSymbolFromName(const std::string& name)
  38. {
  39. for (auto& func : functions)
  40. {
  41. if (func.second.name == name)
  42. return &func.second;
  43. }
  44. return nullptr;
  45. }
  46. void SymbolDB::AddCompleteSymbol(const Symbol &symbol)
  47. {
  48. functions.insert(std::pair<u32, Symbol>(symbol.address, symbol));
  49. }