summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/break_points.cpp97
-rw-r--r--src/common/break_points.h48
2 files changed, 67 insertions, 78 deletions
diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp
index 25d34a21a..25528b864 100644
--- a/src/common/break_points.cpp
+++ b/src/common/break_points.cpp
@@ -9,32 +9,29 @@
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 (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i) 14 auto cond = [&iAddress](const TBreakPoint& bp) { return bp.iAddress == iAddress; };
15 if (i->iAddress == _iAddress) 15 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
16 return true; 16 return it != m_BreakPoints.end();
17 return false;
18} 17}
19 18
20bool BreakPoints::IsTempBreakPoint(u32 _iAddress) 19bool BreakPoints::IsTempBreakPoint(u32 iAddress)
21{ 20{
22 for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i) 21 auto cond = [&iAddress](const TBreakPoint& bp) { return bp.iAddress == iAddress && bp.bTemporary; };
23 if (i->iAddress == _iAddress && i->bTemporary) 22 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
24 return true; 23 return it != m_BreakPoints.end();
25 return false;
26} 24}
27 25
28BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const 26BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
29{ 27{
30 TBreakPointsStr bps; 28 TBreakPointsStr bps;
31 for (TBreakPoints::const_iterator i = m_BreakPoints.begin(); 29 for (auto breakpoint : m_BreakPoints)
32 i != m_BreakPoints.end(); ++i)
33 { 30 {
34 if (!i->bTemporary) 31 if (!breakpoint.bTemporary)
35 { 32 {
36 std::stringstream bp; 33 std::stringstream bp;
37 bp << std::hex << i->iAddress << " " << (i->bOn ? "n" : ""); 34 bp << std::hex << breakpoint.iAddress << " " << (breakpoint.bOn ? "n" : "");
38 bps.push_back(bp.str()); 35 bps.push_back(bp.str());
39 } 36 }
40 } 37 }
@@ -44,13 +41,13 @@ BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
44 41
45void BreakPoints::AddFromStrings(const TBreakPointsStr& bps) 42void BreakPoints::AddFromStrings(const TBreakPointsStr& bps)
46{ 43{
47 for (TBreakPointsStr::const_iterator i = bps.begin(); i != bps.end(); ++i) 44 for (auto bps_item : bps)
48 { 45 {
49 TBreakPoint bp; 46 TBreakPoint bp;
50 std::stringstream bpstr; 47 std::stringstream bpstr;
51 bpstr << std::hex << *i; 48 bpstr << std::hex << bps_item;
52 bpstr >> bp.iAddress; 49 bpstr >> bp.iAddress;
53 bp.bOn = i->find("n") != i->npos; 50 bp.bOn = bps_item.find("n") != bps_item.npos;
54 bp.bTemporary = false; 51 bp.bTemporary = false;
55 Add(bp); 52 Add(bp);
56 } 53 }
@@ -84,16 +81,10 @@ void BreakPoints::Add(u32 em_address, bool temp)
84 81
85void BreakPoints::Remove(u32 em_address) 82void BreakPoints::Remove(u32 em_address)
86{ 83{
87 for (TBreakPoints::iterator i = m_BreakPoints.begin(); i != m_BreakPoints.end(); ++i) 84 auto cond = [&em_address](const TBreakPoint& bp) { return bp.iAddress == em_address; };
88 { 85 auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
89 if (i->iAddress == em_address) 86 if (it != m_BreakPoints.end())
90 { 87 m_BreakPoints.erase(it);
91 m_BreakPoints.erase(i);
92 //if (jit)
93 // jit->GetBlockCache()->InvalidateICache(em_address, 4);
94 return;
95 }
96 }
97} 88}
98 89
99void BreakPoints::Clear() 90void BreakPoints::Clear()
@@ -107,21 +98,23 @@ void BreakPoints::Clear()
107 // } 98 // }
108 // ); 99 // );
109 //} 100 //}
110 101
111 m_BreakPoints.clear(); 102 m_BreakPoints.clear();
112} 103}
113 104
114MemChecks::TMemChecksStr MemChecks::GetStrings() const 105MemChecks::TMemChecksStr MemChecks::GetStrings() const
115{ 106{
116 TMemChecksStr mcs; 107 TMemChecksStr mcs;
117 for (TMemChecks::const_iterator i = m_MemChecks.begin(); 108 for (auto memcheck : m_MemChecks)
118 i != m_MemChecks.end(); ++i)
119 { 109 {
120 std::stringstream mc; 110 std::stringstream mc;
121 mc << std::hex << i->StartAddress; 111 mc << std::hex << memcheck.StartAddress;
122 mc << " " << (i->bRange ? i->EndAddress : i->StartAddress) << " " << 112 mc << " " << (memcheck.bRange ? memcheck.EndAddress : memcheck.StartAddress) << " "
123 (i->bRange ? "n" : "") << (i->OnRead ? "r" : "") << 113 << (memcheck.bRange ? "n" : "")
124 (i->OnWrite ? "w" : "") << (i->Log ? "l" : "") << (i->Break ? "p" : ""); 114 << (memcheck.OnRead ? "r" : "")
115 << (memcheck.OnWrite ? "w" : "")
116 << (memcheck.Log ? "l" : "")
117 << (memcheck.Break ? "p" : "");
125 mcs.push_back(mc.str()); 118 mcs.push_back(mc.str());
126 } 119 }
127 120
@@ -130,17 +123,17 @@ MemChecks::TMemChecksStr MemChecks::GetStrings() const
130 123
131void MemChecks::AddFromStrings(const TMemChecksStr& mcs) 124void MemChecks::AddFromStrings(const TMemChecksStr& mcs)
132{ 125{
133 for (TMemChecksStr::const_iterator i = mcs.begin(); i != mcs.end(); ++i) 126 for (auto mcs_item : mcs)
134 { 127 {
135 TMemCheck mc; 128 TMemCheck mc;
136 std::stringstream mcstr; 129 std::stringstream mcstr;
137 mcstr << std::hex << *i; 130 mcstr << std::hex << mcs_item;
138 mcstr >> mc.StartAddress; 131 mcstr >> mc.StartAddress;
139 mc.bRange = i->find("n") != i->npos; 132 mc.bRange = mcs_item.find("n") != mcs_item.npos;
140 mc.OnRead = i->find("r") != i->npos; 133 mc.OnRead = mcs_item.find("r") != mcs_item.npos;
141 mc.OnWrite = i->find("w") != i->npos; 134 mc.OnWrite = mcs_item.find("w") != mcs_item.npos;
142 mc.Log = i->find("l") != i->npos; 135 mc.Log = mcs_item.find("l") != mcs_item.npos;
143 mc.Break = i->find("p") != i->npos; 136 mc.Break = mcs_item.find("p") != mcs_item.npos;
144 if (mc.bRange) 137 if (mc.bRange)
145 mcstr >> mc.EndAddress; 138 mcstr >> mc.EndAddress;
146 else 139 else
@@ -149,27 +142,23 @@ void MemChecks::AddFromStrings(const TMemChecksStr& mcs)
149 } 142 }
150} 143}
151 144
152void MemChecks::Add(const TMemCheck& _rMemoryCheck) 145void MemChecks::Add(const TMemCheck& rMemoryCheck)
153{ 146{
154 if (GetMemCheck(_rMemoryCheck.StartAddress) == 0) 147 if (GetMemCheck(rMemoryCheck.StartAddress) == 0)
155 m_MemChecks.push_back(_rMemoryCheck); 148 m_MemChecks.push_back(rMemoryCheck);
156} 149}
157 150
158void MemChecks::Remove(u32 _Address) 151void MemChecks::Remove(u32 Address)
159{ 152{
160 for (TMemChecks::iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i) 153 auto cond = [&Address](const TMemCheck& mc) { return mc.StartAddress == Address; };
161 { 154 auto it = std::find_if(m_MemChecks.begin(), m_MemChecks.end(), cond);
162 if (i->StartAddress == _Address) 155 if (it != m_MemChecks.end())
163 { 156 m_MemChecks.erase(it);
164 m_MemChecks.erase(i);
165 return;
166 }
167 }
168} 157}
169 158
170TMemCheck *MemChecks::GetMemCheck(u32 address) 159TMemCheck *MemChecks::GetMemCheck(u32 address)
171{ 160{
172 for (TMemChecks::iterator i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i) 161 for (auto i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i)
173 { 162 {
174 if (i->bRange) 163 if (i->bRange)
175 { 164 {
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