forked from OSchip/llvm-project
[Sanitizer] move DumpProcessMap and DisableCoreDumper to common runtime
llvm-svn: 158490
This commit is contained in:
parent
574cb4c2af
commit
ae1e171b72
|
@ -122,9 +122,7 @@ void ReplaceSystemMalloc();
|
|||
// asan_linux.cc / asan_mac.cc / asan_win.cc
|
||||
void *AsanDoesNotSupportStaticLinkage();
|
||||
bool AsanShadowRangeIsAvailable();
|
||||
void AsanDumpProcessMap();
|
||||
|
||||
void AsanDisableCoreDumper();
|
||||
void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp);
|
||||
|
||||
bool AsanInterceptsSignal(int signum);
|
||||
|
|
|
@ -134,26 +134,6 @@ void InstallSignalHandlers() {
|
|||
MaybeInstallSigaction(SIGBUS, ASAN_OnSIGSEGV);
|
||||
}
|
||||
|
||||
void AsanDisableCoreDumper() {
|
||||
struct rlimit nocore;
|
||||
nocore.rlim_cur = 0;
|
||||
nocore.rlim_max = 0;
|
||||
setrlimit(RLIMIT_CORE, &nocore);
|
||||
}
|
||||
|
||||
void AsanDumpProcessMap() {
|
||||
ProcessMaps proc_maps;
|
||||
uptr start, end;
|
||||
const sptr kBufSize = 4095;
|
||||
char filename[kBufSize];
|
||||
Report("Process memory map follows:\n");
|
||||
while (proc_maps.Next(&start, &end, /* file_offset */0,
|
||||
filename, kBufSize)) {
|
||||
Printf("\t%p-%p\t%s\n", (void*)start, (void*)end, filename);
|
||||
}
|
||||
Report("End of process memory map.\n");
|
||||
}
|
||||
|
||||
uptr GetThreadSelf() {
|
||||
return (uptr)pthread_self();
|
||||
}
|
||||
|
|
|
@ -536,7 +536,7 @@ void __asan_init() {
|
|||
}
|
||||
|
||||
if (FLAG_disable_core) {
|
||||
AsanDisableCoreDumper();
|
||||
DisableCoreDumper();
|
||||
}
|
||||
|
||||
if (AsanShadowRangeIsAvailable()) {
|
||||
|
@ -552,7 +552,7 @@ void __asan_init() {
|
|||
} else {
|
||||
Report("Shadow memory range interleaves with an existing memory mapping. "
|
||||
"ASan cannot proceed correctly. ABORTING.\n");
|
||||
AsanDumpProcessMap();
|
||||
DumpProcessMap();
|
||||
Die();
|
||||
}
|
||||
|
||||
|
|
|
@ -192,10 +192,6 @@ u8 AtomicExchange(u8 *a, u8 new_val) {
|
|||
return t;
|
||||
}
|
||||
|
||||
void AsanDumpProcessMap() {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
uptr GetThreadSelf() {
|
||||
return GetCurrentThreadId();
|
||||
}
|
||||
|
@ -212,10 +208,6 @@ void InstallSignalHandlers() {
|
|||
// FIXME: Decide what to do on Windows.
|
||||
}
|
||||
|
||||
void AsanDisableCoreDumper() {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void SleepForSeconds(int seconds) {
|
||||
Sleep(seconds * 1000);
|
||||
}
|
||||
|
|
|
@ -55,6 +55,10 @@ uptr ReadFileToBuffer(const char *file_name, char **buff,
|
|||
uptr *buff_size, uptr max_len);
|
||||
const char *GetEnv(const char *name);
|
||||
|
||||
// Other
|
||||
void DisableCoreDumper();
|
||||
void DumpProcessMap();
|
||||
|
||||
// Bit twiddling.
|
||||
inline bool IsPowerOfTwo(uptr x) {
|
||||
return (x & (x - 1)) == 0;
|
||||
|
|
|
@ -15,15 +15,20 @@
|
|||
|
||||
#include "sanitizer_common.h"
|
||||
#include "sanitizer_libc.h"
|
||||
#include "sanitizer_procmaps.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace __sanitizer {
|
||||
|
||||
// ------------- sanitizer_common.h
|
||||
|
||||
int GetPid() {
|
||||
return getpid();
|
||||
}
|
||||
|
@ -65,6 +70,28 @@ void *Mprotect(uptr fixed_addr, uptr size) {
|
|||
0, 0);
|
||||
}
|
||||
|
||||
void DumpProcessMap() {
|
||||
ProcessMaps proc_maps;
|
||||
uptr start, end;
|
||||
const sptr kBufSize = 4095;
|
||||
char filename[kBufSize];
|
||||
Report("Process memory map follows:\n");
|
||||
while (proc_maps.Next(&start, &end, /* file_offset */0,
|
||||
filename, kBufSize)) {
|
||||
Printf("\t%p-%p\t%s\n", (void*)start, (void*)end, filename);
|
||||
}
|
||||
Report("End of process memory map.\n");
|
||||
}
|
||||
|
||||
void DisableCoreDumper() {
|
||||
struct rlimit nocore;
|
||||
nocore.rlim_cur = 0;
|
||||
nocore.rlim_max = 0;
|
||||
setrlimit(RLIMIT_CORE, &nocore);
|
||||
}
|
||||
|
||||
// -------------- sanitizer_libc.h
|
||||
|
||||
int internal_sscanf(const char *str, const char *format, ...) {
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
|
|
|
@ -82,6 +82,14 @@ const char *GetEnv(const char *name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void DumpProcessMap() {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void DisableCoreDumper() {
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
// ------------------ sanitizer_libc.h
|
||||
void *internal_mmap(void *addr, uptr length, int prot, int flags,
|
||||
int fd, u64 offset) {
|
||||
|
|
Loading…
Reference in New Issue