简体   繁体   中英

Debugging multiple files with gdb

I have a project which I am working on and it has multiple files and I use make to compile the project. Here is the makefile

CC =  /opt/gcc-4.7-cilkplus/bin/gcc
CFLAGS = -ggdb3 -Wall
COMPLILEFLAGS = `mysql_config --include` -I/opt/gcc-4.7-cilkplus/include/
LINKERINFO = `mysql_config --cflags --libs` -lrt -lm -lz
CILKFLAGS = -lcilkrts

# To be provided at the commandline
DIR = './bloom'
MODE = '2'
FILENAME = 'database.info'

exec: main.o mysql-client.o databaseConnection-common.o murmurhash3.o bloom-filter.o md5.o auxilary-functions.o
    $(CC) $(CFLAGS) -o exec main.o mysql-client.o databaseConnection-common.o murmurhash3.o bloom-filter.o \
    md5.o auxilary-functions.c $(LINKERINFO) $(CILKFLAGS)

main.o: main.c mysql-client.h databaseConnection-common.h bloom-filter.h
    $(CC) $(CFLAGS) $(COMPLILEFLAGS) -c main.c $(CILKFLAGS)

bloom-filter.o: bloom-filter.c bloom-filter.h murmurhash3.h auxilary-functions.h 
    $(CC) $(FLAGS) $(COMPLILEFLAGS) -c bloom-filter.c

murmurhash3.o: murmurhash3.c murmurhash3.h
    $(CC) $(CFLAGS) -c murmurhash3.c

md5.o: md5.c md5.h
    $(CC) $(CFLAGS) -c md5.c

mysql-client.o: mysql-client.c mysql-client.h databaseConnection-common.h
    $(CC) $(CFLAGS) $(COMPLILEFLAGS) -c mysql-client.c

databaseConnection-common.o: databaseConnection-common.c databaseConnection-common.h
    $(CC) $(CFLAGS) $(COMPLILEFLAGS) -c databaseConnection-common.c

auxilary-functions.o: auxilary-functions.h auxilary-functions.c
    $(CC) $(CFLAGS) -c auxilary-functions.c

run:
    ./exec $(MODE) $(FILENAME) $(DIR)

Now to debug the program, I use gdb by running the following commands in chronological order:

gdb ./exec

run 2 database.info ./bloom

Now if I try to add breakpoints in file main.c it works fine. But when I try break bloom-filter.c:340 I get the error No source file named bloom-filter.c . How can I add breakpoints in source files other than main.c

There is typo in the Makefile for target bloom-filter.o . You have mentioned the compilation flags as $(FLAGS) instead of $(CFLAGS) due to which debug flags are not enabled for bloom-filter.o which is most likely the reason why you are getting the error. Try changing $(FLAGS) to $(CFLAGS) and check.
Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM