Support to add a new suboption --follow-calls to trace subcommand
Support for an option to the trace subcommand, "--follow-calls
This option also indents the output according to depth for the calls occurring in the program Calls such as runtime.morestack_noctxt are treated specially and do not adhere to the definition of depth like the other functions Though we can also trace morestack_noctxt calls if desired
For example, if we have a simple .go program such as the following
package main
import "fmt"
func D(i int) int {
return i*i*i
}
func C(i int) int {
return i+20
}
func B(i int) int {
d:=C(i)+40
return d+D(i)
}
func A(i int) int {
return 10+B(i)
}
func main() {
j := 0
j += A(2)
fmt.Println(j)
}
building leaf4 and running delve as follows would give the following trace output
go build -gcflags '-N -l' ./leaf4.go
../dlv trace main.A --follow-calls 3 -e=./leaf4^M
> goroutine(1): runtime.morestack_noctxt()^M
> goroutine(1): main.A(2)^M
> goroutine(1): main.B(2)^M
> goroutine(1): main.C(2)^M
>> goroutine(1): => (22)^M
> goroutine(1): main.D(2)^M
>> goroutine(1): => (8)^M
>> goroutine(1): => (70)^M
>> goroutine(1): => (80)^M
> goroutine(1): runtime.morestack_noctxt()^M
80^M