1
0
mirror of https://github.com/golang/go synced 2024-11-22 19:44:57 -07:00

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/11341
Reviewed-by: Austin Clements <austin@google.com>
This commit is contained in:
Russ Cox 2015-06-22 12:32:05 -04:00
parent c68f2f8996
commit a9e536442e
6 changed files with 34 additions and 0 deletions

View File

@ -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 {

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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