Reputation: 53
I'm trying to debug using gdb running it through emacs, with no success. I keep on getting the well known "no debugging symbol found". I assume the problem is in the way I compile using the -g flag, but I can't tell where is my mistake. Here is the makefile:
all: tree
tree: main.o OctTree.o my_vec.o runge_kutta.o initialize.o global.o
g++ -g -o tree main.o OctTree.o my_vec.o runge_kutta.o initialize.o global.o -lm
main.o: main.cpp OctTree.h my_vec.h global.h
g++ -g -o3 main.cpp -o main.o
my_vec.o: my_vec.cpp my_vec.h
g++ -g -o3 my_vec.cpp -o my_vec.o
OctTree.o: OctTree.cpp OctTree.h my_vec.h global.h
g++ -g -o3 OctTree.cpp -o OctTree.o
runge_kutta.o: runge_kutta.cpp OctTree.h my_vec.h global.h
g++ -g -o3 runge_kutta.cpp -o runge_kutta.o
initialize.o: initialize.cpp my_vec.h OctTree.h global.h
g++ -g -o3 initialize.cpp -o initialize.o
global.o : global.cpp global.h
g++ -g -o3 global.cpp -o global.o
clean:
rm main.o my_vec.o OctTree.o runge_kutta.o initialize.o global.o-f
when I try running gdb I get this message: Reading symbols from /home/alexander/physics with computer/final/tree...(no debugging symbols found)...done.
thank you very much!
Upvotes: 0
Views: 2921
Reputation: 213957
when I try running gdb I get this message: Reading symbols from /home/alexander/physics with computer/final/tree...(no debugging symbols found)...done.
It seems pretty clear that your build actually does contain debug info. Therefore it must be that you are debugging something other than what you've built (some other copy of tree
).
You should
Confirm that the binary has debug info. For example:
cd /home/alexander/physics/computer/final
readelf -wl tree | grep 'runge_kutta\.cpp'
should produce some output. And
readelf -w tree
should produce a lot of output.
Confirm that you can debug this binary outside of emacs:
gdb ./tree
This should not produce no debugging symbols found
Now debug this binary in emacs:
M-x gdb
complete the command to be gdb /home/alexander/physics/computer/final/tree
If step 2 worked, then step 3 will not produce no debugging symbols found
either.
Upvotes: 1
Reputation: 13196
You would be better off taking advantage of make's features to make your makefile easier to change. For example:
# all cpp files (add files here if you add more to your project)
SRC_FILES = main.cpp my_vec.cpp OctTree.cpp runge_kutta.cpp initialize.cpp global.cpp
OBJ_FILES = $(addsuffix .o,$(basename $(SRC_FILES))) # autogenerated
# flags, options, and other crap
OUTPUT = tree
CXX_FLAGS = -c -g # -O3 # disable optimization for now
CXX_FLAGS_LINK = -g
LIBS = -lm
# first target
all: tree
# tree target: requires all object files, links them into output executable
tree: $(OBJ_FILES)
g++ $(CXX_FLAGS_LINK) -o $(OUTPUT) $(OBJFILES) $(LIBS)
# generic target for any cpp file
%.o: %.cpp
g++ $(CXX_FLAGS) -o %.o %.cpp
# clean target
clean:
rm main.o my_vec.o OctTree.o runge_kutta.o initialize.o global.o -f
# specific dependencies for each file
# you can generate these with g++ -MM <filename.cpp>
main.o: main.cpp OctTree.h my_vec.h global.h
my_vec.o: my_vec.cpp my_vec.h
OctTree.o: OctTree.cpp OctTree.h my_vec.h global.h
runge_kutta.o: runge_kutta.cpp OctTree.h my_vec.h global.h
initialize.o: initialize.cpp my_vec.h OctTree.h global.h
global.o : global.cpp global.h
I suspect the issue you're having relates to the lengths the compiler is going to to efficientize your code at O3. Try again with no optimization and see if that works for you.
I have not tested this makefile at all.
OK, you've tried disabling optimization. you've tried a make clean
and recompile with optimization off? How are you launching the debugger? Leave optimization off, it doesn't get along well with debugging, even if GDB has a different gripe right now. Did you forget to rebuild your sources?
Upvotes: 1