2014-12-17 05:38:14 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
2013-09-05 00:17:46 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-04-09 00:15:08 +00:00
|
|
|
#include "common/break_points.h"
|
2013-09-05 00:17:46 +00:00
|
|
|
#include <algorithm>
|
2016-09-18 00:38:01 +00:00
|
|
|
#include <sstream>
|
2016-09-20 15:21:23 +00:00
|
|
|
#include "common/logging/log.h"
|
2013-09-05 00:17:46 +00:00
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
bool BreakPoints::IsAddressBreakPoint(u32 iAddress) const {
|
2014-08-12 10:44:12 +00:00
|
|
|
auto cond = [&iAddress](const TBreakPoint& bp) { return bp.iAddress == iAddress; };
|
2016-09-18 00:38:01 +00:00
|
|
|
auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
|
2014-08-12 11:04:54 +00:00
|
|
|
return it != m_BreakPoints.end();
|
2013-09-05 00:17:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
bool BreakPoints::IsTempBreakPoint(u32 iAddress) const {
|
|
|
|
auto cond = [&iAddress](const TBreakPoint& bp) {
|
|
|
|
return bp.iAddress == iAddress && bp.bTemporary;
|
|
|
|
};
|
|
|
|
auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
|
2014-08-12 11:04:54 +00:00
|
|
|
return it != m_BreakPoints.end();
|
2013-09-05 00:17:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const {
|
2014-04-01 22:20:08 +00:00
|
|
|
TBreakPointsStr bps;
|
2016-09-18 00:38:01 +00:00
|
|
|
for (auto breakpoint : m_BreakPoints) {
|
|
|
|
if (!breakpoint.bTemporary) {
|
2014-04-01 22:20:08 +00:00
|
|
|
std::stringstream bp;
|
2014-08-12 00:44:59 +00:00
|
|
|
bp << std::hex << breakpoint.iAddress << " " << (breakpoint.bOn ? "n" : "");
|
2014-04-01 22:20:08 +00:00
|
|
|
bps.push_back(bp.str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bps;
|
2013-09-05 00:17:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
void BreakPoints::AddFromStrings(const TBreakPointsStr& bps) {
|
|
|
|
for (auto bps_item : bps) {
|
2014-04-01 22:20:08 +00:00
|
|
|
TBreakPoint bp;
|
|
|
|
std::stringstream bpstr;
|
2014-08-12 00:44:59 +00:00
|
|
|
bpstr << std::hex << bps_item;
|
2014-04-01 22:20:08 +00:00
|
|
|
bpstr >> bp.iAddress;
|
2014-08-12 00:44:59 +00:00
|
|
|
bp.bOn = bps_item.find("n") != bps_item.npos;
|
2014-04-01 22:20:08 +00:00
|
|
|
bp.bTemporary = false;
|
|
|
|
Add(bp);
|
|
|
|
}
|
2013-09-05 00:17:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
void BreakPoints::Add(const TBreakPoint& bp) {
|
|
|
|
if (!IsAddressBreakPoint(bp.iAddress)) {
|
2014-04-01 22:20:08 +00:00
|
|
|
m_BreakPoints.push_back(bp);
|
2016-09-18 00:38:01 +00:00
|
|
|
// if (jit)
|
2014-04-01 22:20:08 +00:00
|
|
|
// jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
|
|
|
|
}
|
2013-09-05 00:17:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
void BreakPoints::Add(u32 em_address, bool temp) {
|
2014-04-01 22:20:08 +00:00
|
|
|
if (!IsAddressBreakPoint(em_address)) // only add new addresses
|
|
|
|
{
|
|
|
|
TBreakPoint pt; // breakpoint settings
|
|
|
|
pt.bOn = true;
|
|
|
|
pt.bTemporary = temp;
|
|
|
|
pt.iAddress = em_address;
|
|
|
|
|
|
|
|
m_BreakPoints.push_back(pt);
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
// if (jit)
|
2014-04-01 22:20:08 +00:00
|
|
|
// jit->GetBlockCache()->InvalidateICache(em_address, 4);
|
|
|
|
}
|
2013-09-05 00:17:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
void BreakPoints::Remove(u32 em_address) {
|
2014-08-12 10:44:12 +00:00
|
|
|
auto cond = [&em_address](const TBreakPoint& bp) { return bp.iAddress == em_address; };
|
2016-09-18 00:38:01 +00:00
|
|
|
auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
|
2014-08-12 10:44:12 +00:00
|
|
|
if (it != m_BreakPoints.end())
|
|
|
|
m_BreakPoints.erase(it);
|
2013-09-05 00:17:46 +00:00
|
|
|
}
|
|
|
|
|
2016-09-18 00:38:01 +00:00
|
|
|
void BreakPoints::Clear() {
|
|
|
|
// if (jit)
|
2014-04-01 22:20:08 +00:00
|
|
|
//{
|
|
|
|
// std::for_each(m_BreakPoints.begin(), m_BreakPoints.end(),
|
|
|
|
// [](const TBreakPoint& bp)
|
|
|
|
// {
|
|
|
|
// jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
|
|
|
|
// }
|
|
|
|
// );
|
|
|
|
//}
|
2014-08-12 10:44:12 +00:00
|
|
|
|
2014-04-01 22:20:08 +00:00
|
|
|
m_BreakPoints.clear();
|
2013-09-05 00:17:46 +00:00
|
|
|
}
|