From 1d5de99f281975792abd979679233d50a1db2436 Mon Sep 17 00:00:00 2001 From: Agustin Ranieri Date: Mon, 24 Jul 2023 19:55:14 -0300 Subject: [PATCH] Bugfix debug con Valgrind (#38) --- src/compilation.mk | 12 ++++++++---- src/execution.mk | 6 +++--- src/testing.mk | 6 +++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/compilation.mk b/src/compilation.mk index 69ddbac..8269464 100644 --- a/src/compilation.mk +++ b/src/compilation.mk @@ -34,7 +34,7 @@ OBJS = $(patsubst src/%.c,obj/%.o,$(SRCS_C)) # Set test intermediate objects ifeq ($(TESTS_ENABLED),1) -TEST_OBJS = $(TESTS_C) $(filter-out $(TEST_EXCLUDE), $(SRCS_C)) +TEST_OBJS = $(filter-out $(TEST_EXCLUDE), $(TESTS_C)) $(patsubst src/%.c,obj/%.o,$(filter-out $(TEST_EXCLUDE), $(SRCS_C))) endif # Set binary targets @@ -46,12 +46,15 @@ TEST = bin/$(shell cd . && pwd | xargs basename)_tests.out endif .PHONY: all -all: CFLAGS = $(CDEBUG) -all: $(BIN) $(TEST) +all: debug $(TEST) + +.PHONY: debug +debug: CFLAGS = $(CDEBUG) +debug: $(BIN) .PHONY: release release: CFLAGS = $(CRELEASE) -release: clean $(BIN) $(TEST) +release: $(BIN) .PHONY: clean clean: @@ -71,6 +74,7 @@ obj/%.o: src/%.c $(SRCS_H) $(DEPS) | $(dir $(OBJS)) $(call compile_objs) ifeq ($(TESTS_ENABLED),1) +$(TEST): CFLAGS = $(CDEBUG) $(TEST): $(TEST_OBJS) | $(dir $(TEST)) $(CC) $(CFLAGS) -o "$@" $^ $(IDIRS:%=-I%) $(LIBDIRS:%=-L%) $(RUNDIRS:%=-Wl,-rpath,%) $(LIBS:%=-l%) -lcspecs endif diff --git a/src/execution.mk b/src/execution.mk index a67637a..c146881 100644 --- a/src/execution.mk +++ b/src/execution.mk @@ -1,5 +1,5 @@ .PHONY: start -start: $(BIN) +start: debug valgrind --tool=none ./$(BIN) $(ARGS) .PHONY: daemon @@ -10,9 +10,9 @@ daemon: done .PHONY: memcheck -memcheck: $(BIN) +memcheck: debug valgrind --leak-check=full $(MEMCHECK_FLAGS) ./$(BIN) $(ARGS) .PHONY: helgrind -helgrind: $(BIN) +helgrind: debug valgrind --tool=helgrind $(HELGRIND_FLAGS) ./$(BIN) $(ARGS) diff --git a/src/testing.mk b/src/testing.mk index 56ef1c5..8af8151 100644 --- a/src/testing.mk +++ b/src/testing.mk @@ -1,6 +1,6 @@ ifeq ($(TESTS_ENABLED),1) .PHONY: test -test: all +test: $(TEST) valgrind --tool=none ./$(TEST) .PHONY: test-daemon @@ -11,10 +11,10 @@ test-daemon: done .PHONY: test-memcheck -test-memcheck: all +test-memcheck: $(TEST) valgrind --leak-check=full $(MEMCHECK_FLAGS) ./$(TEST) .PHONY: test-helgrind -test-helgrind: all +test-helgrind: $(TEST) valgrind --tool=helgrind $(HELGRIND_FLAGS) ./$(TEST) endif