| OLD | NEW |
| 1 /* Copyright (c) 2006, Google Inc. | 1 /* Copyright (c) 2006, Google Inc. |
| 2 * All rights reserved. | 2 * All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 "to %"PRIuS" flags %d new_addr=0x%"PRIxPTR, | 611 "to %"PRIuS" flags %d new_addr=0x%"PRIxPTR, |
| 612 (uintptr_t)result, (uintptr_t)old_addr, | 612 (uintptr_t)result, (uintptr_t)old_addr, |
| 613 old_size, new_size, flags, | 613 old_size, new_size, flags, |
| 614 flags & MREMAP_FIXED ? (uintptr_t)new_addr : 0); | 614 flags & MREMAP_FIXED ? (uintptr_t)new_addr : 0); |
| 615 if (result != reinterpret_cast<void*>(-1)) { | 615 if (result != reinterpret_cast<void*>(-1)) { |
| 616 RecordRegionRemoval(old_addr, old_size); | 616 RecordRegionRemoval(old_addr, old_size); |
| 617 RecordRegionAddition(result, new_size); | 617 RecordRegionAddition(result, new_size); |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 extern "C" void* __sbrk(ptrdiff_t increment); // defined in libc | 621 extern "C" void* __sbrk(std::ptrdiff_t increment); // defined in libc |
| 622 | 622 |
| 623 void MemoryRegionMap::SbrkHook(const void* result, ptrdiff_t increment) { | 623 void MemoryRegionMap::SbrkHook(const void* result, std::ptrdiff_t increment) { |
| 624 RAW_VLOG(10, "Sbrk = 0x%"PRIxPTR" of %"PRIdS"", (uintptr_t)result, increment); | 624 RAW_VLOG(10, "Sbrk = 0x%"PRIxPTR" of %"PRIdS"", (uintptr_t)result, increment); |
| 625 if (result != reinterpret_cast<void*>(-1)) { | 625 if (result != reinterpret_cast<void*>(-1)) { |
| 626 if (increment > 0) { | 626 if (increment > 0) { |
| 627 void* new_end = sbrk(0); | 627 void* new_end = sbrk(0); |
| 628 RecordRegionAddition(result, reinterpret_cast<uintptr_t>(new_end) - | 628 RecordRegionAddition(result, reinterpret_cast<uintptr_t>(new_end) - |
| 629 reinterpret_cast<uintptr_t>(result)); | 629 reinterpret_cast<uintptr_t>(result)); |
| 630 } else if (increment < 0) { | 630 } else if (increment < 0) { |
| 631 void* new_end = sbrk(0); | 631 void* new_end = sbrk(0); |
| 632 RecordRegionRemoval(new_end, reinterpret_cast<uintptr_t>(result) - | 632 RecordRegionRemoval(new_end, reinterpret_cast<uintptr_t>(result) - |
| 633 reinterpret_cast<uintptr_t>(new_end)); | 633 reinterpret_cast<uintptr_t>(new_end)); |
| 634 } | 634 } |
| 635 } | 635 } |
| 636 } | 636 } |
| 637 | 637 |
| 638 void MemoryRegionMap::LogAllLocked() { | 638 void MemoryRegionMap::LogAllLocked() { |
| 639 RAW_CHECK(LockIsHeld(), "should be held (by this thread)"); | 639 RAW_CHECK(LockIsHeld(), "should be held (by this thread)"); |
| 640 RAW_LOG(INFO, "List of regions:"); | 640 RAW_LOG(INFO, "List of regions:"); |
| 641 uintptr_t previous = 0; | 641 uintptr_t previous = 0; |
| 642 for (RegionSet::const_iterator r = regions_->begin(); | 642 for (RegionSet::const_iterator r = regions_->begin(); |
| 643 r != regions_->end(); ++r) { | 643 r != regions_->end(); ++r) { |
| 644 RAW_LOG(INFO, "Memory region 0x%"PRIxPTR"..0x%"PRIxPTR" " | 644 RAW_LOG(INFO, "Memory region 0x%"PRIxPTR"..0x%"PRIxPTR" " |
| 645 "from 0x%"PRIxPTR" stack=%d", | 645 "from 0x%"PRIxPTR" stack=%d", |
| 646 r->start_addr, r->end_addr, r->caller(), r->is_stack); | 646 r->start_addr, r->end_addr, r->caller(), r->is_stack); |
| 647 RAW_CHECK(previous < r->end_addr, "wow, we messed up the set order"); | 647 RAW_CHECK(previous < r->end_addr, "wow, we messed up the set order"); |
| 648 // this must be caused by uncontrolled recursive operations on regions_ | 648 // this must be caused by uncontrolled recursive operations on regions_ |
| 649 previous = r->end_addr; | 649 previous = r->end_addr; |
| 650 } | 650 } |
| 651 RAW_LOG(INFO, "End of regions list"); | 651 RAW_LOG(INFO, "End of regions list"); |
| 652 } | 652 } |
| OLD | NEW |