Path: blob/main/contrib/llvm-project/compiler-rt/include/sanitizer/nsan_interface.h
35235 views
//===-- sanitizer/nsan_interface.h ------------------------------*- C++ -*-===//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// Public interface for nsan.9//10//===----------------------------------------------------------------------===//11#ifndef SANITIZER_NSAN_INTERFACE_H12#define SANITIZER_NSAN_INTERFACE_H1314#include <sanitizer/common_interface_defs.h>1516#ifdef __cplusplus17extern "C" {18#endif1920/// User-provided default option settings.21///22/// You can provide your own implementation of this function to return a string23/// containing NSan runtime options (for example,24/// <c>verbosity=1:halt_on_error=0</c>).25///26/// \returns Default options string.27const char *__nsan_default_options(void);2829// Dumps nsan shadow data for a block of `size_bytes` bytes of application30// memory at location `addr`.31//32// Each line contains application address, shadow types, then values.33// Unknown types are shown as `__`, while known values are shown as34// `f`, `d`, `l` for float, double, and long double respectively. Position is35// shown as a single hex digit. The shadow value itself appears on the line that36// contains the first byte of the value.37// FIXME: Show both shadow and application value.38//39// Example: `__nsan_dump_shadow_mem(addr, 32, 8, 0)` might print:40//41// 0x0add7359: __ f0 f1 f2 f3 __ __ __ (42.000)42// 0x0add7361: __ d1 d2 d3 d4 d5 d6 d743// 0x0add7369: d8 f0 f1 f2 f3 __ __ f2 (-1.000) (12.5)44// 0x0add7371: f3 __ __ __ __ __ __ __45//46// This means that there is:47// - a shadow double for the float at address 0x0add7360, with value 42;48// - a shadow float128 for the double at address 0x0add7362, with value -1;49// - a shadow double for the float at address 0x0add736a, with value 12.5;50// There was also a shadow double for the float at address 0x0add736e, but bytes51// f0 and f1 were overwritten by one or several stores, so that the shadow value52// is no longer valid.53// The argument `reserved` can be any value. Its true value is provided by the54// instrumentation.55void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes,56size_t bytes_per_line, size_t reserved);5758// Explicitly dumps a value.59// FIXME: vector versions ?60void __nsan_dump_float(float value);61void __nsan_dump_double(double value);62void __nsan_dump_longdouble(long double value);6364// Explicitly checks a value.65// FIXME: vector versions ?66void __nsan_check_float(float value);67void __nsan_check_double(double value);68void __nsan_check_longdouble(long double value);6970#ifdef __cplusplus71} // extern "C"72#endif7374#endif // SANITIZER_NSAN_INTERFACE_H757677