提交 0e0d6892 编写于 作者: A aarzilli 提交者: Derek Parker

dwarf/line: make LineToPCIn behave like LineToPC for lines without stmt

When a line has instructions associated but none of them have is_stmt
set LineToPC and LineToPCIn should behave in the same way.

Fixes #1817
上级 c5f9a03d
package main
import (
"fmt"
"runtime"
"unsafe"
)
func main() {
l := int(51)
bs := make([]byte, l)
for i := 0; i < l; i++ {
bs[i] = byte(i + int(10))
}
p := uintptr(unsafe.Pointer(&bs))
fmt.Println(p)
bs[0] = 254
runtime.KeepAlive(bs)
}
......@@ -313,13 +313,19 @@ func (lineInfo *DebugLineInfo) LineToPCIn(filename string, lineno int, basePC, s
sm := lineInfo.stateMachineFor(basePC, startPC)
var fallbackPC uint64
for {
if sm.valid && sm.started {
if sm.address >= endPC {
return 0
break
}
if sm.line == lineno && sm.file == filename && sm.address >= startPC && sm.isStmt {
return sm.address
if sm.line == lineno && sm.file == filename && sm.address >= startPC {
if sm.isStmt {
return sm.address
} else {
fallbackPC = sm.address
}
}
}
if err := sm.next(); err != nil {
......@@ -331,7 +337,7 @@ func (lineInfo *DebugLineInfo) LineToPCIn(filename string, lineno int, basePC, s
}
return 0
return fallbackPC
}
// PrologueEndPC returns the first PC address marked as prologue_end in the half open interval [start, end)
......
......@@ -199,7 +199,7 @@ func setFileBreakpoint(p proc.Process, t *testing.T, path string, lineno int) *p
t.Fatalf("%s:%d: FindFileLocation(%s, %d): %v", f, l, path, lineno, err)
}
if len(addrs) != 1 {
t.Fatalf("%s:%d: setFileLineBreakpoint(%s, %d): too many results %v", f, l, path, lineno, addrs)
t.Fatalf("%s:%d: setFileLineBreakpoint(%s, %d): too many (or not enough) results %v", f, l, path, lineno, addrs)
}
bp, err := p.SetBreakpoint(addrs[0], proc.UserBreakpoint, nil)
if err != nil {
......@@ -4517,3 +4517,11 @@ func TestIssue1736(t *testing.T) {
}
})
}
func TestIssue1817(t *testing.T) {
// Setting a breakpoint on a line that doesn't have any PC addresses marked
// is_stmt should work.
withTestProcess("issue1817", t, func(p proc.Process, fixture protest.Fixture) {
setFileBreakpoint(p, t, fixture.Source, 16)
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册