]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: debug trace output for -N variable location gen
authorThan McIntosh <thanm@google.com>
Wed, 5 May 2021 00:38:24 +0000 (20:38 -0400)
committerThan McIntosh <thanm@google.com>
Wed, 5 May 2021 01:48:39 +0000 (01:48 +0000)
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>
src/cmd/compile/internal/ssa/debug.go

index 2f379c9e2c4e2e975030e949872e30a9222b4be3..0ca435e515790cd799118628030ff5b9ebdef321 100644 (file)
@@ -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))