]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.regabi] cmd/compile: clean up debug flag (-d) handling [generated]
authorRuss Cox <rsc@golang.org>
Mon, 16 Nov 2020 06:17:25 +0000 (01:17 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 25 Nov 2020 16:39:42 +0000 (16:39 +0000)
The debug table is not as haphazard as flags, but there are still
a few mismatches between command-line names and variable names.
This CL moves them all into a consistent home (var Debug, like var Flag).

Code updated automatically using the rf command below.
A followup CL will make a few manual cleanups, leaving this CL
completely automated and easier to regenerate during merge
conflicts.

[git-generate]
cd src/cmd/compile/internal/gc
rf '
add main.go var Debug struct{}
mv Debug_append Debug.Append
mv Debug_checkptr Debug.Checkptr
mv Debug_closure Debug.Closure
mv Debug_compilelater Debug.CompileLater
mv disable_checknil Debug.DisableNil
mv debug_dclstack Debug.DclStack
mv Debug_gcprog Debug.GCProg
mv Debug_libfuzzer Debug.Libfuzzer
mv Debug_checknil Debug.Nil
mv Debug_panic Debug.Panic
mv Debug_slice Debug.Slice
mv Debug_typeassert Debug.TypeAssert
mv Debug_wb Debug.WB
mv Debug_export Debug.Export
mv Debug_pctab Debug.PCTab
mv Debug_locationlist Debug.LocationLists
mv Debug_typecheckinl Debug.TypecheckInl
mv Debug_gendwarfinl Debug.DwarfInl
mv Debug_softfloat Debug.SoftFloat
mv Debug_defer Debug.Defer
mv Debug_dumpptrs Debug.DumpPtrs

mv flag.go:/parse.-d/-1,/unknown.debug/+2 parseDebug

mv debugtab Debug parseDebug \
debugHelpHeader debugHelpFooter \
debug.go

# Remove //go:generate line copied from main.go
rm debug.go:/go:generate/-+
'

Change-Id: I625761ca5659be4052f7161a83baa00df75cca91
Reviewed-on: https://go-review.googlesource.com/c/go/+/272246
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
29 files changed:
src/cmd/compile/internal/amd64/ssa.go
src/cmd/compile/internal/arm/ssa.go
src/cmd/compile/internal/arm64/ssa.go
src/cmd/compile/internal/gc/alg.go
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/debug.go [new file with mode: 0644]
src/cmd/compile/internal/gc/dwinl.go
src/cmd/compile/internal/gc/export.go
src/cmd/compile/internal/gc/flag.go
src/cmd/compile/internal/gc/fmt.go
src/cmd/compile/internal/gc/go.go
src/cmd/compile/internal/gc/inl.go
src/cmd/compile/internal/gc/main.go
src/cmd/compile/internal/gc/order.go
src/cmd/compile/internal/gc/pgen.go
src/cmd/compile/internal/gc/print.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/compile/internal/gc/sinit.go
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/walk.go
src/cmd/compile/internal/mips/ssa.go
src/cmd/compile/internal/mips64/ssa.go
src/cmd/compile/internal/ppc64/ssa.go
src/cmd/compile/internal/riscv64/ssa.go
src/cmd/compile/internal/s390x/ssa.go
src/cmd/compile/internal/wasm/ssa.go
src/cmd/compile/internal/x86/ssa.go

index 5ff05a0edd16c6b0dab15099d13e9d89d1be7fc0..1f2d626721ed59fdd825a835a14bce33de54ecab 100644 (file)
@@ -1164,7 +1164,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
        case ssa.OpAMD64MOVBatomicload, ssa.OpAMD64MOVLatomicload, ssa.OpAMD64MOVQatomicload:
index 765a7715465ce8af6f6297ed37d6a924d060af9c..82a5172ec7f96ad9f69a23036495a2ccae10a517 100644 (file)
@@ -741,7 +741,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
        case ssa.OpARMLoweredZero:
index 22b28a9308bd39270376e491a2c100a3ea2cb86c..dcbd8f947400c2110aa79decfcf7c944fec1e389 100644 (file)
@@ -1038,7 +1038,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Line==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Line==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
        case ssa.OpARM64Equal,
index c1d8de6bad426f61419e540040879c2e2958ce92..87b905ed59e0f254de010c132b85902a4cf36272 100644 (file)
@@ -387,7 +387,7 @@ func genhash(t *types.Type) *obj.LSym {
        typecheckslice(fn.Nbody.Slice(), ctxStmt)
        Curfn = nil
 
-       if debug_dclstack != 0 {
+       if Debug.DclStack != 0 {
                testdclstack()
        }
 
@@ -766,7 +766,7 @@ func geneq(t *types.Type) *obj.LSym {
        typecheckslice(fn.Nbody.Slice(), ctxStmt)
        Curfn = nil
 
-       if debug_dclstack != 0 {
+       if Debug.DclStack != 0 {
                testdclstack()
        }
 
index f850cbe2801dc7f601dff73ab46a21efe59b4bcf..c25a4469997e433b64810c728c66e472b123f968 100644 (file)
@@ -337,7 +337,7 @@ func hasemptycvars(clo *Node) bool {
 // closuredebugruntimecheck applies boilerplate checks for debug flags
 // and compiling runtime
 func closuredebugruntimecheck(clo *Node) {
-       if Debug_closure > 0 {
+       if Debug.Closure > 0 {
                if clo.Esc == EscHeap {
                        Warnl(clo.Pos, "heap closure, captured vars = %v", clo.Func.ClosureVars)
                } else {
@@ -386,7 +386,7 @@ func walkclosure(clo *Node, init *Nodes) *Node {
 
        // If no closure vars, don't bother wrapping.
        if hasemptycvars(clo) {
-               if Debug_closure > 0 {
+               if Debug.Closure > 0 {
                        Warnl(clo.Pos, "closure converted to global")
                }
                return fn.Nname
diff --git a/src/cmd/compile/internal/gc/debug.go b/src/cmd/compile/internal/gc/debug.go
new file mode 100644 (file)
index 0000000..f6be3d5
--- /dev/null
@@ -0,0 +1,167 @@
+// Copyright 2009 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package gc
+
+import (
+       "fmt"
+       "log"
+       "os"
+       "strconv"
+       "strings"
+
+       "cmd/compile/internal/ssa"
+       "cmd/internal/objabi"
+)
+
+// Debug arguments.
+// These can be specified with the -d flag, as in "-d nil"
+// to set the debug_checknil variable.
+// Multiple options can be comma-separated.
+// Each option accepts an optional argument, as in "gcprog=2"
+var debugtab = []struct {
+       name string
+       help string
+       val  interface{} // must be *int or *string
+}{
+       {"append", "print information about append compilation", &Debug.Append},
+       {"checkptr", "instrument unsafe pointer conversions", &Debug.Checkptr},
+       {"closure", "print information about closure compilation", &Debug.Closure},
+       {"compilelater", "compile functions as late as possible", &Debug.CompileLater},
+       {"disablenil", "disable nil checks", &Debug.DisableNil},
+       {"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.Nil},
+       {"panic", "do not hide any compiler panic", &Debug.Panic},
+       {"slice", "print information about slice compilation", &Debug.Slice},
+       {"typeassert", "print information about type assertion inlining", &Debug.TypeAssert},
+       {"wb", "print information about write barriers", &Debug.WB},
+       {"export", "print export data", &Debug.Export},
+       {"pctab", "print named pc-value table", &Debug.PCTab},
+       {"locationlists", "print information about DWARF location list creation", &Debug.LocationLists},
+       {"typecheckinl", "eager typechecking of inline function bodies", &Debug.TypecheckInl},
+       {"dwarfinl", "print information about DWARF inlined function creation", &Debug.DwarfInl},
+       {"softfloat", "force compiler to emit soft-float code", &Debug.SoftFloat},
+       {"defer", "print information about defer compilation", &Debug.Defer},
+       {"fieldtrack", "enable fieldtracking", &objabi.Fieldtrack_enabled},
+}
+
+var Debug struct {
+       Append        int
+       Checkptr      int
+       Closure       int
+       CompileLater  int
+       DisableNil    int
+       DclStack      int
+       GCProg        int
+       Libfuzzer     int
+       Nil           int
+       Panic         int
+       Slice         int
+       TypeAssert    int
+       WB            int
+       Export        int
+       PCTab         string
+       LocationLists int
+       TypecheckInl  int
+       DwarfInl      int
+       SoftFloat     int
+       Defer         int
+       DumpPtrs      int
+}
+
+func parseDebug() {
+       // parse -d argument
+       if Flag.LowerD != "" {
+       Split:
+               for _, name := range strings.Split(Flag.LowerD, ",") {
+                       if name == "" {
+                               continue
+                       }
+                       // display help about the -d option itself and quit
+                       if name == "help" {
+                               fmt.Print(debugHelpHeader)
+                               maxLen := len("ssa/help")
+                               for _, t := range debugtab {
+                                       if len(t.name) > maxLen {
+                                               maxLen = len(t.name)
+                                       }
+                               }
+                               for _, t := range debugtab {
+                                       fmt.Printf("\t%-*s\t%s\n", maxLen, t.name, t.help)
+                               }
+                               // ssa options have their own help
+                               fmt.Printf("\t%-*s\t%s\n", maxLen, "ssa/help", "print help about SSA debugging")
+                               fmt.Print(debugHelpFooter)
+                               os.Exit(0)
+                       }
+                       val, valstring, haveInt := 1, "", true
+                       if i := strings.IndexAny(name, "=:"); i >= 0 {
+                               var err error
+                               name, valstring = name[:i], name[i+1:]
+                               val, err = strconv.Atoi(valstring)
+                               if err != nil {
+                                       val, haveInt = 1, false
+                               }
+                       }
+                       for _, t := range debugtab {
+                               if t.name != name {
+                                       continue
+                               }
+                               switch vp := t.val.(type) {
+                               case nil:
+                                       // Ignore
+                               case *string:
+                                       *vp = valstring
+                               case *int:
+                                       if !haveInt {
+                                               log.Fatalf("invalid debug value %v", name)
+                                       }
+                                       *vp = val
+                               default:
+                                       panic("bad debugtab type")
+                               }
+                               continue Split
+                       }
+                       // special case for ssa for now
+                       if strings.HasPrefix(name, "ssa/") {
+                               // expect form ssa/phase/flag
+                               // e.g. -d=ssa/generic_cse/time
+                               // _ in phase name also matches space
+                               phase := name[4:]
+                               flag := "debug" // default flag is debug
+                               if i := strings.Index(phase, "/"); i >= 0 {
+                                       flag = phase[i+1:]
+                                       phase = phase[:i]
+                               }
+                               err := ssa.PhaseOption(phase, flag, val, valstring)
+                               if err != "" {
+                                       log.Fatalf(err)
+                               }
+                               continue Split
+                       }
+                       log.Fatalf("unknown debug key -d %s\n", name)
+               }
+       }
+}
+
+const debugHelpHeader = `usage: -d arg[,arg]* and arg is <key>[=<value>]
+
+<key> is one of:
+
+`
+
+const debugHelpFooter = `
+<value> is key-specific.
+
+Key "checkptr" supports values:
+       "0": instrumentation disabled
+       "1": conversions involving unsafe.Pointer are instrumented
+       "2": conversions to unsafe.Pointer force heap allocation
+
+Key "pctab" supports values:
+       "pctospadj", "pctofile", "pctoline", "pctoinline", "pctopcdata"
+`
index 48d78f6cd7d2a913c2976da33a5c26f632557ada..edde7a4cc530c632d3e4d20b30f1f255404951df 100644 (file)
@@ -26,7 +26,7 @@ type varPos struct {
 func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls {
        var inlcalls dwarf.InlCalls
 
-       if Debug_gendwarfinl != 0 {
+       if Debug.DwarfInl != 0 {
                Ctxt.Logf("assembling DWARF inlined routine info for %v\n", fnsym.Name)
        }
 
@@ -181,7 +181,7 @@ func assembleInlines(fnsym *obj.LSym, dwVars []*dwarf.Var) dwarf.InlCalls {
        }
 
        // Debugging
-       if Debug_gendwarfinl != 0 {
+       if Debug.DwarfInl != 0 {
                dumpInlCalls(inlcalls)
                dumpInlVars(dwVars)
        }
@@ -210,7 +210,7 @@ func genAbstractFunc(fn *obj.LSym) {
                Ctxt.Diag("failed to locate precursor fn for %v", fn)
                return
        }
-       if Debug_gendwarfinl != 0 {
+       if Debug.DwarfInl != 0 {
                Ctxt.Logf("DwarfAbstractFunc(%v)\n", fn.Name)
        }
        Ctxt.DwarfAbstractFunc(ifn, fn, Ctxt.Pkgpath)
index edd270323896cf3086297b776ef76cf050073535..48f77fa18293ea739371012da02d7b33b2b20ee4 100644 (file)
@@ -12,13 +12,9 @@ import (
        "go/constant"
 )
 
-var (
-       Debug_export int // if set, print debugging information about export data
-)
-
 func exportf(bout *bio.Writer, format string, args ...interface{}) {
        fmt.Fprintf(bout, format, args...)
-       if Debug_export != 0 {
+       if Debug.Export != 0 {
                fmt.Printf(format, args...)
        }
 }
@@ -71,7 +67,7 @@ func dumpexport(bout *bio.Writer) {
        size := bout.Offset() - off
        exportf(bout, "\n$$\n")
 
-       if Debug_export != 0 {
+       if Debug.Export != 0 {
                fmt.Printf("BenchmarkExportSize:%s 1 %d bytes\n", Ctxt.Pkgpath, size)
        }
 }
index 090287ef6283576d2f240c7ecac0348d273b0fca..06b0a88ba350af3319206bf103338b20c120b5ae 100644 (file)
@@ -13,10 +13,9 @@ import (
        "os"
        "reflect"
        "runtime"
-       "strconv"
+
        "strings"
 
-       "cmd/compile/internal/ssa"
        "cmd/internal/objabi"
        "cmd/internal/sys"
 )
@@ -209,7 +208,7 @@ func ParseFlags() {
        }
        if Flag.Race || Flag.MSan {
                // -race and -msan imply -d=checkptr for now.
-               Debug_checkptr = 1
+               Debug.Checkptr = 1
        }
 
        if Flag.CompilingRuntime && Flag.N != 0 {
@@ -222,89 +221,18 @@ func ParseFlags() {
                log.Fatalf("cannot use concurrent backend compilation with provided flags; invoked as %v", os.Args)
        }
 
-       // parse -d argument
-       if Flag.LowerD != "" {
-       Split:
-               for _, name := range strings.Split(Flag.LowerD, ",") {
-                       if name == "" {
-                               continue
-                       }
-                       // display help about the -d option itself and quit
-                       if name == "help" {
-                               fmt.Print(debugHelpHeader)
-                               maxLen := len("ssa/help")
-                               for _, t := range debugtab {
-                                       if len(t.name) > maxLen {
-                                               maxLen = len(t.name)
-                                       }
-                               }
-                               for _, t := range debugtab {
-                                       fmt.Printf("\t%-*s\t%s\n", maxLen, t.name, t.help)
-                               }
-                               // ssa options have their own help
-                               fmt.Printf("\t%-*s\t%s\n", maxLen, "ssa/help", "print help about SSA debugging")
-                               fmt.Print(debugHelpFooter)
-                               os.Exit(0)
-                       }
-                       val, valstring, haveInt := 1, "", true
-                       if i := strings.IndexAny(name, "=:"); i >= 0 {
-                               var err error
-                               name, valstring = name[:i], name[i+1:]
-                               val, err = strconv.Atoi(valstring)
-                               if err != nil {
-                                       val, haveInt = 1, false
-                               }
-                       }
-                       for _, t := range debugtab {
-                               if t.name != name {
-                                       continue
-                               }
-                               switch vp := t.val.(type) {
-                               case nil:
-                                       // Ignore
-                               case *string:
-                                       *vp = valstring
-                               case *int:
-                                       if !haveInt {
-                                               log.Fatalf("invalid debug value %v", name)
-                                       }
-                                       *vp = val
-                               default:
-                                       panic("bad debugtab type")
-                               }
-                               continue Split
-                       }
-                       // special case for ssa for now
-                       if strings.HasPrefix(name, "ssa/") {
-                               // expect form ssa/phase/flag
-                               // e.g. -d=ssa/generic_cse/time
-                               // _ in phase name also matches space
-                               phase := name[4:]
-                               flag := "debug" // default flag is debug
-                               if i := strings.Index(phase, "/"); i >= 0 {
-                                       flag = phase[i+1:]
-                                       phase = phase[:i]
-                               }
-                               err := ssa.PhaseOption(phase, flag, val, valstring)
-                               if err != "" {
-                                       log.Fatalf(err)
-                               }
-                               continue Split
-                       }
-                       log.Fatalf("unknown debug key -d %s\n", name)
-               }
-       }
+       parseDebug()
 
        if Flag.CompilingRuntime {
                // Runtime can't use -d=checkptr, at least not yet.
-               Debug_checkptr = 0
+               Debug.Checkptr = 0
 
                // Fuzzing the runtime isn't interesting either.
-               Debug_libfuzzer = 0
+               Debug.Libfuzzer = 0
        }
 
        // set via a -d flag
-       Ctxt.Debugpcln = Debug_pctab
+       Ctxt.Debugpcln = Debug.PCTab
 }
 
 // registerFlags adds flag registrations for all the fields in Flag.
index f995d2e2ec40830117493279162e9ae1633e8f97..51e139e3190b8f4328c9c6f98202430a7d3b70fc 100644 (file)
@@ -339,14 +339,14 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) {
        short := flag&FmtShort != 0
 
        // Useful to see which nodes in an AST printout are actually identical
-       if Debug_dumpptrs != 0 {
+       if Debug.DumpPtrs != 0 {
                fmt.Fprintf(s, " p(%p)", n)
        }
        if !short && n.Name != nil && n.Name.Vargen != 0 {
                fmt.Fprintf(s, " g(%d)", n.Name.Vargen)
        }
 
-       if Debug_dumpptrs != 0 && !short && n.Name != nil && n.Name.Defn != nil {
+       if Debug.DumpPtrs != 0 && !short && 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 6cab03d7265b101bc8d822a702a4ebb58a7c42b7..947dae476b11990f384a9bd292d25208cf4015e9 100644 (file)
@@ -101,9 +101,6 @@ var pragcgobuf [][]string
 
 var decldepth int32
 
-var Debug_checknil int
-var Debug_typeassert int
-
 var localpkg *types.Pkg // package being compiled
 
 var inimport bool // set during import
@@ -189,8 +186,6 @@ var Ctxt *obj.Link
 
 var nodfp *Node
 
-var disable_checknil int
-
 var autogeneratedPos src.XPos
 
 // interface to back end
index 50091e9c111f3daf9e87073183d0c1fb28dcb6d4..fc467dd95aaf70555fbadec2d9fc8d8a9b33941b 100644 (file)
@@ -86,7 +86,7 @@ func typecheckinl(fn *Node) {
                return // typecheckinl on local function
        }
 
-       if Flag.LowerM > 2 || Debug_export != 0 {
+       if Flag.LowerM > 2 || Debug.Export != 0 {
                fmt.Printf("typecheck import [%v] %L { %#v }\n", fn.Sym, fn, asNodes(fn.Func.Inl.Body))
        }
 
@@ -144,7 +144,7 @@ func caninl(fn *Node) {
        }
 
        // If marked "go:nocheckptr" and -d checkptr compilation, don't inline.
-       if Debug_checkptr != 0 && fn.Func.Pragma&NoCheckPtr != 0 {
+       if Debug.Checkptr != 0 && fn.Func.Pragma&NoCheckPtr != 0 {
                reason = "marked go:nocheckptr"
                return
        }
@@ -595,7 +595,7 @@ func inlnode(n *Node, maxCost int32, inlMap map[*Node]bool) *Node {
        case OCALLMETH:
                // Prevent inlining some reflect.Value methods when using checkptr,
                // even when package reflect was compiled without it (#35073).
-               if s := n.Left.Sym; Debug_checkptr != 0 && isReflectPkg(s.Pkg) && (s.Name == "Value.UnsafeAddr" || s.Name == "Value.Pointer") {
+               if s := n.Left.Sym; Debug.Checkptr != 0 && isReflectPkg(s.Pkg) && (s.Name == "Value.UnsafeAddr" || s.Name == "Value.Pointer") {
                        return n
                }
        }
@@ -931,7 +931,7 @@ func mkinlcall(n, fn *Node, maxCost int32, inlMap map[*Node]bool) *Node {
        defer func() {
                inlMap[fn] = false
        }()
-       if Debug_typecheckinl == 0 {
+       if Debug.TypecheckInl == 0 {
                typecheckinl(fn)
        }
 
index 9cf988bca8ea67b5e591e557ffe3568d4966ae6d..0d41f81a52b1483d67032e96c2829596c0241a0f 100644 (file)
@@ -34,79 +34,8 @@ import (
        "strings"
 )
 
-var (
-       Debug_append       int
-       Debug_checkptr     int
-       Debug_closure      int
-       Debug_compilelater int
-       debug_dclstack     int
-       Debug_dumpptrs     int
-       Debug_libfuzzer    int
-       Debug_panic        int
-       Debug_slice        int
-       Debug_wb           int
-       Debug_pctab        string
-       Debug_locationlist int
-       Debug_typecheckinl int
-       Debug_gendwarfinl  int
-       Debug_softfloat    int
-       Debug_defer        int
-)
-
-// Debug arguments.
-// These can be specified with the -d flag, as in "-d nil"
-// to set the debug_checknil variable.
-// Multiple options can be comma-separated.
-// Each option accepts an optional argument, as in "gcprog=2"
-var debugtab = []struct {
-       name string
-       help string
-       val  interface{} // must be *int or *string
-}{
-       {"append", "print information about append compilation", &Debug_append},
-       {"checkptr", "instrument unsafe pointer conversions", &Debug_checkptr},
-       {"closure", "print information about closure compilation", &Debug_closure},
-       {"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},
-       {"panic", "do not hide any compiler panic", &Debug_panic},
-       {"slice", "print information about slice compilation", &Debug_slice},
-       {"typeassert", "print information about type assertion inlining", &Debug_typeassert},
-       {"wb", "print information about write barriers", &Debug_wb},
-       {"export", "print export data", &Debug_export},
-       {"pctab", "print named pc-value table", &Debug_pctab},
-       {"locationlists", "print information about DWARF location list creation", &Debug_locationlist},
-       {"typecheckinl", "eager typechecking of inline function bodies", &Debug_typecheckinl},
-       {"dwarfinl", "print information about DWARF inlined function creation", &Debug_gendwarfinl},
-       {"softfloat", "force compiler to emit soft-float code", &Debug_softfloat},
-       {"defer", "print information about defer compilation", &Debug_defer},
-       {"fieldtrack", "enable fieldtracking", &objabi.Fieldtrack_enabled},
-}
-
-const debugHelpHeader = `usage: -d arg[,arg]* and arg is <key>[=<value>]
-
-<key> is one of:
-
-`
-
-const debugHelpFooter = `
-<value> is key-specific.
-
-Key "checkptr" supports values:
-       "0": instrumentation disabled
-       "1": conversions involving unsafe.Pointer are instrumented
-       "2": conversions to unsafe.Pointer force heap allocation
-
-Key "pctab" supports values:
-       "pctospadj", "pctofile", "pctoline", "pctoinline", "pctopcdata"
-`
-
 func hidePanic() {
-       if Debug_panic == 0 && Errors() > 0 {
+       if Debug.Panic == 0 && Errors() > 0 {
                // If we've already complained about things
                // in the program, don't bother complaining
                // about a panic too; let the user clean up
@@ -243,9 +172,9 @@ func Main(archInit func(*Arch)) {
                instrumenting = true
        }
        if Flag.Dwarf {
-               dwarf.EnableLogging(Debug_gendwarfinl != 0)
+               dwarf.EnableLogging(Debug.DwarfInl != 0)
        }
-       if Debug_softfloat != 0 {
+       if Debug.SoftFloat != 0 {
                thearch.SoftFloat = true
        }
 
@@ -396,7 +325,7 @@ func Main(archInit func(*Arch)) {
 
        // Phase 5: Inlining
        timings.Start("fe", "inlining")
-       if Debug_typecheckinl != 0 {
+       if Debug.TypecheckInl != 0 {
                // Typecheck imported function bodies if Debug.l > 1,
                // otherwise lazily when used or re-exported.
                for _, n := range importlist {
@@ -501,7 +430,7 @@ func Main(archInit func(*Arch)) {
        // DWARF inlining gen so as to avoid problems with generated
        // method wrappers.
        if Ctxt.DwFixups != nil {
-               Ctxt.DwFixups.Finalize(Ctxt.Pkgpath, Debug_gendwarfinl != 0)
+               Ctxt.DwFixups.Finalize(Ctxt.Pkgpath, Debug.DwarfInl != 0)
                Ctxt.DwFixups = nil
                Flag.GenDwarfInl = 0
        }
@@ -944,7 +873,7 @@ func importfile(f constant.Value) *types.Pkg {
                return nil
 
        case 'B':
-               if Debug_export != 0 {
+               if Debug.Export != 0 {
                        fmt.Printf("importing %s (%s)\n", path_, file)
                }
                imp.ReadByte() // skip \n after $$B
index ee0c8f2711084dde821a123a199252bd42627c81..90c08b1b7503e9c6e2005edaf560c66d68d8c0f1 100644 (file)
@@ -384,7 +384,7 @@ func orderMakeSliceCopy(s []*Node) {
 
 // edge inserts coverage instrumentation for libfuzzer.
 func (o *Order) edge() {
-       if Debug_libfuzzer == 0 {
+       if Debug.Libfuzzer == 0 {
                return
        }
 
@@ -998,7 +998,7 @@ func (o *Order) stmt(n *Node) {
        // For now just clean all the temporaries at the end.
        // In practice that's fine.
        case OSWITCH:
-               if Debug_libfuzzer != 0 && !hasDefaultCase(n) {
+               if Debug.Libfuzzer != 0 && !hasDefaultCase(n) {
                        // Add empty "default:" case for instrumentation.
                        n.List.Append(nod(OCASE, nil, nil))
                }
index fe13a161bd508d17bc800de3eae9d3bc70317b09..19a24a3235eb57114976b71aea625ab837c445d9 100644 (file)
@@ -291,7 +291,7 @@ func compilenow(fn *Node) bool {
        if fn.IsMethod() && isInlinableButNotInlined(fn) {
                return false
        }
-       return Flag.LowerC == 1 && Debug_compilelater == 0
+       return Flag.LowerC == 1 && Debug.CompileLater == 0
 }
 
 // isInlinableButNotInlined returns true if 'fn' was marked as an
index 6b5f670812e9c92a4f31c208b9940299f4e81298..345f433fe40245b66c7301a17ed880205dff1941 100644 (file)
@@ -208,7 +208,7 @@ func Fatalf(format string, args ...interface{}) {
 func FatalfAt(pos src.XPos, format string, args ...interface{}) {
        flusherrors()
 
-       if Debug_panic != 0 || numErrors == 0 {
+       if Debug.Panic != 0 || numErrors == 0 {
                fmt.Printf("%v: internal compiler error: ", linestr(pos))
                fmt.Printf(format, args...)
                fmt.Printf("\n")
index 674a3bf3fbae3a56b42140b6bffee10b35e9be2b..11ccc15a253fadba4e70ebd3a33fe8a3737d7d17 100644 (file)
@@ -1787,13 +1787,11 @@ type GCProg struct {
        w      gcprog.Writer
 }
 
-var Debug_gcprog int // set by -d gcprog
-
 func (p *GCProg) init(lsym *obj.LSym) {
        p.lsym = lsym
        p.symoff = 4 // first 4 bytes hold program length
        p.w.Init(p.writeByte)
-       if Debug_gcprog > 0 {
+       if Debug.GCProg > 0 {
                fmt.Fprintf(os.Stderr, "compile: start GCProg for %v\n", lsym)
                p.w.Debug(os.Stderr)
        }
@@ -1807,7 +1805,7 @@ func (p *GCProg) end() {
        p.w.End()
        duint32(p.lsym, 0, uint32(p.symoff-4))
        ggloblsym(p.lsym, int32(p.symoff), obj.DUPOK|obj.RODATA|obj.LOCAL)
-       if Debug_gcprog > 0 {
+       if Debug.GCProg > 0 {
                fmt.Fprintf(os.Stderr, "compile: end GCProg for %v\n", p.lsym)
        }
 }
index 741e0ef9a3a5eeb678aecb7d491413e0d3c8efc2..1f89baa3c01222dcff09c0153a74f0bc42a18755 100644 (file)
@@ -256,7 +256,7 @@ func (s *InitSchedule) staticassign(l *Node, r *Node) bool {
 
        case OCLOSURE:
                if hasemptycvars(r) {
-                       if Debug_closure > 0 {
+                       if Debug.Closure > 0 {
                                Warnl(r.Pos, "closure converted to global")
                        }
                        // Closures with no captured variables are globals,
index 260df2f54f1421b9e351ba4de37a54e4e1ed7ad8..f06f08e6ab6d973667fb52e1153117ee7f92600e 100644 (file)
@@ -1102,7 +1102,7 @@ func (s *state) stmt(n *Node) {
                        }
                }
        case ODEFER:
-               if Debug_defer > 0 {
+               if Debug.Defer > 0 {
                        var defertype string
                        if s.hasOpenDefers {
                                defertype = "open-coded"
@@ -1232,12 +1232,12 @@ func (s *state) stmt(n *Node) {
                                // so there will be no write barriers,
                                // so there's no need to attempt to prevent them.
                                if s.canSSA(n.Left) {
-                                       if Debug_append > 0 { // replicating old diagnostic message
+                                       if Debug.Append > 0 { // replicating old diagnostic message
                                                Warnl(n.Pos, "append: len-only update (in local slice)")
                                        }
                                        break
                                }
-                               if Debug_append > 0 {
+                               if Debug.Append > 0 {
                                        Warnl(n.Pos, "append: len-only update")
                                }
                                s.append(rhs, true)
@@ -5026,7 +5026,7 @@ func (s *state) exprPtr(n *Node, bounded bool, lineno src.XPos) *ssa.Value {
 // Used only for automatically inserted nil checks,
 // not for user code like 'x != nil'.
 func (s *state) nilCheck(ptr *ssa.Value) {
-       if disable_checknil != 0 || s.curfn.Func.NilCheckDisabled() {
+       if Debug.DisableNil != 0 || s.curfn.Func.NilCheckDisabled() {
                return
        }
        s.newValue2(ssa.OpNilCheck, types.TypeVoid, ptr, s.mem())
@@ -5837,7 +5837,7 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) {
                if n.Type.IsEmptyInterface() {
                        // Converting to an empty interface.
                        // Input could be an empty or nonempty interface.
-                       if Debug_typeassert > 0 {
+                       if Debug.TypeAssert > 0 {
                                Warnl(n.Pos, "type assertion inlined")
                        }
 
@@ -5904,7 +5904,7 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) {
                        return
                }
                // converting to a nonempty interface needs a runtime call.
-               if Debug_typeassert > 0 {
+               if Debug.TypeAssert > 0 {
                        Warnl(n.Pos, "type assertion not inlined")
                }
                if n.Left.Type.IsEmptyInterface() {
@@ -5921,14 +5921,14 @@ func (s *state) dottype(n *Node, commaok bool) (res, resok *ssa.Value) {
                return s.rtcall(assertI2I, true, []*types.Type{n.Type}, target, iface)[0], nil
        }
 
-       if Debug_typeassert > 0 {
+       if Debug.TypeAssert > 0 {
                Warnl(n.Pos, "type assertion inlined")
        }
 
        // Converting to a concrete type.
        direct := isdirectiface(n.Type)
        itab := s.newValue1(ssa.OpITab, byteptr, iface) // type word of interface
-       if Debug_typeassert > 0 {
+       if Debug.TypeAssert > 0 {
                Warnl(n.Pos, "type assertion inlined")
        }
        var targetITab *ssa.Value
@@ -6474,7 +6474,7 @@ func genssa(f *ssa.Func, pp *Progs) {
        }
 
        if Ctxt.Flag_locationlists {
-               e.curfn.Func.DebugInfo = ssa.BuildFuncDebug(Ctxt, f, Debug_locationlist > 1, stackOffset)
+               e.curfn.Func.DebugInfo = ssa.BuildFuncDebug(Ctxt, f, Debug.LocationLists > 1, stackOffset)
                bstart := s.bstart
                // Note that at this moment, Prog.Pc is a sequence number; it's
                // not a real PC until after assembly, so this mapping has to
@@ -7113,7 +7113,7 @@ func (e *ssafn) Warnl(pos src.XPos, fmt_ string, args ...interface{}) {
 }
 
 func (e *ssafn) Debug_checknil() bool {
-       return Debug_checknil != 0
+       return Debug.Nil != 0
 }
 
 func (e *ssafn) UseWriteBarrier() bool {
index 32312e9545aeb1aa66d50a4c4046419967c4669a..989d10a561d0de893b57dbcdd340343e812f7d69 100644 (file)
@@ -1412,7 +1412,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym) {
        }
 
        funcbody()
-       if debug_dclstack != 0 {
+       if Debug.DclStack != 0 {
                testdclstack()
        }
 
index 75a7ae2c7af7c25106f16f3b0beaad5ae9fbaf4b..f771a7184ea47b25e6c2da5c503f3af7d9d16118 100644 (file)
@@ -764,7 +764,7 @@ func (f *Func) SetInstrumentBody(b bool)           { f.flags.set(funcInstrumentB
 func (f *Func) SetOpenCodedDeferDisallowed(b bool) { f.flags.set(funcOpenCodedDeferDisallowed, b) }
 
 func (f *Func) setWBPos(pos src.XPos) {
-       if Debug_wb != 0 {
+       if Debug.WB != 0 {
                Warnl(pos, "write barrier")
        }
        if !f.WBPos.IsKnown() {
index c2d8411a596e9707c125be5846f3067622a921ef..de2733909e3e8a00e13031539b27ad724d540b3e 100644 (file)
@@ -1685,7 +1685,7 @@ func reduceSlice(n *Node) *Node {
        n.SetSliceBounds(low, high, max)
        if (n.Op == OSLICE || n.Op == OSLICESTR) && low == nil && high == nil {
                // Reduce x[:] to x.
-               if Debug_slice > 0 {
+               if Debug.Slice > 0 {
                        Warn("slice: omit slice operation")
                }
                return n.Left
@@ -3262,7 +3262,7 @@ func walkcompare(n *Node, init *Nodes) *Node {
 
        switch t.Etype {
        default:
-               if Debug_libfuzzer != 0 && t.IsInteger() {
+               if Debug.Libfuzzer != 0 && t.IsInteger() {
                        n.Left = cheapexpr(n.Left, init)
                        n.Right = cheapexpr(n.Right, init)
 
@@ -4087,5 +4087,5 @@ func walkCheckPtrArithmetic(n *Node, init *Nodes) *Node {
 // function fn at a given level. See debugHelpFooter for defined
 // levels.
 func checkPtr(fn *Node, level int) bool {
-       return Debug_checkptr >= level && fn.Func.Pragma&NoCheckPtr == 0
+       return Debug.Checkptr >= level && fn.Func.Pragma&NoCheckPtr == 0
 }
index 9d11c6bf53ae78652fa7fadf2eedff4943dcc385..1d2e2c79e6ea91d193e05fc936e029f8a44110c2 100644 (file)
@@ -766,7 +766,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
        case ssa.OpMIPSFPFlagTrue,
index 2727c4d8a8340b6481f972a277f98844c9067623..067b8158c939f31c4c44d368a828670b222adb34 100644 (file)
@@ -724,7 +724,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
        case ssa.OpMIPS64FPFlagTrue,
index 3e20c44a4c72b61d9514ec4b977c43d7c6784544..f0e7c4192336ffc2250dbd0be18a44b6713b965e 100644 (file)
@@ -1852,7 +1852,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
 
index 0beb5b4bd180a2460fb69e57311416a9b391202f..d49927ee04e93bfad91fa1311ebe8247feb972e4 100644 (file)
@@ -586,7 +586,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                gc.AddAux(&p.From, v)
                p.To.Type = obj.TYPE_REG
                p.To.Reg = riscv.REG_ZERO
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos == 1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos == 1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
 
index 8037357131c79fac0f6ee350a398d994fa5fcaed..cb13f8d3c0d2890f086f06906700c73c855bbc64 100644 (file)
@@ -642,7 +642,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
        case ssa.OpS390XMVC:
index a36fbca4e02bdc677e128c2c9497416e7e10005d..3f05515b9a6e539006bbc3662fbcecd3e6433947 100644 (file)
@@ -165,7 +165,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
 
index fbf76d0c5efb979e37dab6666008708b26a36fcb..65d7e75a533c204c06c7b418bb4ea8b491900e30 100644 (file)
@@ -850,7 +850,7 @@ func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
                if logopt.Enabled() {
                        logopt.LogOpt(v.Pos, "nilcheck", "genssa", v.Block.Func.Name)
                }
-               if gc.Debug_checknil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
+               if gc.Debug.Nil != 0 && v.Pos.Line() > 1 { // v.Pos.Line()==1 in generated wrappers
                        gc.Warnl(v.Pos, "generated nil check")
                }
        case ssa.OpClobber: