我希望使用gdb来调试程序。当我使用b lib.c:FUNCTION
在lib.c
中设置断点时,GDB会忽略断点:
Breakpoint 1 at 0x8048d03: file lib.c, line 120.
(gdb) run
Starting program: /home/jharvard/Dropbox/project/macro_main
usage: output file in rows of INT, INT, A or D
i.e. ./macro_main in/data_1
[Inferior 1 (process 14766) exited with code 01]
我认为Makefile可能有问题。我该如何解决?
CC?=gcc
CFLAGS+= -g -Wall
LDFLAGS=
LIBS = -lm
macro_main: macro_main.o lsm.o lib.o level.o
$(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $^
clean:
rm -rf *.o macro_main
编辑:下面是我得到的。可疑记录是Make breakpoint pending on future shared library load? (y or [n]) y
。它似乎表明Makefile中没有正确链接的东西。
me (~/Dropbox/project): make
make: Warning: File `Makefile' has modification time 1.7e+06 s in the future
clang -Wall -c -o macro_main.o macro_main.c
clang -Wall -c -o lsm.o lsm.c
clang -Wall -c -o lib.o lib.c
clang -Wall -c -o level.o level.c
gcc -o macro_main macro_main.o lsm.o lib.o level.o -lm
make: warning: Clock skew detected. Your build may be incomplete.
me (~/Dropbox/project): gdb ./macro_main in/data_1
Reading symbols from ./macro_main...(no debugging symbols found)...done.
"/home/me/Dropbox/project/in/data_1" is not a core dump: File format not recognized
(gdb) b main
Breakpoint 1 at 0x8048685
(gdb) run
Starting program: /home/me/Dropbox/project/macro_main
Breakpoint 1, 0x08048685 in main ()
(gdb) b lib.c:lsm_merge
No source file named lib.c.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (lib.c:lsm_merge) pending.
(gdb) continue
Continuing.
usage: output file in rows of INT, INT, A or D
i.e. ./macro_main in/data_1
[Inferior 1 (process 16156) exited with code 01]
答案 0 :(得分:0)
最后,下面的内容对我有用:
CFLAGS = -std=c99 -Wall -g -ggdb -O0
LIBS = -lm
macro_main: macro_main.o lsm.o lib.o level.o
gcc $(CFLAGS) -o $@ $^ $(LIBS)
macro_main.o: macro_main.c
gcc $(CFLAGS) -c macro_main.c
lsm.o: lsm.c
gcc $(CFLAGS) -c lsm.c
lib.o: lib.c
gcc $(CFLAGS) -c lib.c
level.o: level.c
gcc $(CFLAGS) -c level.c
clean:
rm -rf *.o macro_main