Please use GitHub pull requests for new patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
compiler-rt/lib/sanitizer_common/sanitizer_procmaps_common.cpp
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | for (uptr i = 0; Next(&segment); i++) { | ||||
uptr base_address = (i ? segment.start : 0) - segment.offset; | uptr base_address = (i ? segment.start : 0) - segment.offset; | ||||
LoadedModule cur_module; | LoadedModule cur_module; | ||||
cur_module.set(cur_name, base_address); | cur_module.set(cur_name, base_address); | ||||
segment.AddAddressRanges(&cur_module); | segment.AddAddressRanges(&cur_module); | ||||
modules->push_back(cur_module); | modules->push_back(cur_module); | ||||
} | } | ||||
} | } | ||||
#if SANITIZER_LINUX || SANITIZER_ANDROID || SANITIZER_SOLARIS || SANITIZER_NETBSD | |||||
void GetMemoryProfile(fill_profile_f cb, uptr *stats) { | void GetMemoryProfile(fill_profile_f cb, uptr *stats) { | ||||
char *smaps = nullptr; | char *smaps = nullptr; | ||||
uptr smaps_cap = 0; | uptr smaps_cap = 0; | ||||
uptr smaps_len = 0; | uptr smaps_len = 0; | ||||
if (!ReadFileToBuffer("/proc/self/smaps", &smaps, &smaps_cap, &smaps_len)) | if (!ReadFileToBuffer("/proc/self/smaps", &smaps, &smaps_cap, &smaps_len)) | ||||
return; | return; | ||||
ParseUnixMemoryProfile(cb, stats, smaps, smaps_len); | ParseUnixMemoryProfile(cb, stats, smaps, smaps_len); | ||||
UnmapOrDie(smaps, smaps_cap); | UnmapOrDie(smaps, smaps_cap); | ||||
Show All 23 Lines | while (pos < end) { | ||||
} else if (internal_strncmp(pos, "Rss:", 4) == 0) { | } else if (internal_strncmp(pos, "Rss:", 4) == 0) { | ||||
while (pos < end && !IsDecimal(*pos)) pos++; | while (pos < end && !IsDecimal(*pos)) pos++; | ||||
uptr rss = ParseDecimal(&pos) * 1024; | uptr rss = ParseDecimal(&pos) * 1024; | ||||
cb(start, rss, file, stats); | cb(start, rss, file, stats); | ||||
} | } | ||||
while (*pos++ != '\n') {} | while (*pos++ != '\n') {} | ||||
} | } | ||||
} | } | ||||
#endif | |||||
} // namespace __sanitizer | } // namespace __sanitizer | ||||
#endif | #endif |