github.com/Rookout/GoSDK@v0.1.48/pkg/services/instrumentation/binary_info/go_asm_unwrap.go (about) 1 //go:build (amd64 && go1.17) || (arm64 && go1.18) 2 // +build amd64,go1.17 arm64,go1.18 3 4 package binary_info 5 6 import ( 7 "reflect" 8 "runtime" 9 10 "github.com/Rookout/GoSDK/pkg/logger" 11 "github.com/Rookout/GoSDK/pkg/rookoutErrors" 12 ) 13 14 15 16 func (b *BinaryInfo) GetUnwrappedFuncPointer(f func()) (uintptr, rookoutErrors.RookoutError) { 17 wrappedFuncPointer := reflect.ValueOf(f).Pointer() 18 funcName := runtime.FuncForPC(wrappedFuncPointer).Name() 19 20 for i := range b.Functions { 21 if b.Functions[i].Name == funcName { 22 23 if wrappedFuncPointer != uintptr(b.Functions[i].Entry) { 24 logger.Logger().Infof("Found unwrapped func address for %s: 0x%x (replaces 0x%x)", funcName, b.Functions[i].Entry, wrappedFuncPointer) 25 return uintptr(b.Functions[i].Entry), nil 26 } 27 } 28 } 29 30 logger.Logger().Infof("No unwrapped function found for: %s", funcName) 31 return 0, rookoutErrors.NewUnwrappedFuncNotFound(funcName) 32 }