tlog.app/go/loc@v0.6.2-0.20231112073106-b6382a0ac518/unsafe_go1.20.go (about)

     1  //go:build nikandfor_loc_unsafe && go1.20
     2  // +build nikandfor_loc_unsafe,go1.20
     3  
     4  package loc
     5  
     6  import "unsafe"
     7  
     8  type (
     9  	funcID uint8
    10  
    11  	funcInfo struct {
    12  		*_func
    13  		datap unsafe.Pointer
    14  	}
    15  
    16  	_func struct {
    17  		entryOff uint32 // start pc, as offset from moduledata.text/pcHeader.textStart
    18  		nameOff  int32  // function name, as index into moduledata.funcnametab.
    19  	}
    20  
    21  	// inlinedCall is the encoding of entries in the FUNCDATA_InlTree table.
    22  	inlinedCall struct {
    23  		funcID    funcID // type of the called function
    24  		_         [3]byte
    25  		nameOff   int32 // offset into pclntab for name of called function
    26  		parentPc  int32 // position of an instruction whose source position is the call site (offset from entry)
    27  		startLine int32 // line number of start of function (func keyword/TEXT directive)
    28  	}
    29  )
    30  
    31  // FuncEntry is functions entry point.
    32  func (l PC) FuncEntry() PC {
    33  	funcInfo := findfunc(l)
    34  	if funcInfo._func == nil {
    35  		return 0
    36  	}
    37  
    38  	return funcInfoEntry(funcInfo)
    39  }