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

Bugfix debug con Valgrind #38

Merged
merged 6 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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