github.com/Rookout/GoSDK@v0.1.48/pkg/services/instrumentation/trampoline_manager_arm64.go (about)

     1  //go:build arm64
     2  // +build arm64
     3  
     4  package instrumentation
     5  
     6  import (
     7  	"sync"
     8  	"unsafe"
     9  
    10  	"github.com/Rookout/GoSDK/pkg/rookoutErrors"
    11  )
    12  
    13  type trampolineManager struct {
    14  	trampolineAddressesInUse     map[int]bool
    15  	trampolineAddressesInUseLock sync.Mutex
    16  }
    17  
    18  func newTrampolineManager() *trampolineManager {
    19  	t := &trampolineManager{}
    20  	t.trampolineAddressesInUse = make(map[int]bool, trampolineCount)
    21  	for i := range finalTrampolineAddresses {
    22  		t.trampolineAddressesInUse[i] = false
    23  	}
    24  	return t
    25  }
    26  
    27  func (t *trampolineManager) getTrampolineAddress() (*uint64, unsafe.Pointer, rookoutErrors.RookoutError) {
    28  	t.trampolineAddressesInUseLock.Lock()
    29  	defer t.trampolineAddressesInUseLock.Unlock()
    30  
    31  	for i, inUse := range t.trampolineAddressesInUse {
    32  		if inUse {
    33  			continue
    34  		}
    35  		t.trampolineAddressesInUse[i] = true
    36  		return &(finalTrampolineAddresses[i]), getMiddleTrampolineAddress(i), nil
    37  	}
    38  
    39  	return nil, nil, rookoutErrors.NewAllTrampolineAddressesInUse()
    40  }