From e3003213f6deee7f817122847d77b769bc8b46ad Mon Sep 17 00:00:00 2001 From: m0ck1ng Date: Fri, 20 Jun 2025 11:34:25 +0000 Subject: pkg/cover: fix handling of compile unit name The 'attrName' is often an absolute path for out-of-tree modules. This commit avoids redundant path concatenation when 'attrName' is already absolute, enabling developers to view coverage correctly in the web UI. --- CONTRIBUTORS | 1 + pkg/cover/backend/dwarf.go | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f4e93f0d9..0f1a890d6 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -140,3 +140,4 @@ Rivos Inc. Alexandre Ghiti Jeongjun Park Nikita Zhandarovich +Jiacheng Xu diff --git a/pkg/cover/backend/dwarf.go b/pkg/cover/backend/dwarf.go index a5f5e6cda..dc0911a1e 100644 --- a/pkg/cover/backend/dwarf.go +++ b/pkg/cover/backend/dwarf.go @@ -407,8 +407,11 @@ func readTextRanges(debugInfo *dwarf.Data, module *vminfo.KernelModule, pcFix pc } else { // Compile unit names are relative to the compilation dir, // while per-line info isn't. - // Let's stick to the common approach. - unitName := filepath.Join(attrCompDir, attrName) + // attrName could be an absolute path for out-of-tree modules. + unitName := attrName + if !filepath.IsAbs(attrName) { + unitName = filepath.Join(attrCompDir, attrName) + } ranges1, err := debugInfo.Ranges(ent) if err != nil { return nil, nil, err -- cgit mrf-deployment