summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/break_points.cpp62
-rw-r--r--src/common/break_points.h48
2 files changed, 51 insertions, 59 deletions
diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp
index 4e04a06ff..392b8530b 100644
--- a/src/common/break_points.cpp
+++ b/src/common/break_points.cpp
@@ -9,19 +9,21 @@
9#include <sstream> 9#include <sstream>
10#include <algorithm> 10#include <algorithm>
11 11
12bool BreakPoints::IsAddressBreakPoint(u32 _iAddress) 12bool BreakPoints::IsAddressBreakPoint(u32 iAddress)
13{ 13{
14 for (auto breakpoint : m_BreakPoints) 14 auto cond = [&iAddress](const TBreakPoint& bp) { return bp.iAddress == iAddress; };
15 if (breakpoint.iAddress == _iAddress) 15 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
16 return true; 16 if (it != m_BreakPoints.end())
17 return true;
17 return false; 18 return false;
18} 19}
19 20
20bool BreakPoints::IsTempBreakPoint(u32 _iAddress) 21bool BreakPoints::IsTempBreakPoint(u32 iAddress)
21{ 22{
22 for (auto breakpoint : m_BreakPoints) 23 auto cond = [&iAddress](const TBreakPoint& bp) { return bp.iAddress == iAddress && bp.bTemporary; };
23 if (breakpoint.iAddress == _iAddress && breakpoint.bTemporary) 24 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
24 return true; 25 if (it != m_BreakPoints.end())
26 return true;
25 return false; 27 return false;
26} 28}
27 29
@@ -83,16 +85,10 @@ void BreakPoints::Add(u32 em_address, bool temp)
83 85
84void BreakPoints::Remove(u32 em_address) 86void BreakPoints::Remove(u32 em_address)
85{ 87{
86 for (auto i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i) 88 auto cond = [&em_address](const TBreakPoint& bp) { return bp.iAddress == em_address; };
87 { 89 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
88 if (i->iAddress == em_address) 90 if (it != m_BreakPoints.end())
89 { 91 m_BreakPoints.erase(it);
90 m_BreakPoints.erase(i);
91 //if (jit)
92 // jit->GetBlockCache()->InvalidateICache(em_address, 4);
93 return;
94 }
95 }
96} 92}
97 93
98void BreakPoints::Clear() 94void BreakPoints::Clear()
@@ -106,7 +102,7 @@ void BreakPoints::Clear()
106 // } 102 // }
107 // ); 103 // );
108 //} 104 //}
109 105
110 m_BreakPoints.clear(); 106 m_BreakPoints.clear();
111} 107}
112 108
@@ -118,10 +114,10 @@ MemChecks::TMemChecksStr MemChecks::GetStrings() const
118 std::stringstream mc; 114 std::stringstream mc;
119 mc << std::hex << memcheck.StartAddress; 115 mc << std::hex << memcheck.StartAddress;
120 mc << " " << (memcheck.bRange ? memcheck.EndAddress : memcheck.StartAddress) << " " 116 mc << " " << (memcheck.bRange ? memcheck.EndAddress : memcheck.StartAddress) << " "
121 << (memcheck.bRange ? "n" : "") 117 << (memcheck.bRange ? "n" : "")
122 << (memcheck.OnRead ? "r" : "") 118 << (memcheck.OnRead ? "r" : "")
123 << (memcheck.OnWrite ? "w" : "") 119 << (memcheck.OnWrite ? "w" : "")
124 << (memcheck.Log ? "l" : "") 120 << (memcheck.Log ? "l" : "")
125 << (memcheck.Break ? "p" : ""); 121 << (memcheck.Break ? "p" : "");
126 mcs.push_back(mc.str()); 122 mcs.push_back(mc.str());
127 } 123 }
@@ -150,22 +146,18 @@ void MemChecks::AddFromStrings(const TMemChecksStr& mcs)
150 } 146 }
151} 147}
152 148
153void MemChecks::Add(const TMemCheck& _rMemoryCheck) 149void MemChecks::Add(const TMemCheck& rMemoryCheck)
154{ 150{
155 if (GetMemCheck(_rMemoryCheck.StartAddress) == 0) 151 if (GetMemCheck(rMemoryCheck.StartAddress) == 0)
156 m_MemChecks.push_back(_rMemoryCheck); 152 m_MemChecks.push_back(rMemoryCheck);
157} 153}
158 154
159void MemChecks::Remove(u32 _Address) 155void MemChecks::Remove(u32 Address)
160{ 156{
161 for (auto i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i) 157 auto cond = [&Address](const TMemCheck& mc) { return mc.StartAddress == Address; };
162 { 158 auto it = std::find_if(m_MemChecks.begin(), m_MemChecks.end(), cond);
163 if (i->StartAddress == _Address) 159 if (it != m_MemChecks.end())
164 { 160 m_MemChecks.erase(it);
165 m_MemChecks.erase(i);
166 return;
167 }
168 }
169} 161}
170 162
171TMemCheck *MemChecks::GetMemCheck(u32 address) 163TMemCheck *MemChecks::GetMemCheck(u32 address)
diff --git a/src/common/break_points.h b/src/common/break_points.h
index 46df34665..da14ca7f3 100644
--- a/src/common/break_points.h
+++ b/src/common/break_points.h
@@ -14,32 +14,33 @@ class DebugInterface;
14 14
15struct TBreakPoint 15struct TBreakPoint
16{ 16{
17 u32 iAddress; 17 u32 iAddress;
18 bool bOn; 18 bool bOn;
19 bool bTemporary; 19 bool bTemporary;
20}; 20};
21 21
22struct TMemCheck 22struct TMemCheck
23{ 23{
24 TMemCheck() { 24 TMemCheck():
25 numHits = 0; 25 StartAddress(0), EndAddress(0),
26 StartAddress = EndAddress = 0; 26 bRange(false), OnRead(false), OnWrite(false),
27 bRange = OnRead = OnWrite = Log = Break = false; 27 Log(false), Break(false), numHits(0)
28 } 28 { }
29 u32 StartAddress;
30 u32 EndAddress;
31 29
32 bool bRange; 30 u32 StartAddress;
31 u32 EndAddress;
33 32
34 bool OnRead; 33 bool bRange;
35 bool OnWrite;
36 34
37 bool Log; 35 bool OnRead;
38 bool Break; 36 bool OnWrite;
39 37
40 u32 numHits; 38 bool Log;
39 bool Break;
41 40
42 void Action(DebugInterface *dbg_interface, u32 _iValue, u32 addr, 41 u32 numHits;
42
43 void Action(DebugInterface *dbg_interface, u32 iValue, u32 addr,
43 bool write, int size, u32 pc); 44 bool write, int size, u32 pc);
44}; 45};
45 46
@@ -56,22 +57,22 @@ public:
56 void AddFromStrings(const TBreakPointsStr& bps); 57 void AddFromStrings(const TBreakPointsStr& bps);
57 58
58 // is address breakpoint 59 // is address breakpoint
59 bool IsAddressBreakPoint(u32 _iAddress); 60 bool IsAddressBreakPoint(u32 iAddress);
60 bool IsTempBreakPoint(u32 _iAddress); 61 bool IsTempBreakPoint(u32 iAddress);
61 62
62 // Add BreakPoint 63 // Add BreakPoint
63 void Add(u32 em_address, bool temp=false); 64 void Add(u32 em_address, bool temp=false);
64 void Add(const TBreakPoint& bp); 65 void Add(const TBreakPoint& bp);
65 66
66 // Remove Breakpoint 67 // Remove Breakpoint
67 void Remove(u32 _iAddress); 68 void Remove(u32 iAddress);
68 void Clear(); 69 void Clear();
69 70
70 void DeleteByAddress(u32 _Address); 71 void DeleteByAddress(u32 Address);
71 72
72private: 73private:
73 TBreakPoints m_BreakPoints; 74 TBreakPoints m_BreakPoints;
74 u32 m_iBreakOnCount; 75 u32 m_iBreakOnCount;
75}; 76};
76 77
77 78
@@ -89,7 +90,7 @@ public:
89 TMemChecksStr GetStrings() const; 90 TMemChecksStr GetStrings() const;
90 void AddFromStrings(const TMemChecksStr& mcs); 91 void AddFromStrings(const TMemChecksStr& mcs);
91 92
92 void Add(const TMemCheck& _rMemoryCheck); 93 void Add(const TMemCheck& rMemoryCheck);
93 94
94 // memory breakpoint 95 // memory breakpoint
95 TMemCheck *GetMemCheck(u32 address); 96 TMemCheck *GetMemCheck(u32 address);
@@ -99,4 +100,3 @@ public:
99}; 100};
100 101
101#endif 102#endif
102