|
| 1 | +//===-- sanitizer/nsan_interface.h ------------------------------*- C++ -*-===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// |
| 9 | +// Public interface for nsan. |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | +#ifndef SANITIZER_NSAN_INTERFACE_H |
| 13 | +#define SANITIZER_NSAN_INTERFACE_H |
| 14 | + |
| 15 | +#include <sanitizer/common_interface_defs.h> |
| 16 | + |
| 17 | +#ifdef __cplusplus |
| 18 | +extern "C" { |
| 19 | +#endif |
| 20 | + |
| 21 | +/// User-provided default option settings. |
| 22 | +/// |
| 23 | +/// You can provide your own implementation of this function to return a string |
| 24 | +/// containing NSan runtime options (for example, |
| 25 | +/// <c>verbosity=1:halt_on_error=0</c>). |
| 26 | +/// |
| 27 | +/// \returns Default options string. |
| 28 | +const char *__nsan_default_options(void); |
| 29 | + |
| 30 | +// Dumps nsan shadow data for a block of `size_bytes` bytes of application |
| 31 | +// memory at location `addr`. |
| 32 | +// |
| 33 | +// Each line contains application address, shadow types, then values. |
| 34 | +// Unknown types are shown as `__`, while known values are shown as |
| 35 | +// `f`, `d`, `l` for float, double, and long double respectively. Position is |
| 36 | +// shown as a single hex digit. The shadow value itself appears on the line that |
| 37 | +// contains the first byte of the value. |
| 38 | +// FIXME: Show both shadow and application value. |
| 39 | +// |
| 40 | +// Example: `__nsan_dump_shadow_mem(addr, 32, 8, 0)` might print: |
| 41 | +// |
| 42 | +// 0x0add7359: __ f0 f1 f2 f3 __ __ __ (42.000) |
| 43 | +// 0x0add7361: __ d1 d2 d3 d4 d5 d6 d7 |
| 44 | +// 0x0add7369: d8 f0 f1 f2 f3 __ __ f2 (-1.000) (12.5) |
| 45 | +// 0x0add7371: f3 __ __ __ __ __ __ __ |
| 46 | +// |
| 47 | +// This means that there is: |
| 48 | +// - a shadow double for the float at address 0x0add7360, with value 42; |
| 49 | +// - a shadow float128 for the double at address 0x0add7362, with value -1; |
| 50 | +// - a shadow double for the float at address 0x0add736a, with value 12.5; |
| 51 | +// There was also a shadow double for the float at address 0x0add736e, but bytes |
| 52 | +// f0 and f1 were overwritten by one or several stores, so that the shadow value |
| 53 | +// is no longer valid. |
| 54 | +// The argument `reserved` can be any value. Its true value is provided by the |
| 55 | +// instrumentation. |
| 56 | +void __nsan_dump_shadow_mem(const char *addr, size_t size_bytes, |
| 57 | + size_t bytes_per_line, size_t reserved); |
| 58 | + |
| 59 | +// Explicitly dumps a value. |
| 60 | +// FIXME: vector versions ? |
| 61 | +void __nsan_dump_float(float value); |
| 62 | +void __nsan_dump_double(double value); |
| 63 | +void __nsan_dump_longdouble(long double value); |
| 64 | + |
| 65 | +// Explicitly checks a value. |
| 66 | +// FIXME: vector versions ? |
| 67 | +void __nsan_check_float(float value); |
| 68 | +void __nsan_check_double(double value); |
| 69 | +void __nsan_check_longdouble(long double value); |
| 70 | + |
| 71 | +#ifdef __cplusplus |
| 72 | +} // extern "C" |
| 73 | +#endif |
| 74 | + |
| 75 | +#endif // SANITIZER_NSAN_INTERFACE_H |
0 commit comments