void
delRegion(unsigned long long address) {
    RegionMap::iterator it = lookupRegion(address);
    if (it != regionMap.end()) {
        regionMap.erase(it);
    } else {
        assert(0);
    }
}
void
delRegionByPointer(void *ptr) {
    for (RegionMap::iterator it = regionMap.begin(); it != regionMap.end(); ++it) {
        if (it->second.buffer == ptr) {
            regionMap.erase(it);
            return;
        }
    }
    assert(0);
}
Beispiel #3
0
void
addRegion(trace::Call &call, unsigned long long address, void *buffer, unsigned long long size)
{
    if (retrace::verbosity >= 2) {
        std::cout
            << "region "
            << std::hex
            << "0x" << address << "-0x" << (address + size)
            << " -> "
            << "0x" << (uintptr_t)buffer << "-0x" << ((uintptr_t)buffer + size)
            << std::dec
            << "\n";
    }

    if (!address) {
        // Ignore NULL pointer
        assert(buffer == nullptr);
        return;
    }

    const bool debug =
#ifdef NDEBUG
        false
#else
        true
#endif
    ;
    if (debug) {
        RegionMap::iterator start = lowerBound(address);
        RegionMap::iterator stop = upperBound(address + size - 1);
        if (0) {
            // Forget all regions that intersect this new one.
            regionMap.erase(start, stop);
        } else {
            for (RegionMap::iterator it = start; it != stop; ++it) {
                warning(call) << std::hex <<
                    "region 0x" << address << "-0x" << (address + size) << " "
                    "intersects existing region 0x" << it->first << "-0x" << (it->first + it->second.size) << "\n" << std::dec;
                assert(intersects(it, address, size));
            }
        }
    }

    assert(buffer);

    Region region;
    region.buffer = buffer;
    region.size = size;

    regionMap[address] = region;
}
Beispiel #4
0
void
addRegion(unsigned long long address, void *buffer, unsigned long long size)
{
    // Forget all regions that intersect this new one.
    if (0) {
        RegionMap::iterator start = lowerBound(address);
        if (start != regionMap.end()) {
            RegionMap::iterator stop = upperBound(address + size);
            regionMap.erase(start, stop);
        }
    }

    assert(buffer);

    Region region;
    region.buffer = buffer;
    region.size = size;

    regionMap[address] = region;
}