@@ -527,15 +527,15 @@ std::vector<BreakpointEntry>::iterator DebuggerBreakpoints::FindBreakpoint(const
527527 const uint64_t targetAbsolute = m_state->GetModules ()->RelativeAddressToAbsolute (address);
528528 for (auto it = m_breakpoints.begin (); it != m_breakpoints.end (); ++it)
529529 {
530- if (m_state->GetModules ()->RelativeAddressToAbsolute (it->address ) == targetAbsolute)
530+ if (m_state->GetModules ()->RelativeAddressToAbsolute (it->location ) == targetAbsolute)
531531 return it;
532532 }
533533 }
534534 else
535535 {
536536 for (auto it = m_breakpoints.begin (); it != m_breakpoints.end (); ++it)
537537 {
538- if (it->address == address)
538+ if (it->location == address)
539539 return it;
540540 }
541541 }
@@ -611,7 +611,7 @@ bool DebuggerBreakpoints::RemoveOffset(const ModuleNameAndOffset& address)
611611 if (it == m_breakpoints.end ())
612612 return false ;
613613
614- ModuleNameAndOffset actualAddr = it->address ;
614+ ModuleNameAndOffset actualAddr = it->location ;
615615 m_breakpoints.erase (it);
616616 SerializeMetadata ();
617617
@@ -642,7 +642,7 @@ bool DebuggerBreakpoints::EnableOffset(const ModuleNameAndOffset& address)
642642
643643 if (m_state->GetAdapter () && m_state->IsConnected ())
644644 {
645- uint64_t remoteAddress = m_state->GetModules ()->RelativeAddressToAbsolute (it->address );
645+ uint64_t remoteAddress = m_state->GetModules ()->RelativeAddressToAbsolute (it->location );
646646 m_state->GetAdapter ()->AddBreakpoint (remoteAddress);
647647 }
648648 return true ;
@@ -667,7 +667,7 @@ bool DebuggerBreakpoints::DisableOffset(const ModuleNameAndOffset& address)
667667
668668 if (m_state->GetAdapter () && m_state->IsConnected ())
669669 {
670- uint64_t remoteAddress = m_state->GetModules ()->RelativeAddressToAbsolute (it->address );
670+ uint64_t remoteAddress = m_state->GetModules ()->RelativeAddressToAbsolute (it->location );
671671 m_state->GetAdapter ()->RemoveBreakpoint (remoteAddress);
672672 }
673673 return true ;
@@ -704,9 +704,8 @@ bool DebuggerBreakpoints::ContainsAbsolute(uint64_t address)
704704
705705 for (const auto & bp : m_breakpoints)
706706 {
707- if (m_state->GetModules ()->RelativeAddressToAbsolute (bp.address ) == address)
707+ if (m_state->GetModules ()->RelativeAddressToAbsolute (bp.location ) == address)
708708 return true ;
709- }
710709 }
711710 return false ;
712711}
@@ -735,7 +734,7 @@ std::string DebuggerBreakpoints::GetConditionAbsolute(const uint64_t address)
735734{
736735 for (const auto & bp : m_breakpoints)
737736 {
738- if (m_state->GetModules ()->RelativeAddressToAbsolute (bp.address ) == address)
737+ if (m_state->GetModules ()->RelativeAddressToAbsolute (bp.location ) == address)
739738 return bp.condition ;
740739 }
741740 return " " ;
@@ -753,7 +752,7 @@ bool DebuggerBreakpoints::HasConditionAbsolute(const uint64_t address)
753752{
754753 for (const auto & bp : m_breakpoints)
755754 {
756- if (m_state->GetModules ()->RelativeAddressToAbsolute (bp.address ) == address)
755+ if (m_state->GetModules ()->RelativeAddressToAbsolute (bp.location ) == address)
757756 return !bp.condition .empty ();
758757 }
759758 return false ;
@@ -793,8 +792,13 @@ bool DebuggerBreakpoints::AddHardwareBreakpoint(uint64_t address, DebugBreakpoin
793792 // Add to internal storage (either adapter succeeded, or no adapter connected yet)
794793 // Convert absolute address to module+offset for ASLR-safe storage (like AddAbsolute does for software breakpoints)
795794 ModuleNameAndOffset info = m_state->GetModules ()->AbsoluteAddressToRelative (address);
796- BreakpointInfo bp (info, type, size);
795+ BreakpointEntry bp;
796+ bp.location = info;
797+ bp.enabled = true ;
798+ bp.type = type;
799+ bp.size = size;
797800 bp.address = address;
801+ bp.isRelative = true ;
798802 m_breakpoints.push_back (bp);
799803 SerializeMetadata ();
800804
@@ -844,7 +848,7 @@ bool DebuggerBreakpoints::ContainsHardwareBreakpoint(uint64_t address, DebugBrea
844848{
845849 // Similar to ContainsAbsolute, we need to handle both relative and absolute hardware breakpoints
846850 // For relative hardware breakpoints, convert to absolute and compare
847- for (const BreakpointInfo & breakpoint : m_breakpoints)
851+ for (const BreakpointEntry & breakpoint : m_breakpoints)
848852 {
849853 if (breakpoint.IsHardware () && breakpoint.type == type && breakpoint.size == size)
850854 {
@@ -959,7 +963,12 @@ bool DebuggerBreakpoints::AddHardwareBreakpoint(const ModuleNameAndOffset& locat
959963 }
960964
961965 // Add to internal storage (either adapter succeeded, or no adapter connected yet)
962- BreakpointInfo bp (location, type, size); // Uses the constructor for module+offset
966+ BreakpointEntry bp;
967+ bp.location = location;
968+ bp.enabled = true ;
969+ bp.type = type;
970+ bp.size = size;
971+ bp.isRelative = true ;
963972 m_breakpoints.push_back (bp);
964973 SerializeMetadata ();
965974
@@ -969,10 +978,10 @@ bool DebuggerBreakpoints::AddHardwareBreakpoint(const ModuleNameAndOffset& locat
969978
970979bool DebuggerBreakpoints::RemoveHardwareBreakpoint (const ModuleNameAndOffset& location, DebugBreakpointType type, size_t size)
971980{
972- BreakpointInfo toFind (location, type, size);
973-
974981 // Remove from our list
975- auto iter = std::find (m_breakpoints.begin (), m_breakpoints.end (), toFind);
982+ auto iter = std::find_if (m_breakpoints.begin (), m_breakpoints.end (), [&](const BreakpointEntry& bp) {
983+ return bp.IsHardware () && bp.location == location && bp.type == type && bp.size == size;
984+ });
976985 if (iter != m_breakpoints.end ())
977986 {
978987 m_breakpoints.erase (iter);
@@ -992,8 +1001,9 @@ bool DebuggerBreakpoints::RemoveHardwareBreakpoint(const ModuleNameAndOffset& lo
9921001
9931002bool DebuggerBreakpoints::ContainsHardwareBreakpoint (const ModuleNameAndOffset& location, DebugBreakpointType type, size_t size)
9941003{
995- BreakpointInfo toFind (location, type, size);
996- return std::find (m_breakpoints.begin (), m_breakpoints.end (), toFind) != m_breakpoints.end ();
1004+ return std::find_if (m_breakpoints.begin (), m_breakpoints.end (), [&](const BreakpointEntry& bp) {
1005+ return bp.IsHardware () && bp.location == location && bp.type == type && bp.size == size;
1006+ }) != m_breakpoints.end ();
9971007}
9981008
9991009
@@ -1003,8 +1013,9 @@ bool DebuggerBreakpoints::EnableHardwareBreakpoint(const ModuleNameAndOffset& lo
10031013 return false ;
10041014
10051015 // Find and enable the hardware breakpoint
1006- BreakpointInfo toFind (location, type, size);
1007- auto iter = std::find (m_breakpoints.begin (), m_breakpoints.end (), toFind);
1016+ auto iter = std::find_if (m_breakpoints.begin (), m_breakpoints.end (), [&](const BreakpointEntry& bp) {
1017+ return bp.IsHardware () && bp.location == location && bp.type == type && bp.size == size;
1018+ });
10081019 if (iter != m_breakpoints.end ())
10091020 {
10101021 iter->enabled = true ;
@@ -1027,8 +1038,9 @@ bool DebuggerBreakpoints::DisableHardwareBreakpoint(const ModuleNameAndOffset& l
10271038 return false ;
10281039
10291040 // Find and disable the hardware breakpoint
1030- BreakpointInfo toFind (location, type, size);
1031- auto iter = std::find (m_breakpoints.begin (), m_breakpoints.end (), toFind);
1041+ auto iter = std::find_if (m_breakpoints.begin (), m_breakpoints.end (), [&](const BreakpointEntry& bp) {
1042+ return bp.IsHardware () && bp.location == location && bp.type == type && bp.size == size;
1043+ });
10321044 if (iter != m_breakpoints.end ())
10331045 {
10341046 iter->enabled = false ;
@@ -1045,28 +1057,14 @@ bool DebuggerBreakpoints::DisableHardwareBreakpoint(const ModuleNameAndOffset& l
10451057}
10461058
10471059
1048- std::vector<ModuleNameAndOffset> DebuggerBreakpoints::GetSoftwareBreakpointList () const
1049- {
1050- std::vector<ModuleNameAndOffset> result;
1051- for (const BreakpointInfo& bp : m_breakpoints)
1052- {
1053- if (bp.IsSoftware ())
1054- {
1055- result.push_back (bp.location );
1056- }
1057- }
1058- return result;
1059- }
1060-
1061-
10621060void DebuggerBreakpoints::SerializeMetadata ()
10631061{
10641062 std::vector<Ref<Metadata>> breakpoints;
10651063 for (const auto & bp : m_breakpoints)
10661064 {
10671065 std::map<std::string, Ref<Metadata>> info;
1068- info[" module" ] = new Metadata (bp.address .module );
1069- info[" offset" ] = new Metadata (bp.address .offset );
1066+ info[" module" ] = new Metadata (bp.location .module );
1067+ info[" offset" ] = new Metadata (bp.location .offset );
10701068 info[" enabled" ] = new Metadata (bp.enabled );
10711069
10721070 if (!bp.condition .empty ())
@@ -1099,8 +1097,8 @@ void DebuggerBreakpoints::UnserializedMetadata()
10991097 continue ;
11001098
11011099 BreakpointEntry bp;
1102- bp.address .module = info[" module" ]->GetString ();
1103- bp.address .offset = info[" offset" ]->GetUnsignedInteger ();
1100+ bp.location .module = info[" module" ]->GetString ();
1101+ bp.location .offset = info[" offset" ]->GetUnsignedInteger ();
11041102 bp.enabled = (info[" enabled" ] && info[" enabled" ]->IsBoolean ()) ? info[" enabled" ]->GetBoolean () : true ;
11051103 bp.condition = (info[" condition" ] && info[" condition" ]->IsString ()) ? info[" condition" ]->GetString () : " " ;
11061104
@@ -1114,7 +1112,7 @@ void DebuggerBreakpoints::Apply()
11141112 if (!m_state->GetAdapter ())
11151113 return ;
11161114
1117- for (const BreakpointInfo & bp : m_breakpoints)
1115+ for (const auto & bp : m_breakpoints)
11181116 {
11191117 if (bp.IsSoftware ())
11201118 {
0 commit comments