Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/lib/libunwind Fix binary search when search value is in ...
details: https://anonhg.NetBSD.org/src/rev/63d9fa583810
branches: trunk
changeset: 335905:63d9fa583810
user: joerg <joerg%NetBSD.org@localhost>
date: Thu Jan 29 20:05:56 2015 +0000
description:
Fix binary search when search value is in the last block, but not equal
to the start of the range. PR 49444.
diffstat:
sys/lib/libunwind/AddressSpace.hpp | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diffs (31 lines):
diff -r 245e7a8edbc3 -r 63d9fa583810 sys/lib/libunwind/AddressSpace.hpp
--- a/sys/lib/libunwind/AddressSpace.hpp Thu Jan 29 19:57:08 2015 +0000
+++ b/sys/lib/libunwind/AddressSpace.hpp Thu Jan 29 20:05:56 2015 +0000
@@ -263,21 +263,19 @@
pint_t base = n->hdr_base;
pint_t first = n->hdr_start;
- pint_t len = n->hdr_entries;
- while (len) {
- pint_t next = first + ((len + 1) / 2) * 8;
+ for (pint_t len = n->hdr_entries; len > 1; ) {
+ pint_t next = first + (len / 2) * 8;
pint_t nextPC = base + (int32_t)get32(next);
if (nextPC == pc) {
first = next;
break;
}
if (nextPC < pc) {
- len -= (len + 1) / 2;
first = next;
- } else if (len == 1)
- break;
- else
- len = (len + 1) / 2;
+ len -= (len / 2);
+ } else {
+ len /= 2;
+ }
}
fdeStart = base + (int32_t)get32(first + 4);
data_base = n->data_base;
Home |
Main Index |
Thread Index |
Old Index