spy v3.0.0
Andrée Borrel
Loading...
Searching...
No Matches
Sanitizers

The sanitizers the code is compiled with. More...

Detailed Description

The sanitizers the code is compiled with.

Whether the current translation unit carries the instrumentation of the address or the thread sanitizer, so that code which the instrumentation would slow down or trip can step aside at compile time.

Macros

#define SPY_DISABLE_ADDRESS_SANITIZERS   spy_implementation_defined
 Prevents the address sanitizer from analyzing the function following this macro.
#define SPY_DISABLE_SANITIZERS   spy_implementation_defined
 Prevents the sanitizers from analyzing the function following this macro.
#define SPY_DISABLE_THREAD_SANITIZERS   spy_implementation_defined
 Prevents the thread sanitizer from analyzing the function following this macro.

Variables

constexpr bool spy::supports::address_sanitizers_status = spy_implementation_defined {}
 Address sanitizer status indicator.
constexpr bool spy::supports::sanitizers_status = address_sanitizers_status || thread_sanitizers_status
 Sanitizers status indicator.
constexpr bool spy::supports::thread_sanitizers_status = spy_implementation_defined {}
 Thread sanitizer status indicator.

Macro Definition Documentation

◆ SPY_DISABLE_ADDRESS_SANITIZERS

#define SPY_DISABLE_ADDRESS_SANITIZERS   spy_implementation_defined

#include <spy/sanitizers.hpp>

Prevents the address sanitizer from analyzing the function following this macro.

Example

#include <array>
#include <iostream>
#include <spy/spy.hpp>
// Hot paths left out of the sanitizers
SPY_DISABLE_ADDRESS_SANITIZERS int first(int const* data) { return data[ 0 ]; }
SPY_DISABLE_THREAD_SANITIZERS int second(int const* data) { return data[ 1 ]; }
SPY_DISABLE_SANITIZERS int sum(int const* data)
{
int total = 0;
for(int i = 0; i < 4; ++i) total += data[ i ];
return total;
}
int main()
{
std::array<int, 4> values = {1, 2, 3, 4};
int const* data = values.data();
std::cout << first(data) + second(data) + sum(data) << "\n";
}
#define SPY_DISABLE_SANITIZERS
Prevents the sanitizers from analyzing the function following this macro.
Definition sanitizers.hpp:112
#define SPY_DISABLE_ADDRESS_SANITIZERS
Prevents the address sanitizer from analyzing the function following this macro.
Definition sanitizers.hpp:94
#define SPY_DISABLE_THREAD_SANITIZERS
Prevents the thread sanitizer from analyzing the function following this macro.
Definition sanitizers.hpp:103

◆ SPY_DISABLE_SANITIZERS

#define SPY_DISABLE_SANITIZERS   spy_implementation_defined

#include <spy/sanitizers.hpp>

Prevents the sanitizers from analyzing the function following this macro.

Example

#include <array>
#include <iostream>
#include <spy/spy.hpp>
// Hot paths left out of the sanitizers
SPY_DISABLE_ADDRESS_SANITIZERS int first(int const* data) { return data[ 0 ]; }
SPY_DISABLE_THREAD_SANITIZERS int second(int const* data) { return data[ 1 ]; }
SPY_DISABLE_SANITIZERS int sum(int const* data)
{
int total = 0;
for(int i = 0; i < 4; ++i) total += data[ i ];
return total;
}
int main()
{
std::array<int, 4> values = {1, 2, 3, 4};
int const* data = values.data();
std::cout << first(data) + second(data) + sum(data) << "\n";
}

◆ SPY_DISABLE_THREAD_SANITIZERS

#define SPY_DISABLE_THREAD_SANITIZERS   spy_implementation_defined

#include <spy/sanitizers.hpp>

Prevents the thread sanitizer from analyzing the function following this macro.

Example

#include <array>
#include <iostream>
#include <spy/spy.hpp>
// Hot paths left out of the sanitizers
SPY_DISABLE_ADDRESS_SANITIZERS int first(int const* data) { return data[ 0 ]; }
SPY_DISABLE_THREAD_SANITIZERS int second(int const* data) { return data[ 1 ]; }
SPY_DISABLE_SANITIZERS int sum(int const* data)
{
int total = 0;
for(int i = 0; i < 4; ++i) total += data[ i ];
return total;
}
int main()
{
std::array<int, 4> values = {1, 2, 3, 4};
int const* data = values.data();
std::cout << first(data) + second(data) + sum(data) << "\n";
}

Variable Documentation

◆ address_sanitizers_status

bool spy::supports::address_sanitizers_status = spy_implementation_defined {}
inlineconstexpr

#include <spy/sanitizers.hpp>

Address sanitizer status indicator.

Evaluates to true when the current code is compiled with -fsanitize=address.

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
std::cout << "Address sanitizers status: "
<< (spy::supports::address_sanitizers_status ? "true" : "false") << "\n";
std::cout << "Threads sanitizers status: "
<< (spy::supports::thread_sanitizers_status ? "true" : "false") << "\n";
std::cout << "Any sanitizers status: " << (spy::supports::sanitizers_status ? "true" : "false")
<< "\n";
}
constexpr bool thread_sanitizers_status
Thread sanitizer status indicator.
Definition sanitizers.hpp:65
constexpr bool sanitizers_status
Sanitizers status indicator.
Definition sanitizers.hpp:79
constexpr bool address_sanitizers_status
Address sanitizer status indicator.
Definition sanitizers.hpp:48

◆ sanitizers_status

bool spy::supports::sanitizers_status = address_sanitizers_status || thread_sanitizers_status
inlineconstexpr

#include <spy/sanitizers.hpp>

Sanitizers status indicator.

Evaluates to true when any of the sanitizers spy detects is enabled.

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
std::cout << "Address sanitizers status: "
<< (spy::supports::address_sanitizers_status ? "true" : "false") << "\n";
std::cout << "Threads sanitizers status: "
<< (spy::supports::thread_sanitizers_status ? "true" : "false") << "\n";
std::cout << "Any sanitizers status: " << (spy::supports::sanitizers_status ? "true" : "false")
<< "\n";
}

◆ thread_sanitizers_status

bool spy::supports::thread_sanitizers_status = spy_implementation_defined {}
inlineconstexpr

#include <spy/sanitizers.hpp>

Thread sanitizer status indicator.

Evaluates to true when the current code is compiled with -fsanitize=thread.

Example

#include <iostream>
#include <spy/spy.hpp>
int main()
{
std::cout << "Address sanitizers status: "
<< (spy::supports::address_sanitizers_status ? "true" : "false") << "\n";
std::cout << "Threads sanitizers status: "
<< (spy::supports::thread_sanitizers_status ? "true" : "false") << "\n";
std::cout << "Any sanitizers status: " << (spy::supports::sanitizers_status ? "true" : "false")
<< "\n";
}