git.colasdn.top/newrelic/go-agent@v3.26.0+incompatible/internal/stacktracetest/stacktracetest.go (about) 1 // Copyright 2020 New Relic Corporation. All rights reserved. 2 // SPDX-License-Identifier: Apache-2.0 3 4 // Package stacktracetest helps test stack trace behavior. 5 package stacktracetest 6 7 // TopStackFrame is a function should will appear in the stacktrace. 8 func TopStackFrame(generateStacktrace func() []byte) []byte { 9 return generateStacktrace() 10 } 11 12 // CountedCall is a function that allows you to generate a stack trace with this function being called a particular 13 // number of times. The parameter f should be a function that returns a StackTrace (but it is referred to as []uintptr 14 // in order to not create a circular dependency on the internal package) 15 func CountedCall(i int, f func() []uintptr) []uintptr { 16 if i > 0 { 17 return CountedCall(i-1, f) 18 } 19 return f() 20 }