2020-11-16 01:17:25 -05:00
// 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.
2020-11-16 01:44:47 -05:00
// Debug arguments, set by -d flag.
2020-11-19 20:49:23 -05:00
package base
2020-11-16 01:17:25 -05:00
2020-11-16 01:44:47 -05:00
// Debug holds the parsed debugging configuration values.
2021-03-16 17:06:25 -04:00
var Debug DebugFlags
2020-11-16 01:44:47 -05:00
// DebugFlags defines the debugging configuration values (see var Debug).
// Each struct field is a different value, named for the lower-case of the field name.
// Each field must be an int or string and must have a `help` struct tag.
//
// The -d option takes a comma-separated list of settings.
// Each setting is name=value; for ints, name is short for name=1.
type DebugFlags struct {
2022-11-10 11:33:00 -05:00
Append int ` help:"print information about append compilation" `
Checkptr int ` help:"instrument unsafe pointer conversions\n0: instrumentation disabled\n1: conversions involving unsafe.Pointer are instrumented\n2: conversions to unsafe.Pointer force heap allocation" concurrent:"ok" `
Closure int ` help:"print information about closure compilation" `
Defer int ` help:"print information about defer compilation" `
DisableNil int ` help:"disable nil checks" concurrent:"ok" `
2023-06-29 15:37:26 -04:00
DumpInlFuncProps string ` help:"dump function properties from inl heuristics to specified file" `
2023-07-24 10:58:26 -04:00
DumpInlCallSiteScores int ` help:"dump scored callsites during inlining" `
2023-09-28 14:07:29 -04:00
InlScoreAdj string ` help:"set inliner score adjustments (ex: -d=inlscoreadj=panicPathAdj:10/passConstToNestedIfAdj:-90)" `
InlBudgetSlack int ` help:"amount to expand the initial inline budget when new inliner enabled. Defaults to 80 if option not set." concurrent:"ok" `
2022-11-10 11:33:00 -05:00
DumpPtrs int ` help:"show Node pointers values in dump output" `
DwarfInl int ` help:"print information about DWARF inlined function creation" `
2023-08-17 14:15:04 -07:00
EscapeMutationsCalls int ` help:"print extra escape analysis diagnostics about mutations and calls" concurrent:"ok" `
2022-11-10 11:33:00 -05:00
Export int ` help:"print export data" `
Fmahash string ` help:"hash value for use in debugging platform-dependent multiply-add use" concurrent:"ok" `
GCAdjust int ` help:"log adjustments to GOGC" concurrent:"ok" `
2022-11-02 17:23:47 -04:00
GCCheck int ` help:"check heap/gc use by compiler" concurrent:"ok" `
2022-11-10 11:33:00 -05:00
GCProg int ` help:"print dump of GC programs" `
Gossahash string ` help:"hash value for use in debugging the compiler" `
InlFuncsWithClosures int ` help:"allow functions with closures to be inlined" concurrent:"ok" `
2022-11-22 13:28:51 -05:00
InlStaticInit int ` help:"allow static initialization of inlined calls" concurrent:"ok" `
2022-11-10 11:33:00 -05:00
Libfuzzer int ` help:"enable coverage instrumentation for libfuzzer" `
cmd/compile: experimental loop iterator capture semantics change
Adds:
GOEXPERIMENT=loopvar (expected way of invoking)
-d=loopvar={-1,0,1,2,11,12} (for per-package control and/or logging)
-d=loopvarhash=... (for hash debugging)
loopvar=11,12 are for testing, benchmarking, and debugging.
If enabled,for loops of the form `for x,y := range thing`, if x and/or
y are addressed or captured by a closure, are transformed by renaming
x/y to a temporary and prepending an assignment to the body of the
loop x := tmp_x. This changes the loop semantics by making each
iteration's instance of x be distinct from the others (currently they
are all aliased, and when this matters, it is almost always a bug).
3-range with captured iteration variables are also transformed,
though it is a more complex transformation.
"Optimized" to do a simpler transformation for
3-clause for where the increment is empty.
(Prior optimization of address-taking under Return disabled, because
it was incorrect; returns can have loops for children. Restored in
a later CL.)
Includes support for -d=loopvarhash=<binary string> intended for use
with hash search and GOCOMPILEDEBUG=loopvarhash=<binary string>
(use `gossahash -e loopvarhash command-that-fails`).
Minor feature upgrades to hash-triggered features; clients can specify
that file-position hashes use only the most-inline position, and/or that
they use only the basenames of source files (not the full directory path).
Most-inlined is the right choice for debugging loop-iteration change
once the semantics are linked to the package across inlining; basename-only
makes it tractable to write tests (which, otherwise, depend on the full
pathname of the source file and thus vary).
Updates #57969.
Change-Id: I180a51a3f8d4173f6210c861f10de23de8a1b1db
Reviewed-on: https://go-review.googlesource.com/c/go/+/411904
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-12 15:33:57 -04:00
LoopVar int ` help:"shared (0, default), 1 (private loop variables), 2, private + log" `
LoopVarHash string ` help:"for debugging changes in loop behavior. Overrides experiment and loopvar flag." `
2022-11-10 11:33:00 -05:00
LocationLists int ` help:"print information about DWARF location list creation" `
Nil int ` help:"print information about nil checks" `
NoOpenDefer int ` help:"disable open-coded defers" concurrent:"ok" `
NoRefName int ` help:"do not include referenced symbol names in object file" concurrent:"ok" `
PCTab string ` help:"print named pc-value table\nOne of: pctospadj, pctofile, pctoline, pctoinline, pctopcdata" `
Panic int ` help:"show all compiler panics" `
Reshape int ` help:"print information about expression reshaping" `
Shapify int ` help:"print information about shaping recursive types" `
Slice int ` help:"print information about slice compilation" `
SoftFloat int ` help:"force compiler to emit soft-float code" concurrent:"ok" `
2022-03-24 12:27:39 -07:00
StaticCopy int ` help:"print information about missed static copies" concurrent:"ok" `
2022-11-10 11:33:00 -05:00
SyncFrames int ` help:"how many writer stack frames to include at sync points in unified export data" `
TypeAssert int ` help:"print information about type assertion inlining" `
WB int ` help:"print information about write barriers" `
ABIWrap int ` help:"print information about ABI wrapper generation" `
MayMoreStack string ` help:"call named function before all stack growth checks" concurrent:"ok" `
2023-05-12 15:36:37 -04:00
PGODebug int ` help:"debug profile-guided optimizations" `
2023-09-15 12:13:09 -04:00
PGOHash string ` help:"hash value for debugging profile-guided optimizations" concurrent:"ok" `
2023-05-12 15:36:37 -04:00
PGOInline int ` help:"enable profile-guided inlining" concurrent:"ok" `
2023-03-09 13:20:01 -05:00
PGOInlineCDFThreshold string ` help:"cumulative threshold percentage for determining call sites as hot candidates for inlining" concurrent:"ok" `
2022-11-10 11:33:00 -05:00
PGOInlineBudget int ` help:"inline budget for hot functions" concurrent:"ok" `
2023-11-16 13:00:55 -05:00
PGODevirtualize int ` help:"enable profile-guided devirtualization; 0 to disable, 1 to enable interface devirtualization, 2 to enable function devirtualization" concurrent:"ok" `
2023-11-11 15:32:45 -05:00
RangeFuncCheck int ` help:"insert code to check behavior of range iterator functions" concurrent:"ok" `
2023-03-09 13:20:01 -05:00
WrapGlobalMapDbg int ` help:"debug trace output for global map init wrapping" `
WrapGlobalMapCtl int ` help:"global map init wrap control (0 => default, 1 => off, 2 => stress mode, no size cutoff)" `
2023-08-17 14:15:04 -07:00
ZeroCopy int ` help:"enable zero-copy string->[]byte conversions" concurrent:"ok" `
2020-11-16 01:44:47 -05:00
2022-10-25 23:01:44 -04:00
ConcurrentOk bool // true if only concurrentOk flags seen
2020-11-16 01:17:25 -05:00
}
2020-11-16 01:44:47 -05:00
// DebugSSA is called to set a -d ssa/... option.
// If nil, those options are reported as invalid options.
// If DebugSSA returns a non-empty string, that text is reported as a compiler error.
var DebugSSA func ( phase , flag string , val int , valString string ) string