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 -1
View File
@@ -9,7 +9,12 @@ const deferExtraRegs = 0
const callInstSize = 5 // "call someFunction" is 5 bytes
const linux_MAP_ANONYMOUS = 0x20
const (
linux_MAP_ANONYMOUS = 0x20
linux_SIGBUS = 7
linux_SIGILL = 4
linux_SIGSEGV = 11
)
// Align a pointer.
// Note that some amd64 instructions (like movaps) expect 16-byte aligned