12
12
#ifndef __UNWINDCURSOR_HPP__
13
13
#define __UNWINDCURSOR_HPP__
14
14
15
- #include < algorithm>
16
15
#include < stdint.h>
17
16
#include < stdio.h>
18
17
#include < stdlib.h>
@@ -106,7 +105,6 @@ class _LIBUNWIND_HIDDEN DwarfFDECache {
106
105
static void dyldUnloadHook (const struct mach_header *mh, intptr_t slide);
107
106
static bool _registeredForDyldUnloads;
108
107
#endif
109
- // Can't use std::vector<> here because this code is below libc++.
110
108
static entry *_buffer;
111
109
static entry *_bufferUsed;
112
110
static entry *_bufferEnd;
@@ -1229,7 +1227,6 @@ template<typename A>
1229
1227
struct EHABISectionIterator {
1230
1228
typedef EHABISectionIterator _Self;
1231
1229
1232
- typedef std::random_access_iterator_tag iterator_category;
1233
1230
typedef typename A::pint_t value_type;
1234
1231
typedef typename A::pint_t * pointer;
1235
1232
typedef typename A::pint_t & reference;
@@ -1283,6 +1280,29 @@ struct EHABISectionIterator {
1283
1280
const UnwindInfoSections* _sects;
1284
1281
};
1285
1282
1283
+ namespace {
1284
+
1285
+ template <typename A>
1286
+ EHABISectionIterator<A> EHABISectionUpperBound (
1287
+ EHABISectionIterator<A> first,
1288
+ EHABISectionIterator<A> last,
1289
+ typename A::pint_t value) {
1290
+ size_t len = last - first;
1291
+ while (len > 0 ) {
1292
+ size_t l2 = len / 2 ;
1293
+ EHABISectionIterator<A> m = first + l2;
1294
+ if (value < *m) {
1295
+ len = l2;
1296
+ } else {
1297
+ first = ++m;
1298
+ len -= l2 + 1 ;
1299
+ }
1300
+ }
1301
+ return first;
1302
+ }
1303
+
1304
+ }
1305
+
1286
1306
template <typename A, typename R>
1287
1307
bool UnwindCursor<A, R>::getInfoFromEHABISection(
1288
1308
pint_t pc,
@@ -1294,7 +1314,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection(
1294
1314
if (begin == end)
1295
1315
return false ;
1296
1316
1297
- EHABISectionIterator<A> itNextPC = std::upper_bound (begin, end, pc);
1317
+ EHABISectionIterator<A> itNextPC = EHABISectionUpperBound (begin, end, pc);
1298
1318
if (itNextPC == begin)
1299
1319
return false ;
1300
1320
EHABISectionIterator<A> itThisPC = itNextPC - 1 ;
@@ -1304,8 +1324,7 @@ bool UnwindCursor<A, R>::getInfoFromEHABISection(
1304
1324
// in the table, we don't really know the function extent and have to choose a
1305
1325
// value for nextPC. Choosing max() will allow the range check during trace to
1306
1326
// succeed.
1307
- pint_t nextPC = (itNextPC == end) ? std::numeric_limits<pint_t >::max ()
1308
- : itNextPC.functionAddress ();
1327
+ pint_t nextPC = (itNextPC == end) ? UINTPTR_MAX : itNextPC.functionAddress ();
1309
1328
pint_t indexDataAddr = itThisPC.dataAddress ();
1310
1329
1311
1330
if (indexDataAddr == 0 )
0 commit comments