Fix build issue on macOS (aarch64, gcc) and use debugtrap wherever possible
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.
I'll see if I can test it on powerpc64.
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?
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 Thank you.
@scottt Could you have a look at this?
We had to start using a fork of debugbreak due to this build issue on macOS.
@scottt Do you have any comments on this?