diff options
| author | m0ck1ng <stitch@zju.edu.cn> | 2025-06-20 11:34:25 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-06-20 11:58:30 +0000 |
| commit | e3003213f6deee7f817122847d77b769bc8b46ad (patch) | |
| tree | b3e9441f88986121fe85978ca5d3356cdcf05aa4 | |
| parent | 804b39197cace4df6f069d31e585d66e9c136a88 (diff) | |
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.
| -rw-r--r-- | CONTRIBUTORS | 1 | ||||
| -rw-r--r-- | 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 |
