Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add startline to function when symbolizing elf #3648

Merged
merged 2 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pkg/symbol/addr2line/dwarf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ func TestDwarfSymbolizer(t *testing.T) {
}

require.Equal(t, &metastorev1alpha1.Function{
Name: "top2",
Filename: "src/basic-cpp.cpp",
Name: "top2",
Filename: "src/basic-cpp.cpp",
StartLine: 8,
}, gotLines[0].Function)
}
21 changes: 17 additions & 4 deletions pkg/symbol/elfutils/debuginfofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,19 @@ func (f *debugInfoFile) SourceLines(addr uint64) ([]profile.LocationLine, error)
if !ok {
name = ""
}

declLine, ok := tr.Entry.Val(dwarf.AttrDeclLine).(int64)
if !ok {
declLine = 0
}

file, line := findLineInfo(f.lineEntries[cu.Offset], tr.Ranges)
lines = append(lines, profile.LocationLine{
Line: line,
Function: f.demangler.Demangle(&pb.Function{
Name: name,
Filename: file,
Name: name,
Filename: file,
StartLine: declLine,
}),
})

Expand All @@ -114,12 +121,18 @@ func (f *debugInfoFile) SourceLines(addr uint64) ([]profile.LocationLine, error)
name = getFunctionName(abstractOrigin)
}

declLine, ok := ch.Entry.Val(dwarf.AttrDeclLine).(int64)
if !ok {
declLine = 0
}

file, line := findLineInfo(f.lineEntries[cu.Offset], ch.Ranges)
lines = append(lines, profile.LocationLine{
Line: line,
Function: f.demangler.Demangle(&pb.Function{
Name: name,
Filename: file,
Name: name,
Filename: file,
StartLine: declLine,
}),
})
}
Expand Down
Loading