Skip to content

Commit 1068cf7

Browse files
committed
[NFC][lsan] Rename RootRegion and replace size with end
1 parent b6a5aea commit 1068cf7

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

compiler-rt/lib/lsan/lsan_common.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ static LeakSuppressionContext *GetSuppressionContext() {
241241
return suppression_ctx;
242242
}
243243

244-
static InternalMmapVectorNoCtor<RootRegion> root_regions;
244+
static InternalMmapVectorNoCtor<Region> root_regions;
245245

246-
InternalMmapVectorNoCtor<RootRegion> const *GetRootRegions() {
246+
InternalMmapVectorNoCtor<Region> const *GetRootRegions() {
247247
return &root_regions;
248248
}
249249

@@ -527,24 +527,22 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
527527

528528
# endif // SANITIZER_FUCHSIA
529529

530-
void ScanRootRegion(Frontier *frontier, const RootRegion &root_region,
530+
void ScanRootRegion(Frontier *frontier, const Region &root_region,
531531
uptr region_begin, uptr region_end, bool is_readable) {
532532
uptr intersection_begin = Max(root_region.begin, region_begin);
533-
uptr intersection_end = Min(region_end, root_region.begin + root_region.size);
533+
uptr intersection_end = Min(region_end, root_region.end);
534534
if (intersection_begin >= intersection_end)
535535
return;
536536
LOG_POINTERS("Root region %p-%p intersects with mapped region %p-%p (%s)\n",
537-
(void *)root_region.begin,
538-
(void *)(root_region.begin + root_region.size),
537+
(void *)root_region.begin, (void *)root_region.end,
539538
(void *)region_begin, (void *)region_end,
540539
is_readable ? "readable" : "unreadable");
541540
if (is_readable)
542541
ScanRangeForPointers(intersection_begin, intersection_end, frontier, "ROOT",
543542
kReachable);
544543
}
545544

546-
static void ProcessRootRegion(Frontier *frontier,
547-
const RootRegion &root_region) {
545+
static void ProcessRootRegion(Frontier *frontier, const Region &root_region) {
548546
MemoryMappingLayout proc_maps(/*cache_enabled*/ true);
549547
MemoryMappedSegment segment;
550548
while (proc_maps.Next(&segment)) {
@@ -1014,7 +1012,8 @@ SANITIZER_INTERFACE_ATTRIBUTE
10141012
void __lsan_register_root_region(const void *begin, uptr size) {
10151013
#if CAN_SANITIZE_LEAKS
10161014
Lock l(&global_mutex);
1017-
RootRegion region = {reinterpret_cast<uptr>(begin), size};
1015+
Region region = {reinterpret_cast<uptr>(begin),
1016+
reinterpret_cast<uptr>(begin) + size};
10181017
root_regions.push_back(region);
10191018
VReport(1, "Registered root region at %p of size %zu\n", begin, size);
10201019
#endif // CAN_SANITIZE_LEAKS
@@ -1025,9 +1024,10 @@ void __lsan_unregister_root_region(const void *begin, uptr size) {
10251024
#if CAN_SANITIZE_LEAKS
10261025
Lock l(&global_mutex);
10271026
bool removed = false;
1027+
uptr end = reinterpret_cast<uptr>(begin) + size;
10281028
for (uptr i = 0; i < root_regions.size(); i++) {
1029-
RootRegion region = root_regions[i];
1030-
if (region.begin == reinterpret_cast<uptr>(begin) && region.size == size) {
1029+
Region region = root_regions[i];
1030+
if (region.begin == reinterpret_cast<uptr>(begin) && region.end == end) {
10311031
removed = true;
10321032
uptr last_index = root_regions.size() - 1;
10331033
root_regions[i] = root_regions[last_index];

compiler-rt/lib/lsan/lsan_common.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ void InitializePlatformSpecificModules();
239239
void ProcessGlobalRegions(Frontier *frontier);
240240
void ProcessPlatformSpecificAllocations(Frontier *frontier);
241241

242-
struct RootRegion {
242+
struct Region {
243243
uptr begin;
244-
uptr size;
244+
uptr end;
245245
};
246246

247247
// LockStuffAndStopTheWorld can start to use Scan* calls to collect into
@@ -256,9 +256,9 @@ struct CheckForLeaksParam {
256256
bool success = false;
257257
};
258258

259-
InternalMmapVectorNoCtor<RootRegion> const *GetRootRegions();
260-
void ScanRootRegion(Frontier *frontier, RootRegion const &region,
261-
uptr region_begin, uptr region_end, bool is_readable);
259+
InternalMmapVectorNoCtor<Region> const *GetRootRegions();
260+
void ScanRootRegion(Frontier *frontier, const Region &region, uptr region_begin,
261+
uptr region_end, bool is_readable);
262262
// Run stoptheworld while holding any platform-specific locks, as well as the
263263
// allocator and thread registry locks.
264264
void LockStuffAndStopTheWorld(StopTheWorldCallback callback,

compiler-rt/lib/lsan/lsan_common_mac.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ void ProcessPlatformSpecificAllocations(Frontier *frontier) {
165165
vm_address_t address = 0;
166166
kern_return_t err = KERN_SUCCESS;
167167

168-
InternalMmapVectorNoCtor<RootRegion> const *root_regions = GetRootRegions();
168+
InternalMmapVectorNoCtor<Region> const *root_regions = GetRootRegions();
169169

170170
RegionScanState scan_state;
171171
while (err == KERN_SUCCESS) {

0 commit comments

Comments
 (0)