================
@@ -125,34 +125,38 @@ DNBBreakpointList::FindNearestWatchpoint(nub_addr_t addr)
const {
size_t DNBBreakpointList::FindBreakpointsThatOverlapRange(
nub_addr_t addr, nub_addr_t size, std::vector<DNBBreakpoint *> &bps) {
bps.clear();
+
+ if (m_breakpoints.empty())
+ return bps.size();
+
iterator end = m_breakpoints.end();
// Find the first breakpoint with an address >= to "addr"
iterator pos = m_breakpoints.lower_bound(addr);
- if (pos != end) {
- if (pos != m_breakpoints.begin()) {
- // Watch out for a breakpoint at an address less than "addr" that might
- // still overlap
- iterator prev_pos = pos;
- --prev_pos;
- if (prev_pos->second.IntersectsRange(addr, size, NULL, NULL, NULL))
- bps.push_back(&pos->second);
- }
- while (pos != end) {
- // When we hit a breakpoint whose start address is greater than "addr +
- // size" we are done.
- // Do the math in a way that doesn't risk unsigned overflow with bad
- // input.
- if ((pos->second.Address() - addr) >= size)
- break;
+ if (pos != m_breakpoints.begin()) {
+ // Watch out for a breakpoint at an address less than "addr" that might
+ // still overlap
+ iterator prev_pos = pos;
+ --prev_pos;
+ if (prev_pos->second.IntersectsRange(addr, size, NULL, NULL, NULL))
+ bps.push_back(&prev_pos->second);
+ }
----------------
DavidSpickett wrote:
That's why lower_bound is a tiny bit harder to understand than upper. upper is
checking for > only, so it's always relevant to look at the previous. With
lower bound, in the = case, the previous we know doesn't overlap.
But I don't think it really saves any time so there's no point changing it
(also there are 2 uses of lower_bound in debugserver already so let's keep it
consistent).
https://github.com/llvm/llvm-project/pull/217837
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits