Skip to content

Commit 4781364

Browse files
committed
pkg/symbolizer: retain the frame if line number is 0
There are numerous line_entries with a line number of 0 for __sanitizer_cov_trace_pc. Currently, if only one program counter (PC) is hit in the function and the line number is 0 for that PC, the frame is ignored. To accurately report function coverage, we should include the function in such cases.
1 parent c38226e commit 4781364

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pkg/symbolizer/addr2line.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,12 @@ func parse(interner *Interner, s *bufio.Scanner) ([]Frame, error) {
163163
}
164164
file := ln[:colon]
165165
line, err := strconv.Atoi(ln[colon+1 : lineEnd])
166-
if err != nil || fn == "" || fn == "??" || file == "" || file == "??" || line <= 0 {
166+
if err != nil || fn == "" || fn == "??" || file == "" || file == "??" || line < 0 {
167167
continue
168168
}
169+
if line == 0 {
170+
line = -1
171+
}
169172
frames = append(frames, Frame{
170173
PC: pc,
171174
Func: interner.Do(fn),

pkg/symbolizer/addr2line_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ func TestParse(t *testing.T) {
7272
},
7373
},
7474
},
75+
{
76+
0xffffffff82fdbe1b,
77+
"0xffffffff82fdbe1b\n" +
78+
"fbcon_invert_region\n" +
79+
"drivers/video/console/fbcon.c:0\n",
80+
[]Frame{
81+
{
82+
PC: 0xffffffff82fdbe1b,
83+
Func: "fbcon_invert_region",
84+
File: "drivers/video/console/fbcon.c",
85+
Line: -1,
86+
Inline: false,
87+
},
88+
},
89+
},
7590
{
7691
0x123124,
7792
"0x0000000000123124\n" +

0 commit comments

Comments
 (0)