Is it possible to run GDB with a program assembled with as and linked with ld? With gcc adding the flag -g allows for debugging but I get the error No symbol table is loaded. Use the "file" command when I try to add breakpoints to a loaded program.
Thanks!
EDIT Maybe I should make it clear that I’m learning and programming in assembly. All I really want is a stack trace but being able to use GDB would be great.
Resolution Running as -g does the trick.
Thank you to all that answered!!
It is possible. However, you need symbols in order to add symbolic breakpoints, and symbols are provided by debugging info; make sure your assembler and linker are providing those. EDIT With GNU
as, useas -g. Or just usegcc -g: if you give it a.sfile, it will invoke the assembler and linker as appropriate.GDB understands debugging info in several formats: stabs, COFF, PE, DWARF, SOM. (Some of these are executable formats with debugging sections, others are debug info formats that can be embedded into executables, such as ELF.)
gcc -gusually chooses whatever the platform’s default is,gcc -ggdbusually chooses the most expressive (depending on your versions, possibly DWARF-3).If you have debugging info embedded into or linked to by the executable,
gdbwill try to load it automatically. If you have it elsewhere, you may need to usefileto tellgdbwhere to find it.You can still debug without symbolic information. For example, you can issue
break *0x89abcdefto insert a breakpoint at that address, if there’s any code there.