}
}
+#ifndef NDEBUG
+ if (it != regionMap.end()) {
+ assert(contains(it, address) || it->first > address);
+ }
+#endif
+
return it;
}
upperBound(unsigned long long address) {
RegionMap::iterator it = regionMap.upper_bound(address);
+#ifndef NDEBUG
+ if (it != regionMap.end()) {
+ assert(it->first >= address);
+ }
+#endif
+
return it;
}
#ifndef NDEBUG
RegionMap::iterator start = lowerBound(address);
- RegionMap::iterator stop = upperBound(address + size);
+ RegionMap::iterator stop = upperBound(address + size - 1);
if (0) {
// Forget all regions that intersect this new one.
regionMap.erase(start, stop);
}
+
+static std::map<unsigned long long, void *> _obj_map;
+
+void
+addObj(trace::Call &call, trace::Value &value, void *obj) {
+ unsigned long long address = value.toUIntPtr();
+
+ if (!address) {
+ assert(!obj);
+ return;
+ }
+
+ if (!obj) {
+ warning(call) << "got null for object 0x" << std::hex << address << std::dec << "\n";
+ }
+
+ _obj_map[address] = obj;
+
+ if (retrace::verbosity >= 2) {
+ std::cout << std::hex << "obj 0x" << address << " -> 0x" << size_t(obj) << std::dec << "\n";
+ }
+}
+
+void
+delObj(trace::Value &value) {
+ unsigned long long address = value.toUIntPtr();
+ _obj_map.erase(address);
+}
+
+void *
+toObjPointer(trace::Call &call, trace::Value &value) {
+ unsigned long long address = value.toUIntPtr();
+
+ void *obj;
+ if (address) {
+ obj = _obj_map[address];
+ if (!obj) {
+ warning(call) << "unknown object 0x" << std::hex << address << std::dec << "\n";
+ }
+ } else {
+ obj = NULL;
+ }
+
+ if (retrace::verbosity >= 2) {
+ std::cout << std::hex << "obj 0x" << address << " <- 0x" << size_t(obj) << std::dec << "\n";
+ }
+
+ return obj;
+}
+
+
} /* retrace */