X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fretrace_swizzle.cpp;h=2045f6bb7c83eafe5e71cca35141ce19080e7a1a;hb=448a82a8d4070b8911f6db667d55693d1dc8f99f;hp=693fdfeb375a5bbd9fd315801a3717ca973d3db8;hpb=2473ca92aaa49ff2a70c9b931b5a3068d65844f7;p=apitrace diff --git a/retrace/retrace_swizzle.cpp b/retrace/retrace_swizzle.cpp index 693fdfe..2045f6b 100644 --- a/retrace/retrace_swizzle.cpp +++ b/retrace/retrace_swizzle.cpp @@ -75,6 +75,12 @@ lowerBound(unsigned long long address) { } } +#ifndef NDEBUG + if (it != regionMap.end()) { + assert(contains(it, address) || it->first > address); + } +#endif + return it; } @@ -83,6 +89,12 @@ static RegionMap::iterator 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; } @@ -243,8 +255,20 @@ toPointer(trace::Value &value, bool bind) { static std::map _obj_map; void -addObj(trace::Value &value, void *obj) { +addObj(trace::Call &call, trace::Value &value, void *obj) { unsigned long long address = value.toUIntPtr(); + + if (!address) { + if (obj) { + warning(call) << "unexpected non-null object\n"; + } + return; + } + + if (!obj) { + warning(call) << "got null for object 0x" << std::hex << address << std::dec << "\n"; + } + _obj_map[address] = obj; if (retrace::verbosity >= 2) { @@ -259,9 +283,18 @@ delObj(trace::Value &value) { } void * -toObjPointer(trace::Value &value) { +toObjPointer(trace::Call &call, trace::Value &value) { unsigned long long address = value.toUIntPtr(); - void *obj = address ? _obj_map[address] : NULL; + + 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";