func TestCaller(t *testing.T) { … } // These are marked noinline so that we can use FuncForPC // in testCallerBar. // //go:noinline func testCallerFoo(t *testing.T) { … } //go:noinline func testCallerBar(t *testing.T) { … } func lineNumber() int { … } var firstLine … var lineVar1 … var ( lineVar2a … lineVar2b … ) var compLit … var arrayLit … var sliceLit … var mapLit … var intLit … func trythis() { … } var ( l38 … l39 … l40 … ) func recordLines(a, b, c int) { … } func TestLineNumber(t *testing.T) { … } func TestNilName(t *testing.T) { … } var dummy … func inlined() { … } // A function with an InlTree. Returns a PC within the function body. // // No inline to ensure this complete function appears in output. // //go:noinline func tracebackFunc(t *testing.T) uintptr { … } // Test that CallersFrames handles PCs in the alignment region between // functions (int 3 on amd64) without crashing. // // Go will never generate a stack trace containing such an address, as it is // not a valid call site. However, the cgo traceback function passed to // runtime.SetCgoTraceback may not be completely accurate and may incorrect // provide PCs in Go code or the alignment region between functions. // // Go obviously doesn't easily expose the problematic PCs to running programs, // so this test is a bit fragile. Some details: // // - tracebackFunc is our target function. We want to get a PC in the // alignment region following this function. This function also has other // functions inlined into it to ensure it has an InlTree (this was the source // of the bug in issue 44971). // // - We acquire a PC in tracebackFunc, walking forwards until FuncForPC says // we're in a new function. The last PC of the function according to FuncForPC // should be in the alignment region (assuming the function isn't already // perfectly aligned). // // This is a regression test for issue 44971. func TestFunctionAlignmentTraceback(t *testing.T) { … } func BenchmarkFunc(b *testing.B) { … }