Dynamic Analysis Tools

Introduction

Several dynamic analysis tools may be configured within CMake and CTest to run as part of testing. The dynamic analysis tools test only C and C++ code. MATLAB and Python code is not tested, and external dependencies that require MATLAB or Python are disabled.

Sanitizers

AddressSanitizer

AddressSanitizer is a fast memory error detector that is part of Clang 3.1 and above and GCC 4.8 and above.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_SANITIZER=Address ..
cmake --build .
cd drake
ctest --extra-verbose .

LeakSanitizer

LeakSanitizer is a fast memory leak detector that is part of AddressSanitizer.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_SANITIZER=Leak ..
cmake --build .
cd drake
ctest --extra-verbose .

MemorySanitizer

MemorySanitizer is a fast uninitialized memory read detector that is part of Clang 3.3 and above.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_SANITIZER=Memory ..
cmake --build .
cd drake
ctest --extra-verbose .

ThreadSanitizer

ThreadSanitizer is a fast data race detector that is part of Clang 3.2 and above and GCC 4.8 and above.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_SANITIZER=Thread ..
cmake --build .
cd drake
ctest --extra-verbose .

UndefinedBehaviorSanitizer

UndefinedBehaviorSanitizer is a fast undefined behavior detector that is part of Clang 3.3 and above and GCC 4.9 and above.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_SANITIZER=Undefined ..
cmake --build .
cd drake
ctest --extra-verbose .

Valgrind Tools

Cachegrind

Cachegrind is a cache and branch-prediction profiler that is part of the Valgrind tool suite.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_VALGRIND=Cachegrind ..
cmake --build .
cd drake
ctest --extra-verbose --test-action MemCheck .

Helgrind

Helgrind is a thread error detector that is part of the Valgrind tool suite.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_VALGRIND=Helgrind ..
cmake --build .
cd drake
ctest --extra-verbose --test-action MemCheck .

Memcheck

Memcheck is a memory error detector that is part of the Valgrind tool suite.

mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_VALGRIND=Memcheck ..
cmake --build .
cd drake
ctest --extra-verbose --test-action MemCheck .