aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2022-06-12 19:54:14 +0200
committerGitHub <noreply@github.com>2022-06-12 10:54:14 -0700
commitf4967828f905fa055d0e69d48a7d735d7f967e1e (patch)
treea7a200778891f6277acea1986cb4f215c048da0d
parent502f03fc064d1eb427d214521d5cb9f5425a15b4 (diff)
downloadrneovim-f4967828f905fa055d0e69d48a7d735d7f967e1e.tar.gz
rneovim-f4967828f905fa055d0e69d48a7d735d7f967e1e.tar.bz2
rneovim-f4967828f905fa055d0e69d48a7d735d7f967e1e.zip
feat(contrib): asan debugging script #18892
Opted to use a shell script because it's simpler to manipulate environment variables than in makefiles.
-rwxr-xr-xcontrib/asan.sh28
1 files changed, 28 insertions, 0 deletions
diff --git a/contrib/asan.sh b/contrib/asan.sh
new file mode 100755
index 0000000000..7e7dffa1af
--- /dev/null
+++ b/contrib/asan.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# Helper script to build and run neovim with Address Sanitizer enabled.
+# You may read more information in src/nvim/README.md in the section "Build
+# with ASAN".
+
+shopt -s nullglob
+
+root_path=$(git rev-parse --show-toplevel)
+log_path=$(mktemp -d)
+export CC='clang'
+
+# Change to detect_leaks=1 to detect memory leaks (slower).
+export ASAN_OPTIONS="detect_leaks=0:log_path=$log_path/asan"
+
+# Show backtraces in the logs.
+export UBSAN_OPTIONS="print_stacktrace=1"
+
+make -C "$root_path" CMAKE_EXTRA_FLAGS="-DCLANG_ASAN_UBSAN=ON"
+VIMRUNTIME="$root_path"/runtime "$root_path"/build/bin/nvim
+
+# Need to manually reset terminal to avoid mangled output, nvim does not
+# properly restore the terminal when it crashes.
+tput reset
+
+for i in "$log_path"/*; do
+ cat "$i"
+done