Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Bugfix debug con Valgrind (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
RaniAgus committed Jul 26, 2023
1 parent 34b00da commit 1d5de99
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/compilation.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/execution.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: start
start: $(BIN)
start: debug
valgrind --tool=none ./$(BIN) $(ARGS)

.PHONY: daemon
Expand All @@ -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)
6 changes: 3 additions & 3 deletions src/testing.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ifeq ($(TESTS_ENABLED),1)
.PHONY: test
test: all
test: $(TEST)
valgrind --tool=none ./$(TEST)

.PHONY: test-daemon
Expand All @@ -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

0 comments on commit 1d5de99

Please sign in to comment.