const stackTraceDebug … type stackWorkBuf … type stackWorkBufHdr … type stackObjectBuf … type stackObjectBufHdr … func init() { … } type stackObject … // obj.r = r, but with no write barrier. // //go:nowritebarrier func (obj *stackObject) setRecord(r *stackObjectRecord) { … } type stackScanState … // Add p as a potential pointer to a stack object. // p must be a stack address. func (s *stackScanState) putPtr(p uintptr, conservative bool) { … } // Remove and return a potential pointer to a stack object. // Returns 0 if there are no more pointers available. // // This prefers non-conservative pointers so we scan stack objects // precisely if there are any non-conservative pointers to them. func (s *stackScanState) getPtr() (p uintptr, conservative bool) { … } // addObject adds a stack object at addr of type typ to the set of stack objects. func (s *stackScanState) addObject(addr uintptr, r *stackObjectRecord) { … } // buildIndex initializes s.root to a binary search tree. // It should be called after all addObject calls but before // any call of findObject. func (s *stackScanState) buildIndex() { … } // Build a binary search tree with the n objects in the list // x.obj[idx], x.obj[idx+1], ..., x.next.obj[0], ... // Returns the root of that tree, and the buf+idx of the nth object after x.obj[idx]. // (The first object that was not included in the binary search tree.) // If n == 0, returns nil, x. func binarySearchTree(x *stackObjectBuf, idx int, n int) (root *stackObject, restBuf *stackObjectBuf, restIdx int) { … } // findObject returns the stack object containing address a, if any. // Must have called buildIndex previously. func (s *stackScanState) findObject(a uintptr) *stackObject { … }