-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #710 from visualfc/sigsegv
[wip] runtime: signal SIGSEGV
- Loading branch information
Showing
13 changed files
with
246 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package signal | ||
|
||
import ( | ||
"unsafe" | ||
|
||
"github.com/goplus/llgo/c" | ||
) | ||
import "C" | ||
|
||
const ( | ||
LLGoPackage = "link" | ||
) | ||
|
||
//llgo:type C | ||
type SignalHandler func(c.Int) | ||
|
||
//llgo:type C | ||
type sigactiont struct { | ||
handler SignalHandler | ||
tramp unsafe.Pointer | ||
mask c.Int | ||
flags c.Int | ||
} | ||
|
||
//go:linkname sigaction C.sigaction | ||
func sigaction(sig c.Int, act, old *sigactiont) c.Int | ||
|
||
func Signal(sig c.Int, hanlder SignalHandler) c.Int { | ||
var act sigactiont | ||
act.handler = hanlder | ||
return sigaction(sig, &act, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package main | ||
|
||
type T struct { | ||
s int | ||
} | ||
|
||
func f() *T { | ||
return nil | ||
} | ||
|
||
func init() { | ||
println("init") | ||
defer func() { | ||
r := recover() | ||
if e, ok := r.(error); ok { | ||
println("recover", e.Error()) | ||
} | ||
}() | ||
println(f().s) | ||
} | ||
|
||
func main() { | ||
println("main") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.