Path: blob/main/contrib/llvm-project/compiler-rt/lib/memprof/memprof_linux.cpp
35236 views
//===-- memprof_linux.cpp ------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This file is a part of MemProfiler, a memory profiler.9//10// Linux-specific details.11//===----------------------------------------------------------------------===//1213#include "sanitizer_common/sanitizer_platform.h"14#if !SANITIZER_LINUX15#error Unsupported OS16#endif1718#include "memprof_interceptors.h"19#include "memprof_internal.h"20#include "memprof_thread.h"21#include "sanitizer_common/sanitizer_flags.h"22#include "sanitizer_common/sanitizer_libc.h"23#include "sanitizer_common/sanitizer_procmaps.h"2425#include <dlfcn.h>26#include <fcntl.h>27#include <limits.h>28#include <link.h>29#include <pthread.h>30#include <stdio.h>31#include <sys/mman.h>32#include <sys/resource.h>33#include <sys/syscall.h>34#include <sys/time.h>35#include <sys/types.h>36#include <sys/ucontext.h>37#include <unistd.h>38#include <unwind.h>3940typedef enum {41MEMPROF_RT_VERSION_UNDEFINED = 0,42MEMPROF_RT_VERSION_DYNAMIC,43MEMPROF_RT_VERSION_STATIC,44} memprof_rt_version_t;4546// FIXME: perhaps also store abi version here?47extern "C" {48SANITIZER_INTERFACE_ATTRIBUTE49memprof_rt_version_t __memprof_rt_version;50}5152namespace __memprof {5354void InitializePlatformInterceptors() {}55void InitializePlatformExceptionHandlers() {}5657uptr FindDynamicShadowStart() {58uptr shadow_size_bytes = MemToShadowSize(kHighMemEnd);59return MapDynamicShadow(shadow_size_bytes, SHADOW_SCALE,60/*min_shadow_base_alignment*/ 0, kHighMemEnd,61GetMmapGranularity());62}6364void *MemprofDlSymNext(const char *sym) { return dlsym(RTLD_NEXT, sym); }6566} // namespace __memprof676869