[Lldb-commits] [lldb] r134090 - in /lldb/trunk: include/lldb/Breakpoint/BreakpointSiteList.h source/Breakpoint/BreakpointSiteList.cpp source/Target/Process.cpp
Jim Ingham
jingham at apple.com
Wed Jun 29 12:42:28 PDT 2011
Author: jingham
Date: Wed Jun 29 14:42:28 2011
New Revision: 134090
URL: http://llvm.org/viewvc/llvm-project?rev=134090&view=rev
Log:
Remove a few more places where we were iterating linearly over the Breakpoint Site's rather than
looking up what we needed by address, which is much faster.
Modified:
lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h
lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp
lldb/trunk/source/Target/Process.cpp
Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h?rev=134090&r1=134089&r2=134090&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h (original)
+++ lldb/trunk/include/lldb/Breakpoint/BreakpointSiteList.h Wed Jun 29 14:42:28 2011
@@ -165,6 +165,9 @@
void
SetEnabledForAll(const bool enable, const lldb::break_id_t except_id = LLDB_INVALID_BREAK_ID);
+
+ bool
+ FindInRange (lldb::addr_t lower_bound, lldb::addr_t upper_bound, BreakpointSiteList &bp_site_list) const;
typedef void (*BreakpointSiteSPMapFunc) (lldb::BreakpointSiteSP &bp, void *baton);
Modified: lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp?rev=134090&r1=134089&r2=134090&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp Wed Jun 29 14:42:28 2011
@@ -209,6 +209,41 @@
return stop_sp;
}
+bool
+BreakpointSiteList::FindInRange (lldb::addr_t lower_bound, lldb::addr_t upper_bound, BreakpointSiteList &bp_site_list) const
+{
+
+ if (lower_bound > upper_bound)
+ return false;
+
+ collection::const_iterator lower, upper, pos;
+ lower = m_bp_site_list.lower_bound(lower_bound);
+ if (lower == m_bp_site_list.end()
+ || (*lower).first >= upper_bound)
+ return false;
+
+ // This is one tricky bit. The breakpoint might overlap the bottom end of the range. So we grab the
+ // breakpoint prior to the lower bound, and check that that + its byte size isn't in our range.
+ if (lower != m_bp_site_list.begin())
+ {
+ collection::const_iterator prev_pos = lower;
+ prev_pos--;
+ const BreakpointSiteSP &prev_bp = (*prev_pos).second;
+ if (prev_bp->GetLoadAddress() + prev_bp->GetByteSize() > lower_bound)
+ bp_site_list.Add (prev_bp);
+
+ }
+
+ upper = m_bp_site_list.upper_bound(upper_bound);
+
+ for (pos = lower; pos != upper; pos++)
+ {
+ bp_site_list.Add ((*pos).second);
+ }
+ return true;
+}
+
+
void
BreakpointSiteList::SetEnabledForAll (const bool enabled, const lldb::break_id_t except_id)
{
Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=134090&r1=134089&r2=134090&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Wed Jun 29 14:42:28 2011
@@ -1378,18 +1378,22 @@
size_t opcode_offset;
size_t idx;
BreakpointSiteSP bp;
+ BreakpointSiteList bp_sites_in_range;
- for (idx = 0; (bp = m_breakpoint_site_list.GetByIndex(idx)) != NULL; ++idx)
+ if (m_breakpoint_site_list.FindInRange (bp_addr, bp_addr + size, bp_sites_in_range))
{
- if (bp->GetType() == BreakpointSite::eSoftware)
+ for (idx = 0; (bp = bp_sites_in_range.GetByIndex(idx)) != NULL; ++idx)
{
- if (bp->IntersectsRange(bp_addr, size, &intersect_addr, &intersect_size, &opcode_offset))
+ if (bp->GetType() == BreakpointSite::eSoftware)
{
- assert(bp_addr <= intersect_addr && intersect_addr < bp_addr + size);
- assert(bp_addr < intersect_addr + intersect_size && intersect_addr + intersect_size <= bp_addr + size);
- assert(opcode_offset + intersect_size <= bp->GetByteSize());
- size_t buf_offset = intersect_addr - bp_addr;
- ::memcpy(buf + buf_offset, bp->GetSavedOpcodeBytes() + opcode_offset, intersect_size);
+ if (bp->IntersectsRange(bp_addr, size, &intersect_addr, &intersect_size, &opcode_offset))
+ {
+ assert(bp_addr <= intersect_addr && intersect_addr < bp_addr + size);
+ assert(bp_addr < intersect_addr + intersect_size && intersect_addr + intersect_size <= bp_addr + size);
+ assert(opcode_offset + intersect_size <= bp->GetByteSize());
+ size_t buf_offset = intersect_addr - bp_addr;
+ ::memcpy(buf + buf_offset, bp->GetSavedOpcodeBytes() + opcode_offset, intersect_size);
+ }
}
}
}
More information about the lldb-commits
mailing list