我正在使用以下Makefile编译我的代码:
CC=gcc
FL_DEBUG = -g -Wall
OBJ = src/main.o src/hash.o
hash_me: $(OBJ)
$(CC) $(FL_DEBUG) -o hash_me $(OBJ)
src/main.o: src/main.c
$(CC) $(FL_DEBUG) -c src/main.c -o src/main.o
src/hash.o: src/hash.c
$(CC) $(FL_DEBUG) -c src/hash.c -o src/hash.o
所以,当我使用valgrind调试代码时,我使用-g选项来跟踪我的错误。但是当我运行valgrind时,使用以下命令:
valgrind --tool=memcheck --leak-check=full --track-origins=yes ./hash_me file.txt
它仍然没有向我显示我的错误所在的行。我不知道我在这里错过了什么。所以它看起来像:
Conditional jump or move depends on uninitialised value(s)
==2146== at 0x10000ACFB: strlen (vg_replace_strmem.c:435)
==2146== by 0x100001152: parseFile (in ./hash_me)
==2146== by 0x100001713: hashFiles (in ./hash_me)
==2146== by 0x100000F19: main (in ./hash_me)
==2146== Uninitialised value was created by a heap allocation
==2146== at 0x10000951B: malloc (vg_replace_malloc.c:303)