Commit a9e53644 authored by Russ Cox's avatar Russ Cox

runtime: set m.procid always on Linux

For debuggers and other program inspectors.

Fixes #9914.

Change-Id: I670728cea28c045e6eaba1808c550ee2f34d16ff
Reviewed-on: https://go-review.googlesource.com/11341Reviewed-by: default avatarAustin Clements <austin@google.com>
parent c68f2f89
......@@ -197,6 +197,8 @@ func msigsave(mp *m) {
rtsigprocmask(_SIG_SETMASK, nil, smask, int32(unsafe.Sizeof(*smask)))
}
func gettid() uint32
// Called to initialize a new m (including the bootstrap m).
// Called on the new thread, can not allocate memory.
func minit() {
......@@ -204,6 +206,9 @@ func minit() {
_g_ := getg()
signalstack(&_g_.m.gsignal.stack)
// for debuggers, in case cgo created the thread
_g_.m.procid = uint64(gettid())
// restore signal mask from m.sigmask and unblock essential signals
nmask := *(*sigset)(unsafe.Pointer(&_g_.m.sigmask))
for i := range sigtable {
......
......@@ -96,6 +96,12 @@ TEXT runtime·usleep(SB),NOSPLIT,$8
CALL *runtime·_vdso(SB)
RET
TEXT runtime·gettid(SB),NOSPLIT,$0-4
MOVL $224, AX // syscall - gettid
CALL *runtime·_vdso(SB)
MOVL AX, ret+0(FP)
RET
TEXT runtime·raise(SB),NOSPLIT,$12
MOVL $224, AX // syscall - gettid
CALL *runtime·_vdso(SB)
......
......@@ -94,6 +94,12 @@ TEXT runtime·usleep(SB),NOSPLIT,$16
SYSCALL
RET
TEXT runtime·gettid(SB),NOSPLIT,$0-4
MOVL $186, AX // syscall - gettid
SYSCALL
MOVL AX, ret+0(FP)
RET
TEXT runtime·raise(SB),NOSPLIT,$0
MOVL $186, AX // syscall - gettid
SYSCALL
......
......@@ -121,6 +121,12 @@ TEXT runtime·exit1(SB),NOSPLIT,$-4
MOVW $1003, R1
MOVW R0, (R1) // fail hard
TEXT runtime·gettid(SB),NOSPLIT,$0-4
MOVW $SYS_gettid, R7
SWI $0
MOVW R0, ret+0(FP)
RET
TEXT runtime·raise(SB),NOSPLIT,$-4
MOVW $SYS_gettid, R7
SWI $0
......
......@@ -136,6 +136,12 @@ TEXT runtime·usleep(SB),NOSPLIT,$16-4
SVC
RET
TEXT runtime·gettid(SB),NOSPLIT,$0-4
MOVD $SYS_gettid, R8
SVC
MOVW R0, ret+0(FP)
RET
TEXT runtime·raise(SB),NOSPLIT,$-8
MOVD $SYS_gettid, R8
SVC
......
......@@ -121,6 +121,11 @@ TEXT runtime·usleep(SB),NOSPLIT,$16-4
SYSCALL $SYS_newselect
RET
TEXT runtime·gettid(SB),NOSPLIT,$0-4
SYSCALL $SYS_gettid
MOVW R3, ret+0(FP)
RET
TEXT runtime·raise(SB),NOSPLIT,$-8
SYSCALL $SYS_gettid
MOVW R3, R3 // arg 1 tid
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment