Commit 7821be59 authored by David Lazar's avatar David Lazar

runtime: make example independent of inlining

Otherwise, with -l=4, runtime.Callers gets inlined and the example
prints too many frames. Now the example passes with -l=4.

Change-Id: I9e420af9371724ac3ec89efafd76a658cf82bb4a
Reviewed-on: https://go-review.googlesource.com/40876
Run-TryBot: David Lazar <lazard@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: default avatarAustin Clements <austin@google.com>
parent 0ea120a7
......@@ -19,10 +19,9 @@ func ExampleFrames() {
frames := runtime.CallersFrames(pc[:n])
var frame runtime.Frame
more := true
for more {
for i, more := 0, true; more && i < 5; i++ {
frame, more = frames.Next()
fmt.Printf("- more:%v | %s\n", more, frame.Function)
fmt.Printf("- %s\n", frame.Function)
}
}
......@@ -31,9 +30,9 @@ func ExampleFrames() {
a()
// Output:
// - more:true | runtime.Callers
// - more:true | runtime_test.ExampleFrames.func1
// - more:true | runtime_test.ExampleFrames.func2
// - more:true | runtime_test.ExampleFrames.func3
// - more:false | runtime_test.ExampleFrames
// - runtime.Callers
// - runtime_test.ExampleFrames.func1
// - runtime_test.ExampleFrames.func2
// - runtime_test.ExampleFrames.func3
// - runtime_test.ExampleFrames
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment