Skip to content

Commit f6a5926

Browse files
committed
Introduce valgrind to the CI pipeline
The static analyzer along can't catch all the runtime issues. In this commit, dynamic analysis tool Valgrind is added to the CI pipeline. Reference: - https://valgrind.org/docs/manual/quick-start.html - https://linux.die.net/man/1/gcc
1 parent 9e4e13e commit f6a5926

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,18 @@ jobs:
7373
run: |
7474
make ENABLE_UBSAN=1 clean check
7575
make ENABLE_JIT=1 ENABLE_UBSAN=1 clean check
76+
- name: valgrind check (without JIT)
77+
run: |
78+
make clean
79+
make ENABLE_JIT=0 ENABLE_VALGRIND=1
80+
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/hello.elf
81+
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/aes.elf
82+
- name: valgrind check (with JIT)
83+
run: |
84+
make clean
85+
make ENABLE_JIT=1 ENABLE_VALGRIND=1
86+
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/hello.elf
87+
valgrind --leak-check=full --show-leak-kinds=all --error-exitcode=1 ./build/rv32emu ./build/aes.elf
7688
7789
host-arm64:
7890
needs: [detect-code-related-file-changes]

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ CFLAGS = -std=gnu99 -O2 -Wall -Wextra
1111
CFLAGS += -Wno-unused-label
1212
CFLAGS += -include src/common.h
1313

14+
ENABLE_VALGRIND ?= 0
15+
ifeq ("$(ENABLE_UBSAN)", "1")
16+
# according to gcc's man page: "If you use multiple -O options, with or without level numbers, the last such option is the one that is effective."
17+
# In order to use Valgrind, we need to compile with -g
18+
CFLAGS += -g
19+
LDFLAGS += -g
20+
endif
21+
1422
# Enable link-time optimization (LTO)
1523
ENABLE_LTO ?= 1
1624
ifeq ($(call has, LTO), 1)

0 commit comments

Comments
 (0)