Skip to content

Commit 34ffa2e

Browse files
authored
dwarf/line: do not consider end of sequence entries valid (#2235)
This is needed to fix the problem we have with 1.15.4+ after the backport is applied to it. The DWARF standard isn't clear on what should happen with the end_of_sequence opcode but this is consistent with debug/dwarf.LineReader as well as gdb.
1 parent 731f5ed commit 34ffa2e

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

pkg/dwarf/line/line_parser.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type DebugLineInfo struct {
4343
// if normalizeBackslash is true all backslashes (\) will be converted into forward slashes (/)
4444
normalizeBackslash bool
4545
ptrSize int
46+
endSeqIsValid bool
4647
}
4748

4849
type FileEntry struct {

pkg/dwarf/line/state_machine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ func fixedadvancepc(sm *StateMachine, buf *bytes.Buffer) {
543543

544544
func endsequence(sm *StateMachine, buf *bytes.Buffer) {
545545
sm.endSeq = true
546-
sm.valid = true
546+
sm.valid = sm.dbl.endSeqIsValid
547547
}
548548

549549
func setaddress(sm *StateMachine, buf *bytes.Buffer) {

pkg/dwarf/line/state_machine_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func TestGrafana(t *testing.T) {
8080
cuname, _ := e.Val(dwarf.AttrName).(string)
8181

8282
lineInfo := Parse(e.Val(dwarf.AttrCompDir).(string), debugLineBuffer, t.Logf, 0, false, 8)
83+
lineInfo.endSeqIsValid = true
8384
sm := newStateMachine(lineInfo, lineInfo.Instructions, 8)
8485

8586
lnrdr, err := data.LineReader(e)

0 commit comments

Comments
 (0)