| 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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 "to %"PRIuS" flags %d new_addr=0x%"PRIxPTR, | 621 "to %"PRIuS" flags %d new_addr=0x%"PRIxPTR, |
| 622 (uintptr_t)result, (uintptr_t)old_addr, | 622 (uintptr_t)result, (uintptr_t)old_addr, |
| 623 old_size, new_size, flags, | 623 old_size, new_size, flags, |
| 624 flags & MREMAP_FIXED ? (uintptr_t)new_addr : 0); | 624 flags & MREMAP_FIXED ? (uintptr_t)new_addr : 0); |
| 625 if (result != reinterpret_cast<void*>(-1)) { | 625 if (result != reinterpret_cast<void*>(-1)) { |
| 626 RecordRegionRemoval(old_addr, old_size); | 626 RecordRegionRemoval(old_addr, old_size); |
| 627 RecordRegionAddition(result, new_size); | 627 RecordRegionAddition(result, new_size); |
| 628 } | 628 } |
| 629 } | 629 } |
| 630 | 630 |
| 631 extern "C" void* __sbrk(ptrdiff_t increment); // defined in libc | 631 extern "C" void* __sbrk(std::ptrdiff_t increment); // defined in libc |
| 632 | 632 |
| 633 void MemoryRegionMap::SbrkHook(const void* result, ptrdiff_t increment) { | 633 void MemoryRegionMap::SbrkHook(const void* result, std::ptrdiff_t increment) { |
| 634 RAW_VLOG(10, "Sbrk = 0x%"PRIxPTR" of %"PRIdS"", (uintptr_t)result, increment); | 634 RAW_VLOG(10, "Sbrk = 0x%"PRIxPTR" of %"PRIdS"", (uintptr_t)result, increment); |
| 635 if (result != reinterpret_cast<void*>(-1)) { | 635 if (result != reinterpret_cast<void*>(-1)) { |
| 636 if (increment > 0) { | 636 if (increment > 0) { |
| 637 void* new_end = sbrk(0); | 637 void* new_end = sbrk(0); |
| 638 RecordRegionAddition(result, reinterpret_cast<uintptr_t>(new_end) - | 638 RecordRegionAddition(result, reinterpret_cast<uintptr_t>(new_end) - |
| 639 reinterpret_cast<uintptr_t>(result)); | 639 reinterpret_cast<uintptr_t>(result)); |
| 640 } else if (increment < 0) { | 640 } else if (increment < 0) { |
| 641 void* new_end = sbrk(0); | 641 void* new_end = sbrk(0); |
| 642 RecordRegionRemoval(new_end, reinterpret_cast<uintptr_t>(result) - | 642 RecordRegionRemoval(new_end, reinterpret_cast<uintptr_t>(result) - |
| 643 reinterpret_cast<uintptr_t>(new_end)); | 643 reinterpret_cast<uintptr_t>(new_end)); |
| 644 } | 644 } |
| 645 } | 645 } |
| 646 } | 646 } |
| 647 | 647 |
| 648 void MemoryRegionMap::LogAllLocked() { | 648 void MemoryRegionMap::LogAllLocked() { |
| 649 RAW_CHECK(LockIsHeld(), "should be held (by this thread)"); | 649 RAW_CHECK(LockIsHeld(), "should be held (by this thread)"); |
| 650 RAW_LOG(INFO, "List of regions:"); | 650 RAW_LOG(INFO, "List of regions:"); |
| 651 uintptr_t previous = 0; | 651 uintptr_t previous = 0; |
| 652 for (RegionSet::const_iterator r = regions_->begin(); | 652 for (RegionSet::const_iterator r = regions_->begin(); |
| 653 r != regions_->end(); ++r) { | 653 r != regions_->end(); ++r) { |
| 654 RAW_LOG(INFO, "Memory region 0x%"PRIxPTR"..0x%"PRIxPTR" " | 654 RAW_LOG(INFO, "Memory region 0x%"PRIxPTR"..0x%"PRIxPTR" " |
| 655 "from 0x%"PRIxPTR" stack=%d", | 655 "from 0x%"PRIxPTR" stack=%d", |
| 656 r->start_addr, r->end_addr, r->caller(), r->is_stack); | 656 r->start_addr, r->end_addr, r->caller(), r->is_stack); |
| 657 RAW_CHECK(previous < r->end_addr, "wow, we messed up the set order"); | 657 RAW_CHECK(previous < r->end_addr, "wow, we messed up the set order"); |
| 658 // this must be caused by uncontrolled recursive operations on regions_ | 658 // this must be caused by uncontrolled recursive operations on regions_ |
| 659 previous = r->end_addr; | 659 previous = r->end_addr; |
| 660 } | 660 } |
| 661 RAW_LOG(INFO, "End of regions list"); | 661 RAW_LOG(INFO, "End of regions list"); |
| 662 } | 662 } |
| OLD | NEW |