debugbreak icon indicating copy to clipboard operation
debugbreak copied to clipboard

Fix build issue on macOS (aarch64, gcc) and use debugtrap wherever possible

Open MrAnno opened this issue 3 years ago • 6 comments

This PR makes debugbreak prefer __builtin_debugtrap() wherever it's available (clang).

The code snippet I've used is @jwakely's work, I've added a signoff to my commit message to mark the original author.

The patch fixes a build issue too on macOS (Apple silicon) when a real GCC compiler is used:

warning: implicit declaration of function '__builtin_debugtrap';

Depends on #22 Fixes #24


I'm testing this change on the following architectures (with clang + gcc):

  • [x] x86-64
    • gcc/clang: works
  • [x] ARM mode, 32-bit (Raspberry Pi 1 armv6l)
    • gcc/clang: works (stepping in GDB does NOT work)
  • [x] Thumb mode, 32-bit (Cirrus CI)
    • gcc/clang: works (stepping in GDB does NOT work)
  • [x] AArch64, ARMv8 (Raspberry Pi 4)
    • gcc/clang: works (stepping in GDB does NOT work)
  • [x] Apple silicon (macOS M1 machine):
    • gcc: works (stepping in LLDB does NOT work)
    • clang: works

Unfortunately, I won't be able to test the change on riscv and powerpc.

MrAnno avatar Feb 01 '22 23:02 MrAnno

I'll see if I can test it on powerpc64.

jwakely avatar Feb 01 '22 23:02 jwakely

I've completed my tests on the platforms that were available to me. It seems nothing got worse with this change, just slightly better, for example, on macOS.

@scottt What do you think? Is this something you would consider integrating into the master branch?

MrAnno avatar Feb 06 '22 19:02 MrAnno

on POWER8 running CentOS 7.9:

$ test/fib ; test/trap ; test/break ; test/break-c++
Trace/breakpoint trap (core dumped)
Trace/breakpoint trap (core dumped)
Trace/breakpoint trap (core dumped)
Trace/breakpoint trap (core dumped)

jwakely avatar Feb 06 '22 20:02 jwakely

@jwakely Thank you.

MrAnno avatar Feb 07 '22 12:02 MrAnno

@scottt Could you have a look at this?

MrAnno avatar Mar 24 '22 18:03 MrAnno

We had to start using a fork of debugbreak due to this build issue on macOS.

MrAnno avatar Jul 03 '22 16:07 MrAnno

@scottt Do you have any comments on this?

MrAnno avatar Oct 22 '22 18:10 MrAnno