}
}
+func TestDebugLinesConvert(t *testing.T) {
+ if runtime.GOOS != "linux" && runtime.GOOS != "darwin" { // in particular, it could be windows.
+ t.Skip("this test depends on creating a file with a wonky name, only works for sure on Linux and Darwin")
+ }
+
+ switch testGoArch() {
+ default:
+ t.Skip("skipped for many architectures")
+
+ case "arm64", "amd64": // register ABI
+ fn := "G[go.shape.int_0]"
+ if buildcfg.Experiment.Unified {
+ // Unified mangles differently
+ fn = "G[int]"
+ }
+ testDebugLines(t, "-N -l -G=3", "convertline.go", fn, []int{9, 10, 11}, true)
+ }
+}
+
func TestInlineLines(t *testing.T) {
if runtime.GOARCH != "amd64" && *testGoArchFlag == "" {
// As of september 2021, works for everything except mips64, but still potentially fragile
// explicit statement boundaries should appear
// in the generated code.
if p.IsStmt() != src.PosIsStmt {
+ if s.pp.Pos.IsStmt() == src.PosIsStmt && s.pp.Pos.SameFileAndLine(p) {
+ // If s.pp.Pos already has a statement mark, then it was set here (below) for
+ // the previous value. If an actual instruction had been emitted for that
+ // value, then the statement mark would have been reset. Since the statement
+ // mark of s.pp.Pos was not reset, this position (file/line) still needs a
+ // statement mark on an instruction. If file and line for this value are
+ // the same as the previous value, then the first instruction for this
+ // value will work to take the statement mark. Return early to avoid
+ // resetting the statement mark.
+ //
+ // The reset of s.pp.Pos occurs in (*Progs).Prog() -- if it emits
+ // an instruction, and the instruction's statement mark was set,
+ // and it is not one of the LosesStmtMark instructions,
+ // then Prog() resets the statement mark on the (*Progs).Pos.
+ return
+ }
p = p.WithNotStmt()
// Calls use the pos attached to v, but copy the statement mark from State
}
for i, b := range f.Blocks {
s.bstart[b.ID] = s.pp.Next
s.lineRunStart = nil
+ s.SetPos(s.pp.Pos.WithNotStmt()) // It needs a non-empty Pos, but cannot be a statement boundary (yet).
// Attach a "default" liveness info. Normally this will be
// overwritten in the Values loop below for each Value. But