blob: a63720ffe4236151cfc2529bfa6d4fefd22d55b4 [file] [log] [blame]
Benoît Ganne87e64c92019-11-29 17:28:30 +01001.. _sanitizer:
2
John DeNiscoa273ce62020-01-24 14:04:41 -05003*****************
Benoît Ganne87e64c92019-11-29 17:28:30 +01004Google Sanitizers
John DeNiscoa273ce62020-01-24 14:04:41 -05005*****************
Benoît Ganne87e64c92019-11-29 17:28:30 +01006
7VPP is instrumented to support `Google Sanitizers <https://github.com/google/sanitizers>`_.
8As of today, only `AddressSanitizer <https://github.com/google/sanitizers/wiki/AddressSanitizer>`_
9is supported and only for the heap.
10
11AddressSanitizer
John DeNiscoa273ce62020-01-24 14:04:41 -050012================
Benoît Ganne87e64c92019-11-29 17:28:30 +010013
14`AddressSanitizer <https://github.com/google/sanitizers/wiki/AddressSanitizer>`_ (aka ASan) is a memory
15error detector for C/C++. Think Valgrind but much faster.
16
17In order to use it, VPP must be recompiled with ASan support. It is implemented as a cmake
18build option, so all VPP targets should be supported. For example:
19
20.. code-block:: console
21
22 # build a debug image with ASan support:
23 $ make rebuild VPP_EXTRA_CMAKE_ARGS=-DENABLE_SANITIZE_ADDR=ON
24 ....
25
26 # build a release image with ASan support:
27 $ make rebuild-release VPP_EXTRA_CMAKE_ARGS=-DENABLE_SANITIZE_ADDR=ON
28 ....
29
30 # build packages in debug mode with ASan support:
31 $ make pkg-deb-debug VPP_EXTRA_CMAKE_ARGS=-DENABLE_SANITIZE_ADDR=ON
32 ....
33
34 # run GBP plugin tests in debug mode with ASan
35 $ make test-debug TEST=test_gbp VPP_EXTRA_CMAKE_ARGS=-DENABLE_SANITIZE_ADDR=ON
36 ....
37
Benoît Ganne332bc082020-04-21 19:25:14 +020038Once VPP has been built with ASan support you can use it as usual including
39under gdb:
Benoît Ganne87e64c92019-11-29 17:28:30 +010040.. code-block:: console
41
Benoît Ganne332bc082020-04-21 19:25:14 +020042 $ gdb --args $PWD/build-root/install-vpp_debug-native/vpp/bin/vpp "unix { interactive }"
Benoît Ganne87e64c92019-11-29 17:28:30 +010043 ....
44