Illegal instruction handler
This commit is contained in:
parent
9a35bcd31f
commit
83c1260a3a
3 changed files with 50 additions and 0 deletions
1
example/back
Submodule
1
example/back
Submodule
|
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit a21ef046ad624ff1bdc6e8de77c38e8c32eec86b
|
||||||
38
example/main_linux.odin
Normal file
38
example/main_linux.odin
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
#+build linux, darwin, netbsd, openbsd, freebsd
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "back"
|
||||||
|
import "base:runtime"
|
||||||
|
|
||||||
|
import "core:fmt"
|
||||||
|
import "core:mem"
|
||||||
|
import "core:sys/posix"
|
||||||
|
|
||||||
|
@(private="package")
|
||||||
|
_register_illegal_instruction_handler :: proc() {
|
||||||
|
posix.signal(.SIGILL, proc "c" (code: posix.Signal) {
|
||||||
|
context = runtime.default_context()
|
||||||
|
|
||||||
|
space: [16*mem.Kilobyte]byte
|
||||||
|
arena: mem.Arena
|
||||||
|
mem.arena_init(&arena, space[:])
|
||||||
|
allocator := mem.arena_allocator(&arena)
|
||||||
|
|
||||||
|
context.allocator = allocator
|
||||||
|
context.temp_allocator = allocator
|
||||||
|
|
||||||
|
backtrace: {
|
||||||
|
lines, err := back.lines(back.trace(), allocator, allocator)
|
||||||
|
if err != nil {
|
||||||
|
fmt.eprintf("Exception (Code: %i)\nCould not get backtrace: %v\n", code, err)
|
||||||
|
break backtrace
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.eprintf("Exception (Code: %i)\n[back trace]\n", code)
|
||||||
|
back.print(lines, temp_allocator=allocator)
|
||||||
|
}
|
||||||
|
|
||||||
|
runtime.exit(int(code))
|
||||||
|
})
|
||||||
|
}
|
||||||
11
example/main_other.odin
Normal file
11
example/main_other.odin
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#+vet explicit-allocators
|
||||||
|
#+build !linux
|
||||||
|
#+build !darwin
|
||||||
|
#+build !netbsd
|
||||||
|
#+build !openbsd
|
||||||
|
#+build !freebsd
|
||||||
|
#+build !windows
|
||||||
|
package main
|
||||||
|
|
||||||
|
@(private="package")
|
||||||
|
_register_illegal_instruction_handler :: proc() {}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue