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 = 8 // "jal someFunc" is 4 bytes, plus a MIPS delay slot
const linux_MAP_ANONYMOUS = 0x800
const (
linux_MAP_ANONYMOUS = 0x800
linux_SIGBUS = 10
linux_SIGILL = 4
linux_SIGSEGV = 11
)
// It appears that MIPS has a maximum alignment of 8 bytes.
func align(ptr uintptr) uintptr {