Lime3DS/src/common/break_points.cpp

103 lines
2.7 KiB
C++
Raw Normal View History

2014-12-17 06:38:14 +01:00
// Copyright 2013 Dolphin Emulator Project / 2014 Citra Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/break_points.h"
#include "common/logging/log.h"
#include <sstream>
#include <algorithm>
2015-03-30 21:37:34 +02:00
bool BreakPoints::IsAddressBreakPoint(u32 iAddress) const
{
auto cond = [&iAddress](const TBreakPoint& bp) { return bp.iAddress == iAddress; };
auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
return it != m_BreakPoints.end();
}
2015-03-30 21:37:34 +02: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);
return it != m_BreakPoints.end();
}
BreakPoints::TBreakPointsStr BreakPoints::GetStrings() const
{
2014-04-02 00:20:08 +02:00
TBreakPointsStr bps;
for (auto breakpoint : m_BreakPoints)
2014-04-02 00:20:08 +02:00
{
if (!breakpoint.bTemporary)
2014-04-02 00:20:08 +02:00
{
std::stringstream bp;
bp << std::hex << breakpoint.iAddress << " " << (breakpoint.bOn ? "n" : "");
2014-04-02 00:20:08 +02:00
bps.push_back(bp.str());
}
}
return bps;
}
void BreakPoints::AddFromStrings(const TBreakPointsStr& bps)
{
for (auto bps_item : bps)
2014-04-02 00:20:08 +02:00
{
TBreakPoint bp;
std::stringstream bpstr;
bpstr << std::hex << bps_item;
2014-04-02 00:20:08 +02:00
bpstr >> bp.iAddress;
bp.bOn = bps_item.find("n") != bps_item.npos;
2014-04-02 00:20:08 +02:00
bp.bTemporary = false;
Add(bp);
}
}
void BreakPoints::Add(const TBreakPoint& bp)
{
2014-04-02 00:20:08 +02:00
if (!IsAddressBreakPoint(bp.iAddress))
{
m_BreakPoints.push_back(bp);
//if (jit)
// jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
}
}
void BreakPoints::Add(u32 em_address, bool temp)
{
2014-04-02 00:20:08 +02: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);
//if (jit)
// jit->GetBlockCache()->InvalidateICache(em_address, 4);
}
}
void BreakPoints::Remove(u32 em_address)
{
auto cond = [&em_address](const TBreakPoint& bp) { return bp.iAddress == em_address; };
auto it = std::find_if(m_BreakPoints.begin(), m_BreakPoints.end(), cond);
if (it != m_BreakPoints.end())
m_BreakPoints.erase(it);
}
void BreakPoints::Clear()
{
2014-04-02 00:20:08 +02:00
//if (jit)
//{
// std::for_each(m_BreakPoints.begin(), m_BreakPoints.end(),
// [](const TBreakPoint& bp)
// {
// jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4);
// }
// );
//}
2014-04-02 00:20:08 +02:00
m_BreakPoints.clear();
}