[Lldb-commits] [PATCH] Fixed symbol ordering to be stable with overlapping symbols.
Richard Mitton
richard at codersnotes.com
Mon Sep 16 13:07:27 PDT 2013
If two symbols A and B have the same address, then doing lookups at that address will return different symbols depending on whether an offset was used.
e.g. if A==B==0x100000
0x100000 -> A
0x100007 -> B
This would result in spurious labels when disassembling a function with an alias. This patch fixes it by ensuring we always return the first symbol covering an address.
http://llvm-reviews.chandlerc.com/D1690
Files:
include/lldb/Core/RangeMap.h
Index: include/lldb/Core/RangeMap.h
===================================================================
--- include/lldb/Core/RangeMap.h
+++ include/lldb/Core/RangeMap.h
@@ -1229,16 +1229,11 @@
typename Collection::const_iterator end = m_entries.end();
typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
+ while(pos != begin && pos[-1].Contains(addr))
+ --pos;
+
if (pos != end && pos->Contains(addr))
- {
return std::distance (begin, pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- return std::distance (begin, pos);
- }
}
return UINT32_MAX;
}
@@ -1257,19 +1252,12 @@
typename Collection::iterator begin = m_entries.begin();
typename Collection::iterator end = m_entries.end();
typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
+
+ while(pos != begin && pos[-1].Contains(addr))
+ --pos;
if (pos != end && pos->Contains(addr))
- {
return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
}
return NULL;
}
@@ -1288,18 +1276,11 @@
typename Collection::const_iterator end = m_entries.end();
typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
+ while(pos != begin && pos[-1].Contains(addr))
+ --pos;
+
if (pos != end && pos->Contains(addr))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(addr))
- {
- return &(*pos);
- }
- }
+ return &(*pos);
}
return NULL;
}
@@ -1316,18 +1297,11 @@
typename Collection::const_iterator end = m_entries.end();
typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan);
+ while(pos != begin && pos[-1].Contains(range))
+ --pos;
+
if (pos != end && pos->Contains(range))
- {
- return &(*pos);
- }
- else if (pos != begin)
- {
- --pos;
- if (pos->Contains(range))
- {
- return &(*pos);
- }
- }
+ return &(*pos);
}
return NULL;
}
@@ -1501,12 +1475,15 @@
typename Collection::iterator end = m_entries.end();
typename Collection::iterator pos = std::lower_bound (begin, end, entry, BaseLessThan);
+ while(pos != begin && pos[-1].addr == addr)
+ --pos;
+
if (pos != end)
{
if (pos->addr == addr || !exact_match_only)
return &(*pos);
}
- }
+ }
return NULL;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1690.1.patch
Type: text/x-patch
Size: 3848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20130916/342201f9/attachment.bin>
More information about the lldb-commits
mailing list