# prefer C\+\+ compiler builtins for BREAKPOINT · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/25b1ae0a5faf5e5632d9e9103840da6d9c5e80cb)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 25b1ae0a5faf5e5632d9e9103840da6d9c5e80cb

Requested commit: 25b1ae0a5faf5e5632d9e9103840da6d9c5e80cb

Commit: 25b1ae0a5faf5e5632d9e9103840da6d9c5e80cb

Tree: b763b38c6de4b97b6775b8df20ce76285d36425e

Author: Michael Dusan

Committer: Michael Dusan

## Message

```
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)`

```

## Parents

- [c96131f30caaf6d7cd1d202891a28ee0df8b577e](https://git.cafe/gitcafe/zig/commit/c96131f30caaf6d7cd1d202891a28ee0df8b577e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/25b1ae0a5faf5e5632d9e9103840da6d9c5e80cb?format=markdown)
