Author Topic: Debugging programs made with nasm in gdb/ddd.  (Read 6820 times)

Offline DebugBSD

  • New Member
  • Posts: 1
Debugging programs made with nasm in gdb/ddd.
« on: December 27, 2015, 10:19:08 AM »
Hi, good morning,

I'm new in the forums, so, my name is Guillermo. I'm sorry if this is not the correct place to post my problem. If this is not the correct place, please, just tell me where I have to post and I'll post there. I'm learning to write assembly code with several books such as Duntemann and Irvine books too so I'm sorry if I ask quite basic questions. Anyway, first of all, I usually spend a lot of time researching in google about my problem before I post something here.

I've installed an OpenBSD Operating System in a INTEL I7 of 64bit and I'm trying to debug some applications made by myself with gdb or ddd and built with nasm (Version 2.11.08). (More information next).

My problem is when I launch gdb or ddd I can't debug the software. With DDD for example, I can't put breakpoints or I can't go step by step into the code and I don't know why. With GDB the problem is similar, in this case at least I can go step by step but I can't see the source code neither the instructions. Just I can see the addresses of the instructions and I don't know why  (Next is the output of a session with GDB).

Of course, the program was built with debugging support. I tried dwarf and stabs but neither works to me.

Someone can help me? I need debug support because I'm learning to program software and if I don't have a debugger I won't learn anything but a lot of theory.

Here I put the contents of the Makefile:
all:
   nasm -l main.lst -f elf64 -g -F stabs main.asm
   gcc -gstabs -o main main.o

Here, the contents of the assembly program:
default rel

section .data

section .bss

section .text
   global main

main:
    nop
   
    pop rax
    pop rbx
    pop rcx

    mov eax,1 ;
    mov edi,0 ;
    syscall

    nop


Next I put an example of my problem with gdb:

(gdb) start
Breakpoint 2 at 0x17c914700b10
Starting program: /home/debugbsd/Projects/Assembly_Language/GettingArguments/main
Breakpoint 2 at 0x88508100b10
0x0000088508100b10 in main () from /home/debugbsd/Projects/Assembly_Language/GettingArguments/main
(gdb) disassemble
Dump of assembler code for function main:
0x0000088508100b10 <main+0>:   nop   
0x0000088508100b11 <main+1>:   pop    %rax
0x0000088508100b12 <main+2>:   pop    %rbx
0x0000088508100b13 <main+3>:   pop    %rcx
0x0000088508100b14 <main+4>:   mov    $0x1,%eax
0x0000088508100b19 <main+9>:   mov    $0x0,%edi
0x0000088508100b1e <main+14>:   syscall
0x0000088508100b20 <main+16>:   nop   
0x0000088508100b21 <main+17>:   nop   
0x0000088508100b22 <main+18>:   nop   
0x0000088508100b23 <main+19>:   nop   
End of assembler dump.
(gdb) stepi
0x0000088508100b11 in main () from /home/debugbsd/Projects/Assembly_Language/GettingArguments/main
(gdb)
0x0000088508100b12 in main () from /home/debugbsd/Projects/Assembly_Language/GettingArguments/main
(gdb)
0x0000088508100b13 in main () from /home/debugbsd/Projects/Assembly_Language/GettingArguments/main
(gdb)
0x0000088508100b14 in main () from /home/debugbsd/Projects/Assembly_Language/GettingArguments/main
(gdb)
0x0000088508100b19 in main () from /home/debugbsd/Projects/Assembly_Language/GettingArguments/main
(gdb)
0x0000088508100b1e in main () from /home/debugbsd/Projects/Assembly_Language/GettingArguments/main
(gdb)

Program exited normally.
(gdb)

Thanks in advance,
Guille