I have build code using yasm and link to my C ++ program, but I cannot set breakpoints in gdb for characters from assembly language file.
The command lines are probably not very covered, but here we go:
"g++" -ftemplate-depth-128 -O0 -fno-inline -Wall -g -fPIC -std=c++11 -I"$HOME/usr/include" -c -o "bin/gcc-4.7/debug/main.o" "main.cpp" yasm -g dwarf2 -f elf64 -o bin/gcc-4.7/debug/mandel.o mandel.yasm "g++" -L"$HOME/usr/lib" -Wl,-R -Wl,"$HOME/usr/lib" -Wl,-rpath-link -Wl,"$HOME/usr/lib" -o "bin/gcc-4.7/debug/mandel" -Wl,--start-group "bin/gcc-4.7/debug/main.o" "bin/gcc-4.7/debug/mandel.o" -Wl,-Bstatic -Wl,-Bdynamic -lboost_system -lboost_thread -Wl,--end-group -g
Everything is built without incident, and the program starts. But when I try to load it into gdb to debug it, I cannot put breakpoints on any functions in the yasm file. For example, I have a function called MandelRect. Here gdb shows me where he called from somewhere basically:
(gdb) disassemble 0x404ada,0x404af0 Dump of assembler code from 0x404ada to 0x404af0: 0x0000000000404ada <main()+474>: mov %rax,%rdi 0x0000000000404add <main()+477>: callq 0x409980 <MandelRect> 0x0000000000404ae2 <main()+482>: movq $0x0,-0x18(%rbp) 0x0000000000404aea <main()+490>: jmp 0x404b1c <main()+540> 0x0000000000404aec <main()+492>: mov -0x18(%rbp),%rdx End of assembler dump.
Here gdb shows me that its address is:
(gdb) info address MandelRect Symbol "MandelRect" is at 0x409980 in a file compiled without debugging.
Here gdb cannot set a breakpoint on it:
(gdb) break MandelRect Function "MandelRect" not defined. Make breakpoint pending on future shared library load? (y or [n]) n
And if I put a breakpoint on the right address when the execution reaches this function, I will not be able to execute its instructions. It just works from tag to tag, as far as I can (fed up) say.
Obviously, maybe? - this is due to the fact that gdb insisted that the file was compiled without debugging. But in the corresponding .o file and in binary format, the characters appear:
~/tests/mandel/bin/gcc-4.7/debug% nm mandel.o | grep MandelRectAsm 0000000000000000 R MandelRectAsm ~/tests/mandel/bin/gcc-4.7/debug% nm mandel | grep MandelRectAsm 000000000040a340 R MandelRectAsm ~/tests/mandel/bin/gcc-4.7/debug% objdump -t mandel.o | grep -i MandelRectAsm 0000000000000000 g .txt 0000000000000000 MandelRectAsm ~/tests/mandel/bin/gcc-4.7/debug% objdump -t mandel | grep -i MandelRectAsm 000000000040a340 g .txt 0000000000000000 MandelRectAsm
So how can I fix this? Am I misunderstanding something or is yasm -g broken? Has anyone ever received debugging information from clarity for working with gdb?
( Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux system Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux .)