Skip to content

Commit ed55c20

Browse files
committed
Fix conditional breakpoint key mismatch and cleaned up condition lookups
1 parent 3e3c25e commit ed55c20

2 files changed

Lines changed: 25 additions & 11 deletions

File tree

core/debuggercontroller.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2453,11 +2453,10 @@ void DebuggerController::AddModuleValuesToExpressionParser()
24532453

24542454
bool DebuggerController::EvaluateBreakpointCondition(uint64_t address)
24552455
{
2456-
DebuggerBreakpoints* breakpoints = m_state->GetBreakpoints();
2457-
if (!breakpoints->HasConditionAbsolute(address))
2456+
const std::string condition = m_state->GetBreakpoints()->GetConditionAbsolute(address);
2457+
if (condition.empty())
24582458
return true; // no condition means always break
24592459

2460-
const std::string condition = breakpoints->GetConditionAbsolute(address);
24612460
uint64_t result = 0;
24622461
std::string errorString;
24632462

core/debuggerstate.cpp

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -721,17 +721,34 @@ bool DebuggerBreakpoints::SetConditionAbsolute(const uint64_t remoteAddress, con
721721

722722
bool DebuggerBreakpoints::SetConditionOffset(const ModuleNameAndOffset& address, const std::string& condition)
723723
{
724-
if (!ContainsOffset(address))
725-
return false;
724+
std::optional<ModuleNameAndOffset> actualKey;
726725

727-
if (condition.empty())
726+
if (m_state->GetAdapter())
728727
{
729-
m_conditions.erase(address);
728+
const uint64_t targetAbsolute = m_state->GetModules()->RelativeAddressToAbsolute(address);
729+
for (const ModuleNameAndOffset& bp : m_breakpoints)
730+
{
731+
if (m_state->GetModules()->RelativeAddressToAbsolute(bp) == targetAbsolute)
732+
{
733+
actualKey = bp;
734+
break;
735+
}
736+
}
730737
}
731738
else
732739
{
733-
m_conditions[address] = condition;
740+
if (const auto it = std::ranges::find(m_breakpoints, address); it != m_breakpoints.end())
741+
actualKey = *it;
734742
}
743+
744+
if (!actualKey)
745+
return false;
746+
747+
if (condition.empty())
748+
m_conditions.erase(*actualKey);
749+
else
750+
m_conditions[*actualKey] = condition;
751+
735752
SerializeMetadata();
736753
return true;
737754
}
@@ -797,9 +814,7 @@ bool DebuggerBreakpoints::HasConditionAbsolute(const uint64_t address)
797814

798815
bool DebuggerBreakpoints::HasConditionOffset(const ModuleNameAndOffset& address)
799816
{
800-
if (const auto key = FindConditionKey(address))
801-
return !m_conditions[*key].empty();
802-
return false;
817+
return FindConditionKey(address).has_value();
803818
}
804819

805820

0 commit comments

Comments
 (0)