
Displays the return values of the current function when we step out of it after executing a step, next or stepout command. Implementation of this feature is tricky: when the function has returned the return variables are not in scope anymore. Implementing this feature requires evaluating variables that are out of scope, using a stack frame that doesn't exist anymore. We can't calculate the address of these variables when the next/step/stepout command is initiated either, because between that point and the time where the stepout breakpoint is actually hit the goroutine stack could grow and be moved to a different memory address.
12 lines
147 B
Go
12 lines
147 B
Go
package main
|
|
|
|
import "fmt"
|
|
|
|
func stepout(n int) (str string, num int) {
|
|
return fmt.Sprintf("return %d", n), n + 1
|
|
}
|
|
|
|
func main() {
|
|
stepout(47)
|
|
}
|