unix: print a message when a fatal signal happens

Print a message for SIGBUS, SIGSEGV, and SIGILL when they happen.
These signals are always fatal, but it's very useful to know which of
them happened.

Also, it prints the location in the binary which can then be parsed by
`tinygo run` (see https://github.com/tinygo-org/tinygo/pull/4383).

While this does add some extra binary size, it's for Linux and MacOS
(systems that typically have plenty of RAM/storage) and could be very
useful when debugging some low-level crash such as a runtime bug.
This commit is contained in:
Ayke van Laethem
2024-08-12 18:45:22 +02:00
committed by Ron Evans
parent 815784bd96
commit 194396d715
12 changed files with 162 additions and 7 deletions
+6
View File
@@ -23,6 +23,12 @@ const (
clock_MONOTONIC_RAW = 4
)
const (
sig_SIGBUS = linux_SIGBUS
sig_SIGILL = linux_SIGILL
sig_SIGSEGV = linux_SIGSEGV
)
// For the definition of the various header structs, see:
// https://refspecs.linuxfoundation.org/elf/elf.pdf
// Also useful: