1

I need some help finding and using a good debugger for asm code assembled with yasm on 64-bit Linux. The gdb debugger keeps complaining that no symbol tables are loaded. Someone on stackoverflow suggested assembling with the -dstabs switch, but that makes no difference for me. Neither does ddd make a difference.

gdb wouldn't be so bad if I could find a way to get rid of the "no symbol tables loaded" problem. I also need to be able to view the contents of registers and other declarations.

I assemble my asm files using yasm -f elf -m amd64 file.asm and I link with ld file.o -o file. Creating a .lst file with yasm using the -l switch doesn't seem to work either.

All the advice I've found regarding this matter seem to be related to using gcc as a linker and not ld. I need to be able to link with ld.

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
InvalidBrainException
  • 2,312
  • 8
  • 32
  • 41
  • 1
    Have you tried using the `-g` option when assembling? – mtvec Apr 29 '12 at 12:07
  • 1
    @Job: Thanks! I think it worked. I'm getting some new information from gdb. What worked for me is the command: `yasm -f elf -m amd64 -g stabs file.asm`. The man page for gdb_dbgfmts suggested that stabs is a suitable debugging format for UNIX operating systems, but I don't really understand debugging formats. Is there a better option? – InvalidBrainException Apr 29 '12 at 12:17
  • I suggest using dwarf, see my answer. – mtvec Apr 29 '12 at 12:57

2 Answers2

5

You should use the -g option to yasm. I'd suggest using the dwarf2 format as that seems to be the standard nowadays.

yasm -f elf -m amd64 -g dwarf2 file.asm
mtvec
  • 17,846
  • 5
  • 52
  • 83
-1

I'm currently taking systems programming, and we use ddd for debugging, using the -g dwarf2 flag. It has worked well so far.

Arod529
  • 3
  • 2
  • ddd is just a GUI frontend to gdb. – gps Nov 02 '15 at 23:25
  • I know... He said he wanted to "view the contents of registers and other declarations". Maybe you prefer the glorious clutter of having to print out variable and register values to the command line, but I find having a nice little separate display for all that information is quite helpful too. Gdb is a good debugger. He asked for suggestions and I gave one. Do feel free to give a better suggestion, I'm always open to improvements. – Arod529 Nov 03 '15 at 03:40