Skip to content

Commit

Permalink
Tidy/update signal handling code for linux/riscv
Browse files Browse the repository at this point in the history
  • Loading branch information
4a6f656c committed May 7, 2019
1 parent 9fb5eaa commit e4b74ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
14 changes: 2 additions & 12 deletions src/runtime/signal_riscv.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,8 @@ func (c *sigctxt) preparePanic(sig uint32, gp *g) {

pc := gp.sigpc

// If we don't recognize the PC as code
// but we do recognize the RA 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).valid() && findfunc(uintptr(c.ra())).valid() {
pc = 0
}

// Don't bother saving PC if it's zero, which is
// probably a call to a nil func: the RA
// is more useful in the stack trace.
if pc != 0 {
if shouldPushSigpanic(gp, pc, uintptr(c.ra())) {
// Make it look the like faulting PC called sigpanic.
c.set_ra(uint64(pc))
}

Expand Down
12 changes: 6 additions & 6 deletions src/runtime/sys_linux_riscv.s
Original file line number Diff line number Diff line change
Expand Up @@ -266,18 +266,18 @@ TEXT runtime·sigfwd(SB),NOSPLIT,$0-32
JALR RA, T1
RET

// func sigtramp(ureg, note unsafe.Pointer)
TEXT runtime·sigtramp(SB),NOSPLIT,$24
// func sigtramp(signo, ureg, ctxt unsafe.Pointer)
TEXT runtime·sigtramp(SB),NOSPLIT,$64
MOVW A0, 8(X2)
MOV A1, 16(X2)
MOV A2, 24(X2)

// this might be called in external code context,
// where g is not set.
// first save R0, because runtime·load_g will clobber it
MOVW A0, 8(X2)
MOVBU runtime·iscgo(SB), A0
BEQ A0, ZERO, 2(PC)
CALL runtime·load_g(SB)

MOV A1, 16(X2)
MOV A2, 24(X2)
MOV $runtime·sigtrampgo(SB), A0
JALR RA, A0
RET
Expand Down

0 comments on commit e4b74ec

Please sign in to comment.