mirror of
https://github.com/golang/go
synced 2024-11-26 07:47:57 -07:00
cmd/compile: debug trace output for -N variable location gen
Add some rudimentary debug trace output for -N location list generation if "-d=ssa/locationlists" is set. Updates #45948. Change-Id: If1a95730538a6e7def7ebe1ece1a71da8e5f0975 Reviewed-on: https://go-review.googlesource.com/c/go/+/317089 Trust: Than McIntosh <thanm@google.com> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
This commit is contained in:
parent
66ce8aa88d
commit
caf4c9434b
@ -1356,6 +1356,12 @@ func BuildFuncDebugNoOptimized(ctxt *obj.Link, f *Func, loggingEnabled bool, sta
|
||||
return &fd
|
||||
}
|
||||
|
||||
state := debugState{f: f}
|
||||
|
||||
if loggingEnabled {
|
||||
state.logf("generating -N reg param loc lists for func %q\n", f.Name)
|
||||
}
|
||||
|
||||
// Allocate location lists.
|
||||
fd.LocationLists = make([][]byte, numRegParams)
|
||||
|
||||
@ -1383,6 +1389,9 @@ func BuildFuncDebugNoOptimized(ctxt *obj.Link, f *Func, loggingEnabled bool, sta
|
||||
// loops such as that in issue 45948. In such cases, leave
|
||||
// the var/slot set up for the param, but don't try to
|
||||
// emit a location list.
|
||||
if loggingEnabled {
|
||||
state.logf("locatePrologEnd failed, skipping %v\n", n)
|
||||
}
|
||||
pidx++
|
||||
continue
|
||||
}
|
||||
@ -1396,6 +1405,9 @@ func BuildFuncDebugNoOptimized(ctxt *obj.Link, f *Func, loggingEnabled bool, sta
|
||||
pidx++
|
||||
continue
|
||||
}
|
||||
if loggingEnabled {
|
||||
state.logf("param %v:\n [<entry>, %d]:\n", n, afterPrologVal)
|
||||
}
|
||||
rtypes, _ := inp.RegisterTypesAndOffsets()
|
||||
padding := make([]uint64, 0, 32)
|
||||
padding = inp.ComputePadding(padding)
|
||||
@ -1408,15 +1420,24 @@ func BuildFuncDebugNoOptimized(ctxt *obj.Link, f *Func, loggingEnabled bool, sta
|
||||
list = append(list, dwarf.DW_OP_regx)
|
||||
list = dwarf.AppendUleb128(list, uint64(dwreg))
|
||||
}
|
||||
if loggingEnabled {
|
||||
state.logf(" piece %d -> dwreg %d", k, dwreg)
|
||||
}
|
||||
if len(inp.Registers) > 1 {
|
||||
list = append(list, dwarf.DW_OP_piece)
|
||||
ts := rtypes[k].Width
|
||||
list = dwarf.AppendUleb128(list, uint64(ts))
|
||||
if padding[k] > 0 {
|
||||
if loggingEnabled {
|
||||
state.logf(" [pad %d bytes]", padding[k])
|
||||
}
|
||||
list = append(list, dwarf.DW_OP_piece)
|
||||
list = dwarf.AppendUleb128(list, padding[k])
|
||||
}
|
||||
}
|
||||
if loggingEnabled {
|
||||
state.logf("\n")
|
||||
}
|
||||
}
|
||||
// fill in length of location expression element
|
||||
ctxt.Arch.ByteOrder.PutUint16(list[sizeIdx:], uint16(len(list)-sizeIdx-2))
|
||||
@ -1436,6 +1457,10 @@ func BuildFuncDebugNoOptimized(ctxt *obj.Link, f *Func, loggingEnabled bool, sta
|
||||
list = append(list, dwarf.DW_OP_fbreg)
|
||||
list = dwarf.AppendSleb128(list, int64(soff))
|
||||
}
|
||||
if loggingEnabled {
|
||||
state.logf(" [%d, <end>): stackOffset=%d\n", afterPrologVal, soff)
|
||||
}
|
||||
|
||||
// fill in size
|
||||
ctxt.Arch.ByteOrder.PutUint16(list[sizeIdx:], uint16(len(list)-sizeIdx-2))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user