mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile/internal/gc: add tracing support to debug type checking
The compiler must first be built with the constant enableTrace set to true (typecheck.go). After that, the -t flag becomes available which enables tracing output of type-checking functions. With enableTrace == false, the tracing code becomes dead code and won't affect the compiler. Typical output might look like this: path/y.go:4:6: typecheck 0xc00033e180 DCLTYPE <node DCLTYPE> tc=0 path/y.go:4:6: . typecheck1 0xc00033e180 DCLTYPE <node DCLTYPE> tc=2 path/y.go:4:6: . . typecheck 0xc000331a40 TYPE T tc=1 path/y.go:4:6: . . . typecheck1 0xc000331a40 TYPE T tc=2 path/y.go:4:6: . . . . typecheckdef 0xc000331a40 TYPE T tc=2 path/y.go:4:6: . . . . => 0xc000331a40 TYPE T tc=2 type=*T path/y.go:4:6: . . . => 0xc000331a40 TYPE T tc=2 type=*T path/y.go:4:6: . . => 0xc000331a40 TYPE T tc=1 type=*T path/y.go:4:6: . => 0xc00033e180 DCLTYPE <node DCLTYPE> tc=2 type=<T> path/y.go:4:6: => 0xc00033e180 DCLTYPE <node DCLTYPE> tc=1 type=<T> Disabled by default. Change-Id: Ifd8385290d1cf0d3fc5e8468b2f4ab84e8eff338 Reviewed-on: https://go-review.googlesource.com/c/146782 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
c21ba09bcd
commit
e25823edce
2 changed files with 94 additions and 5 deletions
|
|
@ -229,6 +229,9 @@ func Main(archInit func(*Arch)) {
|
|||
flag.BoolVar(&flag_race, "race", false, "enable race detector")
|
||||
}
|
||||
objabi.Flagcount("s", "warn about composite literals that can be simplified", &Debug['s'])
|
||||
if enableTrace {
|
||||
flag.BoolVar(&trace, "t", false, "trace type-checking")
|
||||
}
|
||||
flag.StringVar(&pathPrefix, "trimpath", "", "remove `prefix` from recorded source file paths")
|
||||
flag.BoolVar(&Debug_vlog, "v", false, "increase debug verbosity")
|
||||
objabi.Flagcount("w", "debug type checking", &Debug['w'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue