github.com/Rookout/GoSDK@v0.1.48/pkg/services/callstack/callstack_amd64_1.17.go (about) 1 //go:build amd64 && go1.17 && !go1.22 2 // +build amd64,go1.17,!go1.22 3 4 package callstack 5 6 import ( 7 _ "unsafe" 8 9 "github.com/Rookout/GoSDK/pkg/services/go_runtime" 10 "github.com/Rookout/GoSDK/pkg/services/suspender" 11 ) 12 13 //go:linkname forEachGRace runtime.forEachGRace 14 func forEachGRace(fn func(g go_runtime.GPtr)) 15 16 func (s *StackTraceBuffer) FillStackTraces() (int, bool) { 17 if !suspender.GetSuspender().Stopped() { 18 panic("You can't use this function while the world is not stopped! You must call StopAll() first!") 19 } 20 21 globCurrentG = go_runtime.Getg() 22 globCurrentStb = s 23 24 globCurrentStb.filled = 0 25 globN = 0 26 globOk = false 27 28 29 forEachGRace(countg) 30 if globN <= globCurrentStb.capacity() { 31 globOk = true 32 globStbView = globCurrentStb.buf 33 34 35 36 forEachGRace(saveGoroutine) 37 } 38 return globN, globOk 39 } 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91