forked from OSchip/llvm-project
[asan] move GetRSS from tsan to sanitizer_common
llvm-svn: 223730
This commit is contained in:
parent
cc4487eb8b
commit
6c54a6b5dd
|
@ -66,6 +66,7 @@ bool MemoryRangeIsAvailable(uptr range_start, uptr range_end);
|
||||||
void FlushUnneededShadowMemory(uptr addr, uptr size);
|
void FlushUnneededShadowMemory(uptr addr, uptr size);
|
||||||
void IncreaseTotalMmap(uptr size);
|
void IncreaseTotalMmap(uptr size);
|
||||||
void DecreaseTotalMmap(uptr size);
|
void DecreaseTotalMmap(uptr size);
|
||||||
|
uptr GetRSS();
|
||||||
|
|
||||||
// InternalScopedBuffer can be used instead of large stack arrays to
|
// InternalScopedBuffer can be used instead of large stack arrays to
|
||||||
// keep frame size low.
|
// keep frame size low.
|
||||||
|
|
|
@ -379,6 +379,34 @@ static void ReadNullSepFileToArray(const char *path, char ***arr,
|
||||||
}
|
}
|
||||||
(*arr)[count] = 0;
|
(*arr)[count] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uptr GetRSS() {
|
||||||
|
uptr fd = OpenFile("/proc/self/statm", false);
|
||||||
|
if ((sptr)fd < 0)
|
||||||
|
return 0;
|
||||||
|
char buf[64];
|
||||||
|
uptr len = internal_read(fd, buf, sizeof(buf) - 1);
|
||||||
|
internal_close(fd);
|
||||||
|
if ((sptr)len <= 0)
|
||||||
|
return 0;
|
||||||
|
buf[len] = 0;
|
||||||
|
// The format of the file is:
|
||||||
|
// 1084 89 69 11 0 79 0
|
||||||
|
// We need the second number which is RSS in 4K units.
|
||||||
|
char *pos = buf;
|
||||||
|
// Skip the first number.
|
||||||
|
while (*pos >= '0' && *pos <= '9')
|
||||||
|
pos++;
|
||||||
|
// Skip whitespaces.
|
||||||
|
while (!(*pos >= '0' && *pos <= '9') && *pos != 0)
|
||||||
|
pos++;
|
||||||
|
// Read the number.
|
||||||
|
uptr rss = 0;
|
||||||
|
while (*pos >= '0' && *pos <= '9')
|
||||||
|
rss = rss * 10 + *pos++ - '0';
|
||||||
|
return rss * 4096;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void GetArgsAndEnv(char*** argv, char*** envp) {
|
static void GetArgsAndEnv(char*** argv, char*** envp) {
|
||||||
|
|
|
@ -317,6 +317,10 @@ MacosVersion GetMacosVersion() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uptr GetRSS() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace __sanitizer
|
} // namespace __sanitizer
|
||||||
|
|
||||||
#endif // SANITIZER_MAC
|
#endif // SANITIZER_MAC
|
||||||
|
|
|
@ -375,6 +375,10 @@ uptr internal_rename(const char *oldpath, const char *newpath) {
|
||||||
UNIMPLEMENTED();
|
UNIMPLEMENTED();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uptr GetRSS() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------- BlockingMutex ---------------- {{{1
|
// ---------------------- BlockingMutex ---------------- {{{1
|
||||||
const uptr LOCK_UNINITIALIZED = 0;
|
const uptr LOCK_UNINITIALIZED = 0;
|
||||||
const uptr LOCK_READY = (uptr)-1;
|
const uptr LOCK_READY = (uptr)-1;
|
||||||
|
|
|
@ -251,7 +251,6 @@ uptr ALWAYS_INLINE GetThreadTraceHeader(int tid) {
|
||||||
void InitializePlatform();
|
void InitializePlatform();
|
||||||
void FlushShadowMemory();
|
void FlushShadowMemory();
|
||||||
void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive);
|
void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive);
|
||||||
uptr GetRSS();
|
|
||||||
|
|
||||||
void *internal_start_thread(void(*func)(void*), void *arg);
|
void *internal_start_thread(void(*func)(void*), void *arg);
|
||||||
void internal_join_thread(void *th);
|
void internal_join_thread(void *th);
|
||||||
|
|
|
@ -118,33 +118,6 @@ void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive) {
|
||||||
nlive, nthread);
|
nlive, nthread);
|
||||||
}
|
}
|
||||||
|
|
||||||
uptr GetRSS() {
|
|
||||||
uptr fd = OpenFile("/proc/self/statm", false);
|
|
||||||
if ((sptr)fd < 0)
|
|
||||||
return 0;
|
|
||||||
char buf[64];
|
|
||||||
uptr len = internal_read(fd, buf, sizeof(buf) - 1);
|
|
||||||
internal_close(fd);
|
|
||||||
if ((sptr)len <= 0)
|
|
||||||
return 0;
|
|
||||||
buf[len] = 0;
|
|
||||||
// The format of the file is:
|
|
||||||
// 1084 89 69 11 0 79 0
|
|
||||||
// We need the second number which is RSS in 4K units.
|
|
||||||
char *pos = buf;
|
|
||||||
// Skip the first number.
|
|
||||||
while (*pos >= '0' && *pos <= '9')
|
|
||||||
pos++;
|
|
||||||
// Skip whitespaces.
|
|
||||||
while (!(*pos >= '0' && *pos <= '9') && *pos != 0)
|
|
||||||
pos++;
|
|
||||||
// Read the number.
|
|
||||||
uptr rss = 0;
|
|
||||||
while (*pos >= '0' && *pos <= '9')
|
|
||||||
rss = rss * 10 + *pos++ - '0';
|
|
||||||
return rss * 4096;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if SANITIZER_LINUX
|
#if SANITIZER_LINUX
|
||||||
void FlushShadowMemoryCallback(
|
void FlushShadowMemoryCallback(
|
||||||
const SuspendedThreadsList &suspended_threads_list,
|
const SuspendedThreadsList &suspended_threads_list,
|
||||||
|
|
|
@ -50,10 +50,6 @@ void FlushShadowMemory() {
|
||||||
void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive) {
|
void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uptr GetRSS() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef TSAN_GO
|
#ifndef TSAN_GO
|
||||||
void InitializeShadowMemory() {
|
void InitializeShadowMemory() {
|
||||||
uptr shadow = (uptr)MmapFixedNoReserve(kShadowBeg,
|
uptr shadow = (uptr)MmapFixedNoReserve(kShadowBeg,
|
||||||
|
|
|
@ -31,10 +31,6 @@ void FlushShadowMemory() {
|
||||||
void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive) {
|
void WriteMemoryProfile(char *buf, uptr buf_size, uptr nthread, uptr nlive) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uptr GetRSS() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitializePlatform() {
|
void InitializePlatform() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue