From cb9afe0dc0c9bb19ad6755df5677351e1e7fbb22 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sat, 5 Apr 2014 09:26:17 -0300 Subject: Add helpers for debugging with valgrind The environment variable USE_VALGRIND can be set to run tests with valgrind. If VALGRIND_GDB is set, valgrind will start it's own gdbserver for remote debugging with `target remote | vgdb`. USE_GDB can still be used, but it will be ignored if USE_VALGRIND is set. --- src/testdir/Makefile | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/testdir') diff --git a/src/testdir/Makefile b/src/testdir/Makefile index 033ab732ac..85188b84b7 100644 --- a/src/testdir/Makefile +++ b/src/testdir/Makefile @@ -2,6 +2,8 @@ # Makefile to run all tests for Vim # +export SHELL := sh + VIMPROG := ../../build/bin/nvim SCRIPTS := test1.out test2.out test3.out test4.out test5.out test6.out \ @@ -27,8 +29,19 @@ SCRIPTS := test1.out test2.out test3.out test4.out test5.out test6.out \ SCRIPTS_GUI := test16.out + +ifdef VALGRIND_GDB +VGDB := --vgdb=yes --vgdb-error=0 +endif + +ifdef USE_VALGRIND +VALGRIND_TOOL=--tool=memcheck --leak-check=yes --track-origins=yes +# VALGRIND_TOOL=exp-sgcheck +TOOL = valgrind -q -q $(VALGRIND_TOOL) --suppressions=../../.valgrind.supp --error-exitcode=123 --log-file=valgrind.\%p.$* $(VGDB) --trace-children=yes +else ifdef USE_GDB -GDB = gdb --args +TOOL = gdb --args +endif endif ifdef TESTNUM @@ -54,10 +67,10 @@ $(SCRIPTS) $(SCRIPTS_GUI): $(VIMPROG) RM_ON_RUN = test.out X* viminfo RM_ON_START = tiny.vim small.vim mbyte.vim mzscheme.vim lua.vim test.ok -RUN_VIM = $(GDB) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in +RUN_VIM = $(TOOL) $(VIMPROG) -u unix.vim -U NONE --noplugin -s dotest.in clean: - -rm -rf *.out *.failed *.rej *.orig test.log $(RM_ON_RUN) $(RM_ON_START) valgrind.* + -rm -rf *.out *.failed *.rej *.orig test.log $(RM_ON_RUN) $(RM_ON_START) valgrind.* .*.swp .*.swo test1.out: .gdbinit test1.in -rm -rf $*.failed $(RM_ON_RUN) $(RM_ON_START) wrongtermsize -- cgit