Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 1 | .. _sanitizer: |
| 2 | |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 3 | ***************** |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 4 | Google Sanitizers |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 5 | ***************** |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 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>`_ |
Damjan Marion | cea4652 | 2020-05-21 16:47:05 +0200 | [diff] [blame] | 9 | is supported, both for GCC and clang. |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 10 | |
| 11 | AddressSanitizer |
John DeNisco | a273ce6 | 2020-01-24 14:04:41 -0500 | [diff] [blame] | 12 | ================ |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 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. It is implemented as a cmake |
| 18 | build option, so all VPP targets should be supported. For example: |
| 19 | |
| 20 | .. code-block:: console |
| 21 | |
| 22 | # build a debug image with ASan support: |
Damjan Marion | cea4652 | 2020-05-21 16:47:05 +0200 | [diff] [blame] | 23 | $ make rebuild VPP_EXTRA_CMAKE_ARGS=-DVPP_ENABLE_SANITIZE_ADDR=ON |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 24 | .... |
| 25 | |
| 26 | # build a release image with ASan support: |
Damjan Marion | cea4652 | 2020-05-21 16:47:05 +0200 | [diff] [blame] | 27 | $ make rebuild-release VPP_EXTRA_CMAKE_ARGS=-DVPP_ENABLE_SANITIZE_ADDR=ON |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 28 | .... |
| 29 | |
| 30 | # build packages in debug mode with ASan support: |
Damjan Marion | cea4652 | 2020-05-21 16:47:05 +0200 | [diff] [blame] | 31 | $ make pkg-deb-debug VPP_EXTRA_CMAKE_ARGS=-DVPP_ENABLE_SANITIZE_ADDR=ON |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 32 | .... |
| 33 | |
| 34 | # run GBP plugin tests in debug mode with ASan |
Damjan Marion | cea4652 | 2020-05-21 16:47:05 +0200 | [diff] [blame] | 35 | $ make test-debug TEST=test_gbp VPP_EXTRA_CMAKE_ARGS=-DVPP_ENABLE_SANITIZE_ADDR=ON |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 36 | .... |
| 37 | |
Benoît Ganne | 332bc08 | 2020-04-21 19:25:14 +0200 | [diff] [blame] | 38 | Once VPP has been built with ASan support you can use it as usual including |
| 39 | under gdb: |
John DeNisco | d52820d | 2020-05-29 08:56:38 -0400 | [diff] [blame] | 40 | |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 41 | .. code-block:: console |
| 42 | |
Benoît Ganne | 332bc08 | 2020-04-21 19:25:14 +0200 | [diff] [blame] | 43 | $ gdb --args $PWD/build-root/install-vpp_debug-native/vpp/bin/vpp "unix { interactive }" |
Benoît Ganne | 87e64c9 | 2019-11-29 17:28:30 +0100 | [diff] [blame] | 44 | .... |
| 45 | |