Aman Deep Gautam
Aman Deep Gautam

Reputation: 8737

Single stepping until exit from function 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) $(CFLAGS) $(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)

I set breakpoint at some location and then do next form there but I get

Single stepping until exit from function bf_dup_eleminate_read, which has no line number information.

bf_dup_eleminate_read is a function in bloom-filter.c. I cannot understand why this is happening even if bloom-filter.c is compiled with proper options

Upvotes: 5

Views: 8206

Answers (3)

AKUMA no ONI
AKUMA no ONI

Reputation: 11819

Well its 2021 so things are a bit different now. Typicly I find the -ggdb flag more useful. It isn't only more verbose, it also seems to be less error prone (but thats my opinion). You also need to make sure that you add the -ggdb flag to all the object files as well. To give some sort of reference, and a more solid way to get your project going if its not debugging as expected. Here is a snippet from a project I just built and debugged sucessfully in VSCode v1.62.1. It was compiled w/ GNU C++ Compiler g++ 10.3, debugged with GNU Debugger gdb v9.2, and built using the make command via GNU Make 4.2.1

# Here is an example from my current project that I debug on vscode
TARGET = A10
ALL = fraction.o main.o
GCC = g++
FLAGS = -Wall -c

${TARGET}: fraction.o main.o
    ${GCC} -Wall -ggdb ${ALL} -o ${TARGET}

main.o: main.cpp fraction.h
    ${GCC} -Wall -ggdb -c main.cpp

fraction.o: fraction.cpp fraction.h
    ${GCC} -Wall -ggdb -c fraction.cpp fraction.h

Upvotes: 0

Warbean
Warbean

Reputation: 547

Try to update your gdb. It might be that your gcc version was too new. I got the same problem and fixed it after updated my gdb.

Upvotes: 0

arrowd
arrowd

Reputation: 34391

I don not see anywhere the -g flag. It informs compiler to emit debugging info, so you need to add it to compilation line, if you wish gdb to show you line numbers.

Upvotes: 5

Related Questions