[PATCH 4/4] doc: using asan

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.patches
Message-ID <[email protected]>
* README-hacking.md: here.
---
 README-hacking.md | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/README-hacking.md b/README-hacking.md
index d596c7e3..2fa15824 100644
--- a/README-hacking.md
+++ b/README-hacking.md
@@ -437,6 +437,31 @@ Use the `javaexec.sh` script.  For instance to run the parser of test case
 
     $ sh ./_build/javaexec.sh -cp ./_build/tests/testsuite.dir/504 Calc
 
+## Using Sanitizers
+Address sanitizer (ASAN) and undefined-behavior sanitizer (UBSAN) are very
+useful.  Here's one way to set ASAN up with GCC 10 on MacPorts
+
+1. Configure with
+
+    $ ~bison/configure -C --enable-gcc-warnings \
+        CPPFLAGS='-isystem /opt/local/include' \
+        CC='gcc-mp-10 -fsanitize=address' \
+        CFLAGS='-ggdb' \
+        CXX='g++-mp-10.0 -fsanitize=address' \
+        CXXFLAGS='-ggdb' \
+        LDFLAGS='-L/opt/local/lib'
+
+2. Compile
+
+3. Generate debug symbols:
+
+    $ dsymutil src/bison
+
+4. Run the tests with leak detection enabled
+   (`ASAN_OPTIONS=detect_leaks=1`).  E.g. for counterexamples:
+
+    $ make check-local TESTSUITEFLAGS='-j5 -k cex' ASAN_OPTIONS=detect_leaks=1
+
 ## make maintainer-check-valgrind
 This target uses valgrind both to check bison, and the generated parsers.
 
-- 
2.26.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.