0

Currently using kdbg and am finding that although I can debug the code and see the registers changing as expected, I cannot see the current line being highlighted in the source code window:

enter image description here

From examples on the web I'd expect to see a highlighted line in the source window.

I'm on Ubuntu 16.04 and using kdbg 2.5.4. Makefile contents is:

helloworld: helloworld.o
    ld -m elf_i386 -o helloworld helloworld.o

helloworld.o: helloworld.asm
    nasm -f elf32 -g -F stabs helloworld.asm -o helloworld.o

Update 1

It may or may not be related, but just for completeness, in the Xterm window 'KDbg: Program Output' window I can see the following:

warning: GDB: Failed to set controlling terminal: Operation not permitted

Update 2

I updated the linker command as suggested in comments, but still get the same issue:

helloworld: helloworld.o
    ld -g -m elf_i386 -o helloworld helloworld.o
imrichardcole
  • 4,633
  • 3
  • 23
  • 45
  • Most likely this is because you build without debugging information (without `-g`). – ks1322 Sep 30 '17 at 10:01
  • updated question to include how I've assembled and linked. – imrichardcole Sep 30 '17 at 10:31
  • Looks like a bug in kgdb. You can try `layout asm` in standalone gdb. See this answer: https://stackoverflow.com/a/2015523/72178. – ks1322 Sep 30 '17 at 10:59
  • Does `kgdb` have a `layout asm` / disassembly mode? It looks like a nice UI, but when debugging C the step-instruction button seems really weird if there's no asm display! – Peter Cordes Sep 30 '17 at 13:07
  • Update, not really, all I could find was setting the memory pane to disassemble `$pc`. https://stackoverflow.com/questions/7139786/debug-assembly-code-using-kdbg – Peter Cordes Sep 30 '17 at 14:40
  • @imrichardcole Try linking with `-g`. If that does not work, please make a transcript with `kdbg -t /tmp/gdb-transcript helloworld` and send it to the maintainer. Include `helloworld.asm` if possible. – j6t Oct 04 '17 at 18:23
  • 1
    Try with `nasm -g -Fdwarf` to generate the modern format of debug symbols. `ld` can only include the debug info that NASM generates; it doesn't look at the original source. – Peter Cordes Oct 05 '17 at 21:45

1 Answers1

-1

KDbg will highlight the current line when you start it from the command line and from the same directory where the assembly source code is located:

kdbg helloworld

Unfortunately, gdb does not report absolute paths when it is not started from the directory where the assembly source code is located. (It just says helloworld.asm: No such file or directory.) With the above work-around, gdb finds the file and can report sufficient information to KDbg so that it can display the source code.

j6t
  • 9,150
  • 1
  • 15
  • 35