BreakPoints.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. // Copyright 2008 Dolphin Emulator Project
  2. // Licensed under GPLv2+
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <string>
  6. #include <vector>
  7. #include "Common/CommonTypes.h"
  8. class DebugInterface;
  9. struct TBreakPoint
  10. {
  11. u32 iAddress;
  12. bool bOn;
  13. bool bTemporary;
  14. };
  15. struct TMemCheck
  16. {
  17. TMemCheck()
  18. {
  19. numHits = 0;
  20. StartAddress = EndAddress = 0;
  21. bRange = OnRead = OnWrite = Log = Break = false;
  22. }
  23. u32 StartAddress;
  24. u32 EndAddress;
  25. bool bRange;
  26. bool OnRead;
  27. bool OnWrite;
  28. bool Log;
  29. bool Break;
  30. u32 numHits;
  31. // returns whether to break
  32. bool Action(DebugInterface *dbg_interface, u32 _iValue, u32 addr,
  33. bool write, int size, u32 pc);
  34. };
  35. struct TWatch
  36. {
  37. std::string name = "";
  38. u32 iAddress;
  39. bool bOn;
  40. };
  41. // Code breakpoints.
  42. class BreakPoints
  43. {
  44. public:
  45. typedef std::vector<TBreakPoint> TBreakPoints;
  46. typedef std::vector<std::string> TBreakPointsStr;
  47. const TBreakPoints& GetBreakPoints() { return m_BreakPoints; }
  48. TBreakPointsStr GetStrings() const;
  49. void AddFromStrings(const TBreakPointsStr& bps);
  50. // is address breakpoint
  51. bool IsAddressBreakPoint(u32 address) const;
  52. bool IsTempBreakPoint(u32 address) const;
  53. // Add BreakPoint
  54. void Add(u32 em_address, bool temp = false);
  55. void Add(const TBreakPoint& bp);
  56. // Remove Breakpoint
  57. void Remove(u32 _iAddress);
  58. void Clear();
  59. void ClearAllTemporary();
  60. void DeleteByAddress(u32 _Address);
  61. private:
  62. TBreakPoints m_BreakPoints;
  63. u32 m_iBreakOnCount;
  64. };
  65. // Memory breakpoints
  66. class MemChecks
  67. {
  68. public:
  69. typedef std::vector<TMemCheck> TMemChecks;
  70. typedef std::vector<std::string> TMemChecksStr;
  71. TMemChecks m_MemChecks;
  72. const TMemChecks& GetMemChecks() { return m_MemChecks; }
  73. TMemChecksStr GetStrings() const;
  74. void AddFromStrings(const TMemChecksStr& mcs);
  75. void Add(const TMemCheck& _rMemoryCheck);
  76. // memory breakpoint
  77. TMemCheck *GetMemCheck(u32 address);
  78. void Remove(u32 _Address);
  79. void Clear() { m_MemChecks.clear(); }
  80. bool HasAny() const { return !m_MemChecks.empty(); }
  81. };
  82. class Watches
  83. {
  84. public:
  85. typedef std::vector<TWatch> TWatches;
  86. typedef std::vector<std::string> TWatchesStr;
  87. const TWatches& GetWatches() { return m_Watches; }
  88. TWatchesStr GetStrings() const;
  89. void AddFromStrings(const TWatchesStr& bps);
  90. bool IsAddressWatch(u32 _iAddress) const;
  91. // Add BreakPoint
  92. void Add(u32 em_address);
  93. void Add(const TWatch& bp);
  94. void Update(int count, u32 em_address);
  95. void UpdateName(int count, const std::string name);
  96. // Remove Breakpoint
  97. void Remove(u32 _iAddress);
  98. void Clear();
  99. void DeleteByAddress(u32 _Address);
  100. private:
  101. TWatches m_Watches;
  102. };