Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the line numbers for GDB?

Tags:

c++

gdb

Is there a specific way to do this? I'm speaking in general purposes. When I try to launch my program in GDB for example, I get this notification:

Reading symbols from /home/amsterdam/Code/c++/opengl_03/bin/opengl_03...(no debugging symbols found)...done.

It makes me wonder if I have to find a specific file for this?

Update

Note: I have already tried the following command:

nm --debug-sym <your_executable> | grep debug

with no success; it refuses to display anything.

Here is my Makefile:

BIN = bin/
OBJ = obj/
TARGET = opengl_03
DEPS = main.o  displayinit.o initializer.o algorithms.o matrix3f.o window.o vertex3.o
CC = g++
CFLAGS = -g -ggdb 
LIBS = -lglut -lGLEW -lGL 
INCLUDEPATH = -L/usr/include/ -L/usr/lib/ -L/usr/lib/x86_64-linux-gnu/

$(TARGET) : $(DEPS)
    $(CC) $(CFLAGS) -o $(BIN)$(TARGET) $(DEPS) $(LIBS) $(INCLUDEPATH) 

displayinit.o : displayinit.cpp displayinit.h
    $(CC) $(CFLAGS) -c displayinit.cpp  $(LIBS) $(INCLUDEPATH) #&& mv displayinit.o $(OBJ)displayinit.o
initializer.o : initializer.cpp initializer.h
    $(CC) $(CFLAGS) -c initializer.cpp $(OBJ) $(LIBS) $(INCLUDEPATH) 
algorithms.o : algorithms.cpp algorithms.h
    $(CC) $(CFLAGS) -c algorithms.cpp $(OBJ) $(LIBS) $(INCLUDEPATH) 
matrix3f.o : matrix3f.cpp matrix3f.h
    $(CC) $(CFLAGS)  -c matrix3f.cpp $(OBJ) $(LIBS) $(INCLUDEPATH) 
vertex3.o : vertex3.cpp vertex3.h
    $(CC) $(CFLAGS)  -c vertex3.cpp $(OBJ) $(LIBS) $(INCLUDEPATH) 
window.o : window.cpp window.h
    $(CC) $(CFLAGS) $(LIBS) $(INCLUDEPATH) -c window.cpp $(OBJ)
main.o : main.cpp
    $(CC) $(CFLAGS) $(LIBS) $(INCLUDEPATH) -c main.cpp $(OBJ)
like image 471
zeboidlund Avatar asked Oct 31 '25 22:10

zeboidlund


2 Answers

You need to include debugging symbols when you compile. For example if you are using gcc add the flag -ggdb.

like image 52
DrYap Avatar answered Nov 02 '25 13:11

DrYap


You need to compile with debug symbols included gcc -g option and make sure you don't strip your executable. More details in this link.

-------------------------------------------------Edit-------------------------------------------

Your Makefile does not look good, why don't you use boilerplate Makefiles. You can find it here, works well for me.

like image 30
Kamath Avatar answered Nov 02 '25 13:11

Kamath



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!