mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Merge pull request #6467 from lioncash/breakpoint
Breakpoints: Remove direct usages of the JIT global
This commit is contained in:
@ -12,9 +12,9 @@
|
|||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/DebugInterface.h"
|
#include "Common/DebugInterface.h"
|
||||||
|
#include "Common/Logging/Log.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/PowerPC/JitCommon/JitBase.h"
|
#include "Core/PowerPC/JitInterface.h"
|
||||||
#include "Core/PowerPC/JitCommon/JitCache.h"
|
|
||||||
#include "Core/PowerPC/PowerPC.h"
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
|
|
||||||
bool BreakPoints::IsAddressBreakPoint(u32 address) const
|
bool BreakPoints::IsAddressBreakPoint(u32 address) const
|
||||||
@ -62,52 +62,47 @@ void BreakPoints::AddFromStrings(const TBreakPointsStr& bp_strings)
|
|||||||
|
|
||||||
void BreakPoints::Add(const TBreakPoint& bp)
|
void BreakPoints::Add(const TBreakPoint& bp)
|
||||||
{
|
{
|
||||||
if (!IsAddressBreakPoint(bp.address))
|
if (IsAddressBreakPoint(bp.address))
|
||||||
{
|
return;
|
||||||
m_breakpoints.push_back(bp);
|
|
||||||
if (g_jit)
|
m_breakpoints.push_back(bp);
|
||||||
g_jit->GetBlockCache()->InvalidateICache(bp.address, 4, true);
|
|
||||||
}
|
JitInterface::InvalidateICache(bp.address, 4, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakPoints::Add(u32 address, bool temp)
|
void BreakPoints::Add(u32 address, bool temp)
|
||||||
{
|
{
|
||||||
if (!IsAddressBreakPoint(address)) // only add new addresses
|
// Only add new addresses
|
||||||
{
|
if (IsAddressBreakPoint(address))
|
||||||
TBreakPoint bp; // breakpoint settings
|
return;
|
||||||
bp.is_enabled = true;
|
|
||||||
bp.is_temporary = temp;
|
|
||||||
bp.address = address;
|
|
||||||
|
|
||||||
m_breakpoints.push_back(bp);
|
TBreakPoint bp; // breakpoint settings
|
||||||
|
bp.is_enabled = true;
|
||||||
|
bp.is_temporary = temp;
|
||||||
|
bp.address = address;
|
||||||
|
|
||||||
if (g_jit)
|
m_breakpoints.push_back(bp);
|
||||||
g_jit->GetBlockCache()->InvalidateICache(address, 4, true);
|
|
||||||
}
|
JitInterface::InvalidateICache(address, 4, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakPoints::Remove(u32 address)
|
void BreakPoints::Remove(u32 address)
|
||||||
{
|
{
|
||||||
for (auto i = m_breakpoints.begin(); i != m_breakpoints.end(); ++i)
|
const auto iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(),
|
||||||
{
|
[address](const auto& bp) { return bp.address == address; });
|
||||||
if (i->address == address)
|
|
||||||
{
|
if (iter == m_breakpoints.cend())
|
||||||
m_breakpoints.erase(i);
|
return;
|
||||||
if (g_jit)
|
|
||||||
g_jit->GetBlockCache()->InvalidateICache(address, 4, true);
|
m_breakpoints.erase(iter);
|
||||||
return;
|
JitInterface::InvalidateICache(address, 4, true);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BreakPoints::Clear()
|
void BreakPoints::Clear()
|
||||||
{
|
{
|
||||||
if (g_jit)
|
for (const TBreakPoint& bp : m_breakpoints)
|
||||||
{
|
{
|
||||||
for (const TBreakPoint& bp : m_breakpoints)
|
JitInterface::InvalidateICache(bp.address, 4, true);
|
||||||
{
|
|
||||||
g_jit->GetBlockCache()->InvalidateICache(bp.address, 4, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_breakpoints.clear();
|
m_breakpoints.clear();
|
||||||
@ -120,8 +115,7 @@ void BreakPoints::ClearAllTemporary()
|
|||||||
{
|
{
|
||||||
if (bp->is_temporary)
|
if (bp->is_temporary)
|
||||||
{
|
{
|
||||||
if (g_jit)
|
JitInterface::InvalidateICache(bp->address, 4, true);
|
||||||
g_jit->GetBlockCache()->InvalidateICache(bp->address, 4, true);
|
|
||||||
bp = m_breakpoints.erase(bp);
|
bp = m_breakpoints.erase(bp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -171,68 +165,65 @@ void MemChecks::AddFromStrings(const TMemChecksStr& mc_strings)
|
|||||||
|
|
||||||
void MemChecks::Add(const TMemCheck& memory_check)
|
void MemChecks::Add(const TMemCheck& memory_check)
|
||||||
{
|
{
|
||||||
if (GetMemCheck(memory_check.start_address) == nullptr)
|
if (GetMemCheck(memory_check.start_address) != nullptr)
|
||||||
{
|
return;
|
||||||
bool had_any = HasAny();
|
|
||||||
Core::RunAsCPUThread([&] {
|
bool had_any = HasAny();
|
||||||
m_mem_checks.push_back(memory_check);
|
Core::RunAsCPUThread([&] {
|
||||||
// If this is the first one, clear the JIT cache so it can switch to
|
m_mem_checks.push_back(memory_check);
|
||||||
// watchpoint-compatible code.
|
// If this is the first one, clear the JIT cache so it can switch to
|
||||||
if (!had_any && g_jit)
|
// watchpoint-compatible code.
|
||||||
g_jit->ClearCache();
|
if (!had_any)
|
||||||
PowerPC::DBATUpdated();
|
JitInterface::ClearCache();
|
||||||
});
|
PowerPC::DBATUpdated();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemChecks::Remove(u32 address)
|
void MemChecks::Remove(u32 address)
|
||||||
{
|
{
|
||||||
for (auto i = m_mem_checks.begin(); i != m_mem_checks.end(); ++i)
|
const auto iter =
|
||||||
{
|
std::find_if(m_mem_checks.cbegin(), m_mem_checks.cend(),
|
||||||
if (i->start_address == address)
|
[address](const auto& check) { return check.start_address == address; });
|
||||||
{
|
|
||||||
Core::RunAsCPUThread([&] {
|
if (iter == m_mem_checks.cend())
|
||||||
m_mem_checks.erase(i);
|
return;
|
||||||
if (!HasAny() && g_jit)
|
|
||||||
g_jit->ClearCache();
|
Core::RunAsCPUThread([&] {
|
||||||
PowerPC::DBATUpdated();
|
m_mem_checks.erase(iter);
|
||||||
});
|
if (!HasAny())
|
||||||
return;
|
JitInterface::ClearCache();
|
||||||
}
|
PowerPC::DBATUpdated();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
TMemCheck* MemChecks::GetMemCheck(u32 address, size_t size)
|
TMemCheck* MemChecks::GetMemCheck(u32 address, size_t size)
|
||||||
{
|
{
|
||||||
for (TMemCheck& mc : m_mem_checks)
|
const auto iter =
|
||||||
{
|
std::find_if(m_mem_checks.begin(), m_mem_checks.end(), [address, size](const auto& mc) {
|
||||||
if (mc.end_address >= address && address + size - 1 >= mc.start_address)
|
return mc.end_address >= address && address + size - 1 >= mc.start_address;
|
||||||
{
|
});
|
||||||
return &mc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// none found
|
// None found
|
||||||
return nullptr;
|
if (iter == m_mem_checks.cend())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return &*iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MemChecks::OverlapsMemcheck(u32 address, u32 length)
|
bool MemChecks::OverlapsMemcheck(u32 address, u32 length)
|
||||||
{
|
{
|
||||||
if (!HasAny())
|
if (!HasAny())
|
||||||
return false;
|
return false;
|
||||||
u32 page_end_suffix = length - 1;
|
|
||||||
u32 page_end_address = address | page_end_suffix;
|
const u32 page_end_suffix = length - 1;
|
||||||
for (TMemCheck memcheck : m_mem_checks)
|
const u32 page_end_address = address | page_end_suffix;
|
||||||
{
|
|
||||||
if (((memcheck.start_address | page_end_suffix) == page_end_address ||
|
return std::any_of(m_mem_checks.cbegin(), m_mem_checks.cend(), [&](const auto& mc) {
|
||||||
(memcheck.end_address | page_end_suffix) == page_end_address) ||
|
return ((mc.start_address | page_end_suffix) == page_end_address ||
|
||||||
((memcheck.start_address | page_end_suffix) < page_end_address &&
|
(mc.end_address | page_end_suffix) == page_end_address) ||
|
||||||
(memcheck.end_address | page_end_suffix) > page_end_address))
|
((mc.start_address | page_end_suffix) < page_end_address &&
|
||||||
{
|
(mc.end_address | page_end_suffix) > page_end_address);
|
||||||
return true;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TMemCheck::Action(DebugInterface* debug_interface, u32 value, u32 addr, bool write,
|
bool TMemCheck::Action(DebugInterface* debug_interface, u32 value, u32 addr, bool write,
|
||||||
@ -288,22 +279,23 @@ void Watches::AddFromStrings(const TWatchesStr& watch_strings)
|
|||||||
|
|
||||||
void Watches::Add(const TWatch& watch)
|
void Watches::Add(const TWatch& watch)
|
||||||
{
|
{
|
||||||
if (!IsAddressWatch(watch.address))
|
if (IsAddressWatch(watch.address))
|
||||||
{
|
return;
|
||||||
m_watches.push_back(watch);
|
|
||||||
}
|
m_watches.push_back(watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Watches::Add(u32 address)
|
void Watches::Add(u32 address)
|
||||||
{
|
{
|
||||||
if (!IsAddressWatch(address)) // only add new addresses
|
// Only add new addresses
|
||||||
{
|
if (IsAddressWatch(address))
|
||||||
TWatch watch; // watch settings
|
return;
|
||||||
watch.is_enabled = true;
|
|
||||||
watch.address = address;
|
|
||||||
|
|
||||||
m_watches.push_back(watch);
|
TWatch watch; // watch settings
|
||||||
}
|
watch.is_enabled = true;
|
||||||
|
watch.address = address;
|
||||||
|
|
||||||
|
m_watches.push_back(watch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Watches::Update(int count, u32 address)
|
void Watches::Update(int count, u32 address)
|
||||||
@ -318,14 +310,13 @@ void Watches::UpdateName(int count, const std::string name)
|
|||||||
|
|
||||||
void Watches::Remove(u32 address)
|
void Watches::Remove(u32 address)
|
||||||
{
|
{
|
||||||
for (auto i = m_watches.begin(); i != m_watches.end(); ++i)
|
const auto iter = std::find_if(m_watches.cbegin(), m_watches.cend(),
|
||||||
{
|
[address](const auto& watch) { return watch.address == address; });
|
||||||
if (i->address == address)
|
|
||||||
{
|
if (iter == m_watches.cend())
|
||||||
m_watches.erase(i);
|
return;
|
||||||
return;
|
|
||||||
}
|
m_watches.erase(iter);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Watches::Clear()
|
void Watches::Clear()
|
||||||
|
Reference in New Issue
Block a user