11 The sanitizers support a simple mechanism for gathering profiling statistics
12 to help understand the overhead associated with sanitizers.
17 SanitizerStats can currently only be used with :doc:`ControlFlowIntegrity`.
18 In addition to ``-fsanitize=cfi*``, pass the ``-fsanitize-stats`` flag.
19 This will cause the program to count the number of times that each control
20 flow integrity check in the program fires.
22 At run time, set the ``SANITIZER_STATS_PATH`` environment variable to direct
23 statistics output to a file. The file will be written on process exit.
24 The following substitutions will be applied to the environment variable:
26 - ``%b`` -- The executable basename.
27 - ``%p`` -- The process ID.
29 You can also send the ``SIGUSR2`` signal to a process to make it write
30 sanitizer statistics immediately.
32 The ``sanstats`` program can be used to dump statistics. It takes as a
33 command line argument the path to a statistics file produced by a program
34 compiled with ``-fsanitize-stats``.
36 The output of ``sanstats`` is in four columns, separated by spaces. The first
37 column is the file and line number of the call site. The second column is
38 the function name. The third column is the type of statistic gathered (in
39 this case, the type of control flow integrity check). The fourth column is
44 .. code-block:: console
51 5 __attribute__((noinline)) void g(A *a) {
59 $ clang++ -fsanitize=cfi -fvisibility=hidden -flto -fuse-ld=gold vcall.cc -fsanitize-stats -g
60 $ SANITIZER_STATS_PATH=a.stats ./a.out
62 vcall.cc:6 _Z1gP1A cfi-vcall 1