github.com/Rookout/GoSDK@v0.1.48/pkg/services/go_runtime/goroutine1.21.go (about)

     1  //go:build go1.21 && !go1.22
     2  // +build go1.21,!go1.22
     3  
     4  package go_runtime
     5  
     6  import (
     7  	_ "unsafe"
     8  
     9  	"github.com/Rookout/GoSDK/pkg/services/instrumentation/module"
    10  )
    11  
    12  type GPtr uintptr
    13  
    14  
    15  type guintptr uintptr
    16  type unwindFlags uint8
    17  
    18  const (
    19  	
    20  	
    21  	
    22  	
    23  	
    24  	
    25  	
    26  	
    27  	
    28  	
    29  	
    30  	
    31  	unwindPrintErrors unwindFlags = 1 << iota
    32  
    33  	
    34  	unwindSilentErrors
    35  
    36  	
    37  	
    38  	
    39  	
    40  	
    41  	
    42  	
    43  	
    44  	
    45  	
    46  	unwindTrap
    47  
    48  	
    49  	
    50  	
    51  	unwindJumpStack
    52  )
    53  
    54  type stkframe struct {
    55  	
    56  	
    57  	fn module.FuncInfo
    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  	pc uintptr
    84  
    85  	
    86  	
    87  	
    88  	
    89  	
    90  	
    91  	
    92  	
    93  	continpc uintptr
    94  
    95  	lr   uintptr 
    96  	sp   uintptr 
    97  	fp   uintptr 
    98  	varp uintptr 
    99  	argp uintptr 
   100  }
   101  type unwinder struct {
   102  	
   103  	
   104  	frame stkframe
   105  
   106  	
   107  	
   108  	
   109  	g guintptr
   110  
   111  	
   112  	
   113  	cgoCtxt int
   114  
   115  	
   116  	
   117  	calleeFuncID module.FuncID
   118  
   119  	
   120  	
   121  	flags unwindFlags
   122  
   123  	
   124  	cache module.PCValueCache
   125  }
   126  
   127  
   128  func Getg() GPtr
   129  
   130  //go:linkname initAt runtime.(*unwinder).initAt
   131  func initAt(u *unwinder, pc0, sp0, lr0 uintptr, gp GPtr, flags unwindFlags)
   132  
   133  //go:linkname tracebackPCs runtime.tracebackPCs
   134  func tracebackPCs(u *unwinder, skip int, pcBuf []uintptr) int
   135  
   136  
   137  func Callers(pc uintptr, sp uintptr, gp GPtr, pcbuf []uintptr) int {
   138  	var u unwinder
   139  	initAt(&u, pc, sp, 0, gp, unwindSilentErrors)
   140  	return tracebackPCs(&u, 0, pcbuf)
   141  }