From 3eba45d51db7adab6fb1d3c7e71d699ca6bea4b3 Mon Sep 17 00:00:00 2001 From: Joey Jiao Date: Tue, 14 May 2024 15:52:08 +0800 Subject: pkg/cover: fix offset in canonicalizer - offset is int64 on some 64bit os - for core kernel, no need to add offset --- pkg/cover/canonicalizer.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/cover/canonicalizer.go b/pkg/cover/canonicalizer.go index 7241a7478..c9678585c 100644 --- a/pkg/cover/canonicalizer.go +++ b/pkg/cover/canonicalizer.go @@ -40,7 +40,8 @@ type convertContext struct { // Contains the offset and final address of each module. type canonicalizerModule struct { - offset int + offset int64 + name string endAddr uint64 // Discard coverage from current module. // Set to true if module is not present in canonical. @@ -93,13 +94,15 @@ func (can *Canonicalizer) NewInstance(modules []KernelModule) *CanonicalizerInst instAddr := module.Addr canonicalToInstMap[canonicalAddr] = &canonicalizerModule{ - offset: int(instAddr) - int(canonicalAddr), + offset: int64(instAddr - canonicalAddr), + name: module.Name, endAddr: module.Size + canonicalAddr, discard: discard, } instToCanonicalMap[instAddr] = &canonicalizerModule{ - offset: int(canonicalAddr) - int(instAddr), + offset: int64(canonicalAddr - instAddr), + name: module.Name, endAddr: module.Size + instAddr, discard: discard, } @@ -203,7 +206,9 @@ func (convert *Convert) convertPC(pc uint64) (uint64, bool) { if module.discard { return pc, false } - pc = uint64(int(pc) + module.offset) + if module.name != "" { + pc = uint64(int64(pc) + module.offset) + } } } return pc, true -- cgit mrf-deployment