diff options
| author | 2015-09-11 09:47:36 -0400 | |
|---|---|---|
| committer | 2015-09-11 09:47:36 -0400 | |
| commit | ef622a07ffc95a1cd3229556244a0fa887cf2e6f (patch) | |
| tree | a070f5ee545eebd76fc685f43ae5e1ce857055bb /src/common/break_points.cpp | |
| parent | Merge pull request #1145 from lioncash/cast (diff) | |
| parent | common: Get rid of debug_interface.h (diff) | |
| download | yuzu-ef622a07ffc95a1cd3229556244a0fa887cf2e6f.tar.gz yuzu-ef622a07ffc95a1cd3229556244a0fa887cf2e6f.tar.xz yuzu-ef622a07ffc95a1cd3229556244a0fa887cf2e6f.zip | |
Merge pull request #1144 from lioncash/remove
common: Get rid of debug_interface.h
Diffstat (limited to 'src/common/break_points.cpp')
| -rw-r--r-- | src/common/break_points.cpp | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/src/common/break_points.cpp b/src/common/break_points.cpp index 023a485a4..e7d0d3e43 100644 --- a/src/common/break_points.cpp +++ b/src/common/break_points.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/debug_interface.h" | ||
| 6 | #include "common/break_points.h" | 5 | #include "common/break_points.h" |
| 7 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 8 | 7 | ||
| @@ -101,92 +100,3 @@ void BreakPoints::Clear() | |||
| 101 | 100 | ||
| 102 | m_BreakPoints.clear(); | 101 | m_BreakPoints.clear(); |
| 103 | } | 102 | } |
| 104 | |||
| 105 | MemChecks::TMemChecksStr MemChecks::GetStrings() const | ||
| 106 | { | ||
| 107 | TMemChecksStr mcs; | ||
| 108 | for (auto memcheck : m_MemChecks) | ||
| 109 | { | ||
| 110 | std::stringstream mc; | ||
| 111 | mc << std::hex << memcheck.StartAddress; | ||
| 112 | mc << " " << (memcheck.bRange ? memcheck.EndAddress : memcheck.StartAddress) << " " | ||
| 113 | << (memcheck.bRange ? "n" : "") | ||
| 114 | << (memcheck.OnRead ? "r" : "") | ||
| 115 | << (memcheck.OnWrite ? "w" : "") | ||
| 116 | << (memcheck.Log ? "l" : "") | ||
| 117 | << (memcheck.Break ? "p" : ""); | ||
| 118 | mcs.push_back(mc.str()); | ||
| 119 | } | ||
| 120 | |||
| 121 | return mcs; | ||
| 122 | } | ||
| 123 | |||
| 124 | void MemChecks::AddFromStrings(const TMemChecksStr& mcs) | ||
| 125 | { | ||
| 126 | for (auto mcs_item : mcs) | ||
| 127 | { | ||
| 128 | TMemCheck mc; | ||
| 129 | std::stringstream mcstr; | ||
| 130 | mcstr << std::hex << mcs_item; | ||
| 131 | mcstr >> mc.StartAddress; | ||
| 132 | mc.bRange = mcs_item.find("n") != mcs_item.npos; | ||
| 133 | mc.OnRead = mcs_item.find("r") != mcs_item.npos; | ||
| 134 | mc.OnWrite = mcs_item.find("w") != mcs_item.npos; | ||
| 135 | mc.Log = mcs_item.find("l") != mcs_item.npos; | ||
| 136 | mc.Break = mcs_item.find("p") != mcs_item.npos; | ||
| 137 | if (mc.bRange) | ||
| 138 | mcstr >> mc.EndAddress; | ||
| 139 | else | ||
| 140 | mc.EndAddress = mc.StartAddress; | ||
| 141 | Add(mc); | ||
| 142 | } | ||
| 143 | } | ||
| 144 | |||
| 145 | void MemChecks::Add(const TMemCheck& rMemoryCheck) | ||
| 146 | { | ||
| 147 | if (GetMemCheck(rMemoryCheck.StartAddress) == 0) | ||
| 148 | m_MemChecks.push_back(rMemoryCheck); | ||
| 149 | } | ||
| 150 | |||
| 151 | void MemChecks::Remove(u32 Address) | ||
| 152 | { | ||
| 153 | auto cond = [&Address](const TMemCheck& mc) { return mc.StartAddress == Address; }; | ||
| 154 | auto it = std::find_if(m_MemChecks.begin(), m_MemChecks.end(), cond); | ||
| 155 | if (it != m_MemChecks.end()) | ||
| 156 | m_MemChecks.erase(it); | ||
| 157 | } | ||
| 158 | |||
| 159 | TMemCheck *MemChecks::GetMemCheck(u32 address) | ||
| 160 | { | ||
| 161 | for (auto i = m_MemChecks.begin(); i != m_MemChecks.end(); ++i) | ||
| 162 | { | ||
| 163 | if (i->bRange) | ||
| 164 | { | ||
| 165 | if (address >= i->StartAddress && address <= i->EndAddress) | ||
| 166 | return &(*i); | ||
| 167 | } | ||
| 168 | else if (i->StartAddress == address) | ||
| 169 | return &(*i); | ||
| 170 | } | ||
| 171 | |||
| 172 | // none found | ||
| 173 | return 0; | ||
| 174 | } | ||
| 175 | |||
| 176 | void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, | ||
| 177 | bool write, int size, u32 pc) | ||
| 178 | { | ||
| 179 | if ((write && OnWrite) || (!write && OnRead)) | ||
| 180 | { | ||
| 181 | if (Log) | ||
| 182 | { | ||
| 183 | LOG_DEBUG(Debug_Breakpoint, "CHK %08x (%s) %s%i %0*x at %08x (%s)", | ||
| 184 | pc, debug_interface->getDescription(pc).c_str(), | ||
| 185 | write ? "Write" : "Read", size*8, size*2, iValue, addr, | ||
| 186 | debug_interface->getDescription(addr).c_str() | ||
| 187 | ); | ||
| 188 | } | ||
| 189 | if (Break) | ||
| 190 | debug_interface->breakNow(); | ||
| 191 | } | ||
| 192 | } | ||