Skip to content

Commit bc995c0

Browse files
committed
Add info about debugging (valgrind and address sanitizer flags) in README.
1 parent 7b0c00e commit bc995c0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Use the [installer](https://github.com/metacall/install) and try [some examples]
7474
- [6. Build System](#6-build-system)
7575
- [6.1 Build Options](#61-build-options)
7676
- [6.2 Coverage](#62-coverage)
77+
- [6.3 Debugging](#63-debugging)
7778
- [7. Platform Support](#7-platform-support)
7879
- [7.1 Docker Support](#71-docker-support)
7980
- [7.1.1 Docker Development](#711-docker-development)
@@ -607,6 +608,37 @@ make <target>-geninfo
607608
make <target>-genhtml
608609
```
609610

611+
### 6.3 Debugging
612+
613+
For debugging memory leaks, undefined behaviors and other related problems, the following compile options are provided:
614+
615+
| Build Option | Description | Default Value |
616+
|:----------------------------:|--------------------------------------------------------|:-------------:|
617+
| **OPTION_TEST_MEMORYCHECK** | Enable Valgrind with memcheck tool for the tests. | OFF |
618+
| **OPTION_BUILD_SANITIZER** | Build with AddressSanitizer family (GCC and Clang). | OFF |
619+
620+
Both options are mutually exclusive. Valgrind is not compatible with AddressSanitizer. The current implementation does not support MSVC compiler (yet). Some run-times may fail if they are not compiled with AddressSanitizer too, for example NetCore. Due to this, tests implying may fail with signal 11. The same problem happens with Valgrind, due to that, some tests are excluded of the memcheck target.
621+
622+
For running all tests with Valgrind, enable the `OPTION_TEST_MEMORYCHECK` flag and then run:
623+
624+
```sh
625+
make memcheck
626+
```
627+
628+
For runing a test (or all) with AddressSanitizer, enable the `OPTION_BUILD_SANITIZER` flag and then run:
629+
630+
```sh
631+
# Run one test
632+
make py_loader rb_loader node_loader metacall-node-port-test # Build required dependencies and a test
633+
ctest -VV -R metacall-node-port-test # Run one test (verbose)
634+
635+
# Run all
636+
make
637+
ctest
638+
```
639+
640+
For running other Valgrind's tools like helgrind or similar, I recommend running them manually. Just run one test with `ctest -VV -R metacall-node-port-test`, copy the environment variables, and configure the flags by yourself.
641+
610642
## 7. Platform Support
611643

612644
The following platforms and architectures have been tested an work correctly with all plugins of **METACALL**.

0 commit comments

Comments
 (0)