summaryrefslogtreecommitdiffhomepage
path: root/app/tools/libwg-go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-05-21 14:13:55 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-05-21 14:13:55 +0200
commit4863bd647afe100d35f61aa08db9ed25f0d5bac1 (patch)
treefd27b6eddd2ca95be99c101f805fab81719967d1 /app/tools/libwg-go
parentcb62dc8fa2ccf4b1bb435f9ced97d8817adccd2a (diff)
Add stacktrace via SIGUSR2
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'app/tools/libwg-go')
-rw-r--r--app/tools/libwg-go/api-android.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/app/tools/libwg-go/api-android.go b/app/tools/libwg-go/api-android.go
index 5ea57a9d..a609ec44 100644
--- a/app/tools/libwg-go/api-android.go
+++ b/app/tools/libwg-go/api-android.go
@@ -17,7 +17,10 @@ import (
"log"
"math"
"os"
+ "os/signal"
+ "runtime"
"strings"
+ "unsafe"
)
type AndroidLogger struct {
@@ -34,6 +37,19 @@ var tunnelHandles map[int32]*Device
func init() {
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
@@ -53,7 +69,6 @@ func wgTurnOn(ifnameRef string, tun_fd int32, settings string) int32 {
events: make(chan TUNEvent, 5),
errors: make(chan error, 5),
nopi: true,
- statusListenersShutdown: make(chan struct{}),
}
var err error