Debugger BreakpointWidget: Allow editing breakpoints

This commit is contained in:
JoshuaMK
2022-11-20 22:11:15 -06:00
committed by Admiral H. Curtiss
parent 032f54d403
commit dd2282324b
8 changed files with 199 additions and 64 deletions

View File

@ -38,11 +38,10 @@ bool BreakPoints::IsTempBreakPoint(u32 address) const
const TBreakPoint* BreakPoints::GetBreakpoint(u32 address) const
{
auto bp = std::find_if(m_breakpoints.begin(), m_breakpoints.end(), [address](const auto& bp) {
return bp.is_enabled && bp.address == address;
});
auto bp = std::find_if(m_breakpoints.begin(), m_breakpoints.end(),
[address](const auto& bp) { return bp.address == address; });
if (bp == m_breakpoints.end() || !EvaluateCondition(bp->condition))
if (bp == m_breakpoints.end())
return nullptr;
return &*bp;
@ -120,9 +119,10 @@ void BreakPoints::Add(u32 address, bool temp)
void BreakPoints::Add(u32 address, bool temp, bool break_on_hit, bool log_on_hit,
std::optional<Expression> condition)
{
// Only add new addresses
if (IsAddressBreakPoint(address))
return;
// Check for existing breakpoint, and overwrite with new info.
// This is assuming we usually want the new breakpoint over an old one.
auto iter = std::find_if(m_breakpoints.begin(), m_breakpoints.end(),
[address](const auto& bp) { return bp.address == address; });
TBreakPoint bp; // breakpoint settings
bp.is_enabled = true;
@ -132,7 +132,15 @@ void BreakPoints::Add(u32 address, bool temp, bool break_on_hit, bool log_on_hit
bp.address = address;
bp.condition = std::move(condition);
m_breakpoints.emplace_back(std::move(bp));
if (iter != m_breakpoints.end()) // We found an existing breakpoint
{
bp.is_enabled = iter->is_enabled;
*iter = std::move(bp);
}
else
{
m_breakpoints.emplace_back(std::move(bp));
}
JitInterface::InvalidateICache(address, 4, true);
}
@ -229,12 +237,25 @@ void MemChecks::AddFromStrings(const TMemChecksStr& mc_strings)
void MemChecks::Add(const TMemCheck& memory_check)
{
if (GetMemCheck(memory_check.start_address) != nullptr)
return;
bool had_any = HasAny();
Core::RunAsCPUThread([&] {
m_mem_checks.push_back(memory_check);
// Check for existing breakpoint, and overwrite with new info.
// This is assuming we usually want the new breakpoint over an old one.
const u32 address = memory_check.start_address;
auto old_mem_check =
std::find_if(m_mem_checks.begin(), m_mem_checks.end(),
[address](const auto& check) { return check.start_address == address; });
if (old_mem_check != m_mem_checks.end())
{
const bool is_enabled = old_mem_check->is_enabled; // Preserve enabled status
*old_mem_check = std::move(memory_check);
old_mem_check->is_enabled = is_enabled;
old_mem_check->num_hits = 0;
}
else
{
m_mem_checks.push_back(memory_check);
}
// If this is the first one, clear the JIT cache so it can switch to
// watchpoint-compatible code.
if (!had_any)

View File

@ -612,7 +612,7 @@ void CheckBreakPoints()
{
const TBreakPoint* bp = PowerPC::breakpoints.GetBreakpoint(PC);
if (bp == nullptr)
if (!bp || !bp->is_enabled || !EvaluateCondition(bp->condition))
return;
if (bp->break_on_hit)