NASM - The Netwide Assembler
NASM Forum => Using NASM => Topic started by: mrb on June 12, 2017, 11:34:54 AM
-
Supposedly NASM now supports debugging on Mac OS, but I haven't been able to get it to work. See my StackOverflow question: https://stackoverflow.com/questions/44493487/is-it-possible-to-debug-x64-assembly-on-mac-os?noredirect=1#comment75989484_44493487 (https://stackoverflow.com/questions/44493487/is-it-possible-to-debug-x64-assembly-on-mac-os?noredirect=1#comment75989484_44493487)
for more details.
If someone could please show me the exact commands necessary to actually debug a program assembled by NASM, I'd appreciate it.
-
So I tried this on Linux too.
Using GAS and gdb works fine there.
But it turns out NASM and gdb do not. The problem is this [1] bug.
Although NASM nominally is capable of outputting several debug formats, it's not clear to me whether it's possible to use it with any debugger on any platform. Is it? If so, please show me how.
[1] https://bugzilla.nasm.us/show_bug.cgi?id=3392234
-
I find gdb very "unfriendly", and so use some other debugger when possible. However:
; nasm -f elf32 -F dwarf hw.asm
; ld -o hw hw.o
; gdb hw
; break bp1
; run
; step
; step
; ...
global _start
section .data
msg db 'Hello, world',0Ah
msg_len equ $-msg
section .text
_start:
nop ; parking place for gdb
bp1:
mov eax,4
mov ebx,1
mov ecx, msg
mov edx,msg_len
int 80h
bp2:
mov eax,1
int 80h
Works for me... I can't help ya with Mac.
Best,
Frank
-
Thanks. Yes, that works for me too. It seems that bug I linked to only affects 64 bit code.
So, let me rephrase. Are you able to debug *64 bit code* using NASM?
-
Nope - haven't got a 64-bit system. Sorry.
Best,
Frank
-
I've been debugging 64bit nasm code for a couple of years now.
I use GDB on Linux with DDD and INSIGHT as graphical front ends. DDD is more stable but INSIGHT provides some pretty nice features.
I am currently porting to windows and have been using X64DBG.
I haven't found any problems with debugging the code.
-
I found this http://lldb.llvm.org/symbols.html which may help. I haven't had time to do the setup but it may address the issue.
-
RogerTunnicliffe,
Thanks for the information. What about the bug I linked to [1]? If you follow the commands in that bug report, does your gdb behave as described there, or does it work correctly?
[1] https://bugzilla.nasm.us/show_bug.cgi?id=3392234
frankc,
Thanks for the link. It describes the debugging process on Macs, but I don't think it's going to help NASM generate debugging information.