]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix build on non-x86 machines
authorRuss Cox <rsc@golang.org>
Tue, 14 Jul 2015 04:41:18 +0000 (00:41 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 14 Jul 2015 04:42:12 +0000 (04:42 +0000)
Fixes #11656 (again).

Change-Id: I170ff10bfbdb0f34e57c11de42b6ee5291837813
Reviewed-on: https://go-review.googlesource.com/12142
Reviewed-by: Russ Cox <rsc@golang.org>
src/runtime/signal_arm.go
src/runtime/signal_arm64.go
src/runtime/signal_ppc64x.go

index 38d7181b2ab7ffafc8226ef1c85a09551069c14b..f1f3c60699b4355c6e19aad0e3a48c77b8cacedc 100644 (file)
@@ -67,11 +67,21 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
                c.set_sp(sp)
                *(*uint32)(unsafe.Pointer(uintptr(sp))) = c.lr()
 
+               pc := uintptr(gp.sigpc)
+
+               // If we don't recognize the PC as code
+               // but we do recognize the link register as code,
+               // then assume this was a call to non-code and treat like
+               // pc == 0, to make unwinding show the context.
+               if pc != 0 && findfunc(pc) == nil && findfunc(uintptr(c.lr())) != nil {
+                       pc = 0
+               }
+
                // Don't bother saving PC if it's zero, which is
                // probably a call to a nil func: the old link register
                // is more useful in the stack trace.
-               if gp.sigpc != 0 {
-                       c.set_lr(uint32(gp.sigpc))
+               if pc != 0 {
+                       c.set_lr(uint32(pc))
                }
 
                // In case we are panicking from external C code
index dde3c7c43faae8082a487660cdc2452757ba3b73..07ab638c26184c00c289aad94fdb5fde974da7d7 100644 (file)
@@ -80,11 +80,21 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
                c.set_sp(sp)
                *(*uint64)(unsafe.Pointer(uintptr(sp))) = c.lr()
 
+               pc := uintptr(gp.sigpc)
+
+               // If we don't recognize the PC as code
+               // but we do recognize the link register as code,
+               // then assume this was a call to non-code and treat like
+               // pc == 0, to make unwinding show the context.
+               if pc != 0 && findfunc(pc) == nil && findfunc(uintptr(c.lr())) != nil {
+                       pc = 0
+               }
+
                // Don't bother saving PC if it's zero, which is
                // probably a call to a nil func: the old link register
                // is more useful in the stack trace.
-               if gp.sigpc != 0 {
-                       c.set_lr(uint64(gp.sigpc))
+               if pc != 0 {
+                       c.set_lr(uint64(pc))
                }
 
                // In case we are panicking from external C code
index 04d8cfcec1909d1a31dc04f7c40a822134fbd532..4462e0ccf8e888b54870ad6c17331be3ae261ae6 100644 (file)
@@ -84,11 +84,21 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
                c.set_sp(sp)
                *(*uint64)(unsafe.Pointer(uintptr(sp))) = c.link()
 
+               pc := uintptr(gp.sigpc)
+
+               // If we don't recognize the PC as code
+               // but we do recognize the link register as code,
+               // then assume this was a call to non-code and treat like
+               // pc == 0, to make unwinding show the context.
+               if pc != 0 && findfunc(pc) == nil && findfunc(uintptr(c.link())) != nil {
+                       pc = 0
+               }
+
                // Don't bother saving PC if it's zero, which is
                // probably a call to a nil func: the old link register
                // is more useful in the stack trace.
-               if gp.sigpc != 0 {
-                       c.set_link(uint64(gp.sigpc))
+               if pc != 0 {
+                       c.set_link(uint64(pc))
                }
 
                // In case we are panicking from external C code