authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2020-01-12 16:10:17-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2020-01-12 16:41:11-05:00
log25b1ae0a5faf5e5632d9e9103840da6d9c5e80cb
treeb763b38c6de4b97b6775b8df20ce76285d36425e
parentc96131f30caaf6d7cd1d202891a28ee0df8b577e
signature Commit is signed but in an unrecognized format.

prefer C++ compiler builtins for BREAKPOINT

Fix breakpoints on macOS to trap EXC_BREAKPOINT with correct source location when using lldb. Old behavior with `raise(SIGTRAP)` traps SIGTRAP and incorrect source location. Fix breakpoints on archlinux to trap SIGILL with correct source location when using gdb. Old behavior with `raise(SIGTRAP)` traps SIGTRAP and (sometimes) incorrect source location with very shallow (break in main) stack. when building stage1: - w/ clang, use `__builtin_debugtrap()` - w/ gcc, use `__builtin_trap()` - else use `raise(SIGTRAP)`

1 files changed, 5 insertions(+), 2 deletions(-)

src/util.hpp+5-2
......@@ -30,8 +30,6 @@
3030
3131#else
3232
33#include <signal.h>
34
3533#define ATTRIBUTE_COLD __attribute__((cold))
3634#define ATTRIBUTE_PRINTF(a, b) __attribute__((format(printf, a, b)))
3735#define ATTRIBUTE_RETURNS_NOALIAS __attribute__((__malloc__))
......@@ -40,7 +38,12 @@
4038
4139#if defined(__MINGW32__) || defined(__MINGW64__)
4240#define BREAKPOINT __debugbreak()
41#elif defined(__clang__)
42#define BREAKPOINT __builtin_debugtrap()
43#elif defined(__GNUC__)
44#define BREAKPOINT __builtin_trap()
4345#else
46#include <signal.h>
4447#define BREAKPOINT raise(SIGTRAP)
4548#endif
4649