@@ -520,30 +520,30 @@ DebuggerBreakpoints::DebuggerBreakpoints(DebuggerState* state, std::vector<Modul
520520}
521521
522522
523- BreakpointEntry* DebuggerBreakpoints::FindBreakpoint (const ModuleNameAndOffset& address)
523+ std::vector< BreakpointEntry>::iterator DebuggerBreakpoints::FindBreakpoint (const ModuleNameAndOffset& address)
524524{
525525 if (m_state->GetAdapter ())
526526 {
527527 const uint64_t targetAbsolute = m_state->GetModules ()->RelativeAddressToAbsolute (address);
528- for (auto & bp : m_breakpoints)
528+ for (auto it = m_breakpoints. begin (); it != m_breakpoints. end (); ++it )
529529 {
530- if (m_state->GetModules ()->RelativeAddressToAbsolute (bp. address ) == targetAbsolute)
531- return &bp ;
530+ if (m_state->GetModules ()->RelativeAddressToAbsolute (it-> address ) == targetAbsolute)
531+ return it ;
532532 }
533533 }
534534 else
535535 {
536- for (auto & bp : m_breakpoints)
536+ for (auto it = m_breakpoints. begin (); it != m_breakpoints. end (); ++it )
537537 {
538- if (bp. address == address)
539- return &bp ;
538+ if (it-> address == address)
539+ return it ;
540540 }
541541 }
542- return nullptr ;
542+ return m_breakpoints. end () ;
543543}
544544
545545
546- const BreakpointEntry* DebuggerBreakpoints::FindBreakpoint (const ModuleNameAndOffset& address) const
546+ std::vector< BreakpointEntry>::const_iterator DebuggerBreakpoints::FindBreakpoint (const ModuleNameAndOffset& address) const
547547{
548548 return const_cast <DebuggerBreakpoints*>(this )->FindBreakpoint (address);
549549}
@@ -594,14 +594,11 @@ bool DebuggerBreakpoints::RemoveAbsolute(uint64_t remoteAddress)
594594 return false ;
595595
596596 ModuleNameAndOffset info = m_state->GetModules ()->AbsoluteAddressToRelative (remoteAddress);
597- BreakpointEntry* bp = FindBreakpoint (info);
598- if (!bp )
597+ auto it = FindBreakpoint (info);
598+ if (it == m_breakpoints. end () )
599599 return false ;
600600
601- auto it = std::find_if (m_breakpoints.begin (), m_breakpoints.end (),
602- [bp](const BreakpointEntry& b) { return &b == bp; });
603- if (it != m_breakpoints.end ())
604- m_breakpoints.erase (it);
601+ m_breakpoints.erase (it);
605602 SerializeMetadata ();
606603 m_state->GetAdapter ()->RemoveBreakpoint (remoteAddress);
607604 return true ;
@@ -610,15 +607,12 @@ bool DebuggerBreakpoints::RemoveAbsolute(uint64_t remoteAddress)
610607
611608bool DebuggerBreakpoints::RemoveOffset (const ModuleNameAndOffset& address)
612609{
613- BreakpointEntry* bp = FindBreakpoint (address);
614- if (!bp )
610+ auto it = FindBreakpoint (address);
611+ if (it == m_breakpoints. end () )
615612 return false ;
616613
617- ModuleNameAndOffset actualAddr = bp->address ;
618- auto it = std::find_if (m_breakpoints.begin (), m_breakpoints.end (),
619- [bp](const BreakpointEntry& b) { return &b == bp; });
620- if (it != m_breakpoints.end ())
621- m_breakpoints.erase (it);
614+ ModuleNameAndOffset actualAddr = it->address ;
615+ m_breakpoints.erase (it);
622616 SerializeMetadata ();
623617
624618 if (m_state->GetAdapter () && m_state->IsConnected ())
@@ -639,16 +633,16 @@ bool DebuggerBreakpoints::EnableAbsolute(uint64_t remoteAddress)
639633
640634bool DebuggerBreakpoints::EnableOffset (const ModuleNameAndOffset& address)
641635{
642- BreakpointEntry* bp = FindBreakpoint (address);
643- if (!bp )
636+ auto it = FindBreakpoint (address);
637+ if (it == m_breakpoints. end () )
644638 return false ;
645639
646- bp ->enabled = true ;
640+ it ->enabled = true ;
647641 SerializeMetadata ();
648642
649643 if (m_state->GetAdapter () && m_state->IsConnected ())
650644 {
651- uint64_t remoteAddress = m_state->GetModules ()->RelativeAddressToAbsolute (bp ->address );
645+ uint64_t remoteAddress = m_state->GetModules ()->RelativeAddressToAbsolute (it ->address );
652646 m_state->GetAdapter ()->AddBreakpoint (remoteAddress);
653647 }
654648 return true ;
@@ -664,16 +658,16 @@ bool DebuggerBreakpoints::DisableAbsolute(uint64_t remoteAddress)
664658
665659bool DebuggerBreakpoints::DisableOffset (const ModuleNameAndOffset& address)
666660{
667- BreakpointEntry* bp = FindBreakpoint (address);
668- if (!bp )
661+ auto it = FindBreakpoint (address);
662+ if (it == m_breakpoints. end () )
669663 return false ;
670664
671- bp ->enabled = false ;
665+ it ->enabled = false ;
672666 SerializeMetadata ();
673667
674668 if (m_state->GetAdapter () && m_state->IsConnected ())
675669 {
676- uint64_t remoteAddress = m_state->GetModules ()->RelativeAddressToAbsolute (bp ->address );
670+ uint64_t remoteAddress = m_state->GetModules ()->RelativeAddressToAbsolute (it ->address );
677671 m_state->GetAdapter ()->RemoveBreakpoint (remoteAddress);
678672 }
679673 return true ;
@@ -689,17 +683,17 @@ bool DebuggerBreakpoints::IsEnabledAbsolute(uint64_t address)
689683
690684bool DebuggerBreakpoints::IsEnabledOffset (const ModuleNameAndOffset& address)
691685{
692- const BreakpointEntry* bp = FindBreakpoint (address);
693- if (!bp )
686+ auto it = FindBreakpoint (address);
687+ if (it == m_breakpoints. end () )
694688 return true ; // Default to enabled if breakpoint not found
695689
696- return bp ->enabled ;
690+ return it ->enabled ;
697691}
698692
699693
700694bool DebuggerBreakpoints::ContainsOffset (const ModuleNameAndOffset& address)
701695{
702- return FindBreakpoint (address) != nullptr ;
696+ return FindBreakpoint (address) != m_breakpoints. end () ;
703697}
704698
705699
@@ -726,11 +720,11 @@ bool DebuggerBreakpoints::SetConditionAbsolute(const uint64_t remoteAddress, con
726720
727721bool DebuggerBreakpoints::SetConditionOffset (const ModuleNameAndOffset& address, const std::string& condition)
728722{
729- BreakpointEntry* bp = FindBreakpoint (address);
730- if (!bp )
723+ auto it = FindBreakpoint (address);
724+ if (it == m_breakpoints. end () )
731725 return false ;
732726
733- bp ->condition = condition;
727+ it ->condition = condition;
734728 SerializeMetadata ();
735729 return true ;
736730}
@@ -749,8 +743,8 @@ std::string DebuggerBreakpoints::GetConditionAbsolute(const uint64_t address)
749743
750744std::string DebuggerBreakpoints::GetConditionOffset (const ModuleNameAndOffset& address)
751745{
752- const BreakpointEntry* bp = FindBreakpoint (address);
753- return bp ? bp ->condition : " " ;
746+ auto it = FindBreakpoint (address);
747+ return it != m_breakpoints. end () ? it ->condition : " " ;
754748}
755749
756750
@@ -767,8 +761,8 @@ bool DebuggerBreakpoints::HasConditionAbsolute(const uint64_t address)
767761
768762bool DebuggerBreakpoints::HasConditionOffset (const ModuleNameAndOffset& address)
769763{
770- const BreakpointEntry* bp = FindBreakpoint (address);
771- return bp && !bp ->condition .empty ();
764+ auto it = FindBreakpoint (address);
765+ return it != m_breakpoints. end () && !it ->condition .empty ();
772766}
773767
774768
0 commit comments