Author Topic: debugging on Mac OS?  (Read 16167 times)

Offline mrb

  • Jr. Member
  • *
  • Posts: 4
debugging on Mac OS?
« 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
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.

Offline mrb

  • Jr. Member
  • *
  • Posts: 4
Re: debugging on Mac OS?
« Reply #1 on: June 12, 2017, 08:24:02 PM »
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

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: debugging on Mac OS?
« Reply #2 on: June 13, 2017, 05:02:37 AM »
I find gdb very "unfriendly", and so use some other debugger when possible. However:

Code: [Select]
; 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


Offline mrb

  • Jr. Member
  • *
  • Posts: 4
Re: debugging on Mac OS?
« Reply #3 on: June 13, 2017, 01:47:49 PM »
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?

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: debugging on Mac OS?
« Reply #4 on: June 13, 2017, 04:22:44 PM »
Nope - haven't got a 64-bit system. Sorry.

Best,
Frank


Offline RogerTunnicliffe

  • Jr. Member
  • *
  • Posts: 4
Re: debugging on Mac OS?
« Reply #5 on: July 20, 2017, 04:04:54 AM »
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.

Offline frankc

  • New Member
  • Posts: 1
Re: debugging on Mac OS?
« Reply #6 on: July 20, 2017, 10:49:21 AM »
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.

Offline mrb

  • Jr. Member
  • *
  • Posts: 4
Re: debugging on Mac OS?
« Reply #7 on: October 13, 2017, 11:15:58 PM »
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.