Add stacktrace via SIGUSR2
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
parent
cb62dc8fa2
commit
4863bd647a
@ -17,7 +17,10 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AndroidLogger struct {
|
type AndroidLogger struct {
|
||||||
@ -34,6 +37,19 @@ var tunnelHandles map[int32]*Device
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
tunnelHandles = make(map[int32]*Device)
|
tunnelHandles = make(map[int32]*Device)
|
||||||
|
signals := make(chan os.Signal)
|
||||||
|
signal.Notify(signals, unix.SIGUSR2)
|
||||||
|
go func() {
|
||||||
|
buf := make([]byte, os.Getpagesize())
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-signals:
|
||||||
|
n := runtime.Stack(buf, true)
|
||||||
|
buf[n] = 0
|
||||||
|
C.__android_log_write(C.ANDROID_LOG_ERROR, C.CString("WireGuard/GoBackend/Stacktrace"), (*_Ctype_char)(unsafe.Pointer(&buf[0])))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
//export wgTurnOn
|
//export wgTurnOn
|
||||||
@ -53,7 +69,6 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 {
|
|||||||
events: make(chan TUNEvent, 5),
|
events: make(chan TUNEvent, 5),
|
||||||
errors: make(chan error, 5),
|
errors: make(chan error, 5),
|
||||||
nopi: true,
|
nopi: true,
|
||||||
statusListenersShutdown: make(chan struct{}),
|
|
||||||
}
|
}
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user