github.com/Rookout/GoSDK@v0.1.48/pkg/services/callstack/callstack_amd64_1.15.go (about) 1 //go:build amd64 && go1.15 && !go1.17 2 // +build amd64,go1.15,!go1.17 3 4 package callstack 5 6 import ( 7 "github.com/Rookout/GoSDK/pkg/services/go_runtime" 8 "github.com/Rookout/GoSDK/pkg/services/suspender" 9 _ "unsafe" 10 ) 11 12 //go:linkname allgs runtime.allgs 13 var allgs []go_runtime.GPtr 14 15 func (s *StackTraceBuffer) FillStackTraces() (int, bool) { 16 if !suspender.GetSuspender().Stopped() { 17 panic("You can't use this function while the world is not stopped! You must call StopAll() first!") 18 } 19 20 globCurrentG = go_runtime.Getg() 21 globCurrentStb = s 22 globCurrentStb.filled = 0 23 globN = 0 24 globOk = false 25 26 for _, gp1 := range allgs { 27 countg(gp1) 28 } 29 30 if globN <= globCurrentStb.capacity() { 31 globOk = true 32 globStbView = globCurrentStb.buf 33 34 35 for _, gp1 := range allgs { 36 saveGoroutine(gp1) 37 } 38 } 39 return globN, globOk 40 }