mirror of
https://github.com/golang/go
synced 2024-11-24 01:00:15 -07:00
cmd/compile: make GOSSAHASH package-sensitive, also append to log files
Turns out if your failure is in a function with a name like "Reset()" there will be a lot of hits on the same hashcode. Adding package sensitivity solves this problem. In additionm, it turned out that in the case that a logfile was specified for the GOSSAHASH logging, that it was opened in create mode, which meant that multiple compiler invocations would reset the file to zero length. Opening in append mode works better; the automated harness (github.com/dr2chase/gossahash) takes care of truncating the file before use. Change-Id: I5601bc280faa94cbd507d302448831849db6c842 Reviewed-on: https://go-review.googlesource.com/c/go/+/246937 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
c0602603b2
commit
4220d67084
@ -329,8 +329,8 @@ func buildssa(fn *Node, worker int) *ssa.Func {
|
|||||||
s.f.Config = ssaConfig
|
s.f.Config = ssaConfig
|
||||||
s.f.Cache = &ssaCaches[worker]
|
s.f.Cache = &ssaCaches[worker]
|
||||||
s.f.Cache.Reset()
|
s.f.Cache.Reset()
|
||||||
s.f.DebugTest = s.f.DebugHashMatch("GOSSAHASH", name)
|
|
||||||
s.f.Name = name
|
s.f.Name = name
|
||||||
|
s.f.DebugTest = s.f.DebugHashMatch("GOSSAHASH")
|
||||||
s.f.PrintOrHtmlSSA = printssa
|
s.f.PrintOrHtmlSSA = printssa
|
||||||
if fn.Func.Pragma&Nosplit != 0 {
|
if fn.Func.Pragma&Nosplit != 0 {
|
||||||
s.f.NoSplit = true
|
s.f.NoSplit = true
|
||||||
@ -6863,6 +6863,10 @@ func (e *ssafn) SetWBPos(pos src.XPos) {
|
|||||||
e.curfn.Func.setWBPos(pos)
|
e.curfn.Func.setWBPos(pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e *ssafn) MyImportPath() string {
|
||||||
|
return myimportpath
|
||||||
|
}
|
||||||
|
|
||||||
func (n *Node) Typ() *types.Type {
|
func (n *Node) Typ() *types.Type {
|
||||||
return n.Type
|
return n.Type
|
||||||
}
|
}
|
||||||
|
@ -173,6 +173,9 @@ type Frontend interface {
|
|||||||
// SetWBPos indicates that a write barrier has been inserted
|
// SetWBPos indicates that a write barrier has been inserted
|
||||||
// in this function at position pos.
|
// in this function at position pos.
|
||||||
SetWBPos(pos src.XPos)
|
SetWBPos(pos src.XPos)
|
||||||
|
|
||||||
|
// MyImportPath provides the import name (roughly, the package) for the function being compiled.
|
||||||
|
MyImportPath() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// interface used to hold a *gc.Node (a stack variable).
|
// interface used to hold a *gc.Node (a stack variable).
|
||||||
|
@ -146,6 +146,10 @@ func (d DummyFrontend) Fatalf(_ src.XPos, msg string, args ...interface{}) { d.t
|
|||||||
func (d DummyFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.Logf(msg, args...) }
|
func (d DummyFrontend) Warnl(_ src.XPos, msg string, args ...interface{}) { d.t.Logf(msg, args...) }
|
||||||
func (d DummyFrontend) Debug_checknil() bool { return false }
|
func (d DummyFrontend) Debug_checknil() bool { return false }
|
||||||
|
|
||||||
|
func (d DummyFrontend) MyImportPath() string {
|
||||||
|
return "my/import/path"
|
||||||
|
}
|
||||||
|
|
||||||
var dummyTypes Types
|
var dummyTypes Types
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -678,7 +678,8 @@ func (f *Func) invalidateCFG() {
|
|||||||
// GSHS_LOGFILE
|
// GSHS_LOGFILE
|
||||||
// or standard out if that is empty or there is an error
|
// or standard out if that is empty or there is an error
|
||||||
// opening the file.
|
// opening the file.
|
||||||
func (f *Func) DebugHashMatch(evname, name string) bool {
|
func (f *Func) DebugHashMatch(evname string) bool {
|
||||||
|
name := f.fe.MyImportPath() + "." + f.Name
|
||||||
evhash := os.Getenv(evname)
|
evhash := os.Getenv(evname)
|
||||||
switch evhash {
|
switch evhash {
|
||||||
case "":
|
case "":
|
||||||
@ -727,7 +728,7 @@ func (f *Func) logDebugHashMatch(evname, name string) {
|
|||||||
file = os.Stdout
|
file = os.Stdout
|
||||||
if tmpfile := os.Getenv("GSHS_LOGFILE"); tmpfile != "" {
|
if tmpfile := os.Getenv("GSHS_LOGFILE"); tmpfile != "" {
|
||||||
var err error
|
var err error
|
||||||
file, err = os.Create(tmpfile)
|
file, err = os.OpenFile(tmpfile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
f.Fatalf("could not open hash-testing logfile %s", tmpfile)
|
f.Fatalf("could not open hash-testing logfile %s", tmpfile)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user