]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: flag "-d=dumpptrs" to print Node ptrs in Dump output
authorDan Scales <danscales@google.com>
Thu, 19 Nov 2020 00:42:31 +0000 (16:42 -0800)
committerDan Scales <danscales@google.com>
Thu, 19 Nov 2020 17:28:05 +0000 (17:28 +0000)
The printing of the ptr values can mean that two dump outputs can't easily be
compared for the identical structure, so adding the "-d=dumpptrs" option to make
printing of Node pointer values be an option.

Change-Id: I0e92b02f069e9de2e6fa036a7841645d13cdd7a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/271339
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/fmt.go
src/cmd/compile/internal/gc/main.go

index 240b09bb6d38c9040c75769dac2ca7d7cd090f7d..f92f5d0e884a7ad53748bf42f7c5423bc9130c1b 100644 (file)
@@ -419,13 +419,15 @@ func (n *Node) format(s fmt.State, verb rune, mode fmtMode) {
 func (n *Node) jconv(s fmt.State, flag FmtFlag) {
        c := flag & FmtShort
 
-       // Useful to see which nodes in an AST printout are actually identical
-       fmt.Fprintf(s, " p(%p)", n)
+       // Useful to see which nodes in a Node Dump/dumplist are actually identical
+       if Debug_dumpptrs != 0 {
+               fmt.Fprintf(s, " p(%p)", n)
+       }
        if c == 0 && n.Name != nil && n.Name.Vargen != 0 {
                fmt.Fprintf(s, " g(%d)", n.Name.Vargen)
        }
 
-       if c == 0 && n.Name != nil && n.Name.Defn != nil {
+       if Debug_dumpptrs != 0 && c == 0 && n.Name != nil && n.Name.Defn != nil {
                // Useful to see where Defn is set and what node it points to
                fmt.Fprintf(s, " defn(%p)", n.Name.Defn)
        }
index f0a913275a0b8adc016e0c4302aeb3a9037ddb1e..a6963a3d66e62c36ad5f8d46a89cbac3ca53e73c 100644 (file)
@@ -46,6 +46,7 @@ var (
        Debug_closure      int
        Debug_compilelater int
        debug_dclstack     int
+       Debug_dumpptrs     int
        Debug_libfuzzer    int
        Debug_panic        int
        Debug_slice        int
@@ -75,6 +76,7 @@ var debugtab = []struct {
        {"compilelater", "compile functions as late as possible", &Debug_compilelater},
        {"disablenil", "disable nil checks", &disable_checknil},
        {"dclstack", "run internal dclstack check", &debug_dclstack},
+       {"dumpptrs", "show Node pointer values in Dump/dumplist output", &Debug_dumpptrs},
        {"gcprog", "print dump of GC programs", &Debug_gcprog},
        {"libfuzzer", "coverage instrumentation for libfuzzer", &Debug_libfuzzer},
        {"nil", "print information about nil checks", &Debug_checknil},