Add documentation on running Trick with sanitizers

This commit is contained in:
Jacqueline Deans 2023-01-20 17:33:35 -06:00
parent 5ff52a01c5
commit e11ff83051
2 changed files with 36 additions and 0 deletions

View File

@ -8,3 +8,4 @@ Link documentation for Trick internals, processes, and plans here.
- [Testing](Testing)
- [How to make a new Trick release on GitHub](How-To-Make-A-Release)
- [Tooling and Sanitizers](Tooling-and-Sanitizers)

View File

@ -0,0 +1,35 @@
| [Home](/trick) → [Developer Docs](Developer-Docs-Home) → Tooling and Sanitizers |
|------------------------------------------------------------------|
Lots of development and debugging tools require a binary to be instrumented with compiler flags. Trick does compiling and linking steps separately and uses several variables to propogate flags to different parts of the build. The following is a convenience function that can be added to your bashrc to easily modify the flags in your environment:
```
add-trickenv () {
export CFLAGS="$CFLAGS $1"
export CXXFLAGS="$CXXFLAGS $1"
export LDFLAGS="$LDFLAGS $1"
export TRICK_CFLAGS="$TRICK_CFLAGS $1"
export TRICK_CXXFLAGS="$TRICK_CXXFLAGS $1"
export TRICK_LDFLAGS="$TRICK_LDFLAGS $1"
export TRICK_SYSTEM_CFLAGS="$TRICK_SYSTEM_CFLAGS $1"
export TRICK_SYSTEM_CXXFLAGS="$TRICK_SYSTEM_CXXFLAGS $1"
export TRICK_SYSTEM_LDFLAGS="$TRICK_SYSTEM_LDFLAGS $1"
}
```
To debug a sim, you will likely need to run a clean build of all of Trick with these flags set.
## Tools that are known to work well with Trick
GDB/LLDB: `-g`
gcov: `-fprofile-arcs -ftest-coverage -O0`
tsan: `-g -fsanitize=thread`
asan: `-g -fsanitize=address -fsanitize-recover=address`
Suggest running asan instrumented sims with:
`ASAN_OPTIONS=halt_on_error=0 ./S_main* <your args>`