docs: mention how to build VPP outside git
[vpp.git] / docs / gettingstarted / troubleshooting / sanitizer.rst
1 .. _sanitizer:
2
3 *****************
4 Google Sanitizers
5 *****************
6
7 VPP is instrumented to support `Google Sanitizers <https://github.com/google/sanitizers>`_.
8 As of today, only `AddressSanitizer <https://github.com/google/sanitizers/wiki/AddressSanitizer>`_
9 is supported, both for GCC and clang.
10
11 AddressSanitizer
12 ================
13
14 `AddressSanitizer <https://github.com/google/sanitizers/wiki/AddressSanitizer>`_  (aka ASan) is a memory
15 error detector for C/C++. Think Valgrind but much faster.
16
17 In order to use it, VPP must be recompiled with ASan support.
18 See developer documentation on prerequisites for :ref:`building VPP <building>`.
19
20 ASan support is implemented as a cmake build option,
21 so all VPP targets should be supported. For example:
22
23 .. code-block:: console
24
25     # build a debug image with ASan support:
26     $ make rebuild VPP_EXTRA_CMAKE_ARGS=-DVPP_ENABLE_SANITIZE_ADDR=ON
27     ....
28
29     # build a release image with ASan support:
30     $ make rebuild-release VPP_EXTRA_CMAKE_ARGS=-DVPP_ENABLE_SANITIZE_ADDR=ON
31     ....
32
33     # build packages in debug mode with ASan support:
34     $ make pkg-deb-debug VPP_EXTRA_CMAKE_ARGS=-DVPP_ENABLE_SANITIZE_ADDR=ON
35     ....
36
37     # run GBP plugin tests in debug mode with ASan
38     $ make test-debug TEST=test_gbp VPP_EXTRA_CMAKE_ARGS=-DVPP_ENABLE_SANITIZE_ADDR=ON
39     ....
40
41 Once VPP has been built with ASan support you can use it as usual including
42 under gdb:
43
44 .. code-block:: console
45
46     $ gdb --args $PWD/build-root/install-vpp_debug-native/vpp/bin/vpp "unix { interactive }"
47     ....
48