llvm/compiler-rt/lib/sanitizer_common/sanitizer_common.cpp

//===-- sanitizer_common.cpp ----------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file is shared between AddressSanitizer and ThreadSanitizer
// run-time libraries.
//===----------------------------------------------------------------------===//

#include "sanitizer_common.h"

#include "sanitizer_allocator_interface.h"
#include "sanitizer_allocator_internal.h"
#include "sanitizer_atomic.h"
#include "sanitizer_flags.h"
#include "sanitizer_interface_internal.h"
#include "sanitizer_libc.h"
#include "sanitizer_placement_new.h"

namespace __sanitizer {

const char *SanitizerToolName =;

atomic_uint32_t current_verbosity;
uptr PageSizeCached;
u32 NumberOfCPUsCached;

// PID of the tracer task in StopTheWorld. It shares the address space with the
// main process, but has a different PID and thus requires special handling.
uptr stoptheworld_tracer_pid =;
// Cached pid of parent process - if the parent process dies, we want to keep
// writing to the same log file.
uptr stoptheworld_tracer_ppid =;

void NORETURN ReportMmapFailureAndDie(uptr size, const char *mem_type,
                                      const char *mmap_type, error_t err,
                                      bool raw_report) {}

void NORETURN ReportMunmapFailureAndDie(void *addr, uptr size, error_t err,
                                        bool raw_report) {}

UptrComparisonFunction;
U32ComparisonFunction;

const char *StripPathPrefix(const char *filepath,
                            const char *strip_path_prefix) {}

const char *StripModuleName(const char *module) {}

void ReportErrorSummary(const char *error_message, const char *alt_tool_name) {}

// Removes the ANSI escape sequences from the input string (in-place).
void RemoveANSIEscapeSequencesFromString(char *str) {}

void LoadedModule::set(const char *module_name, uptr base_address) {}

void LoadedModule::set(const char *module_name, uptr base_address,
                       ModuleArch arch, u8 uuid[kModuleUUIDSize],
                       bool instrumented) {}

void LoadedModule::setUuid(const char *uuid, uptr size) {}

void LoadedModule::clear() {}

void LoadedModule::addAddressRange(uptr beg, uptr end, bool executable,
                                   bool writable, const char *name) {}

bool LoadedModule::containsAddress(uptr address) const {}

static atomic_uintptr_t g_total_mmaped;

void IncreaseTotalMmap(uptr size) {}

void DecreaseTotalMmap(uptr size) {}

bool TemplateMatch(const char *templ, const char *str) {}

static char binary_name_cache_str[kMaxPathLength];
static char process_name_cache_str[kMaxPathLength];

const char *GetProcessName() {}

static uptr ReadProcessName(/*out*/ char *buf, uptr buf_len) {}

void UpdateProcessName() {}

// Call once to make sure that binary_name_cache_str is initialized
void CacheBinaryName() {}

uptr ReadBinaryNameCached(/*out*/char *buf, uptr buf_len) {}

uptr ReadBinaryDir(/*out*/ char *buf, uptr buf_len) {}

#if !SANITIZER_GO
void PrintCmdline() {}
#endif

// Malloc hooks.
static const int kMaxMallocFreeHooks =;
struct MallocFreeHook {};

static MallocFreeHook MFHooks[kMaxMallocFreeHooks];

void RunMallocHooks(void *ptr, uptr size) {}

// Returns '1' if the call to free() should be ignored (based on
// __sanitizer_ignore_free_hook), or '0' otherwise.
int RunFreeHooks(void *ptr) {}

static int InstallMallocFreeHooks(void (*malloc_hook)(const void *, uptr),
                                  void (*free_hook)(const void *)) {}

void internal_sleep(unsigned seconds) {}
void SleepForSeconds(unsigned seconds) {}
void SleepForMillis(unsigned millis) {}

void WaitForDebugger(unsigned seconds, const char *label) {}

} // namespace __sanitizer

usingnamespace__sanitizer;

extern "C" {
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_report_error_summary,
                             const char *error_summary) {}

SANITIZER_INTERFACE_ATTRIBUTE
int __sanitizer_acquire_crash_state() {}

SANITIZER_INTERFACE_ATTRIBUTE
int __sanitizer_install_malloc_and_free_hooks(void (*malloc_hook)(const void *,
                                                                  uptr),
                                              void (*free_hook)(const void *)) {}

// Provide default (no-op) implementation of malloc hooks.
SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_malloc_hook, void *ptr,
                             uptr size) {}

SANITIZER_INTERFACE_WEAK_DEF(void, __sanitizer_free_hook, void *ptr) {}

SANITIZER_INTERFACE_WEAK_DEF(int, __sanitizer_ignore_free_hook, void *ptr) {}

} // extern "C"