Skip to content

Commit 7887bbf

Browse files
committed
Review feedback, add comment about the binary search
1 parent 743f5e5 commit 7887bbf

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

processmanager/processinfo.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ func (pm *ProcessManager) findMappingForTrace(pid libpf.PID, fid host.FileID,
709709
return libpf.FrameMapping{}
710710
}
711711

712+
// Binary search for the potentially matching 'maps' entry. The search
713+
// lambda makes 'sort.Search' return the first entry that is larger
714+
// than the fid/addr pair. Thus -1 is needed to get index for the first
715+
// entry whchi is equal or less than fid/addr pair.
712716
i := sort.Search(len(maps), func(i int) bool {
713717
entry := &maps[i]
714718
fm := entry.FrameMapping.Value()
@@ -725,13 +729,11 @@ func (pm *ProcessManager) findMappingForTrace(pid libpf.PID, fid host.FileID,
725729
fm := entry.FrameMapping.Value()
726730
f := fm.File.Value()
727731
entryFid := host.FileIDFromLibpf(f.FileID)
732+
// Validate that the candidate 'maps' entry is a true match.
728733
if entryFid == fid && fm.Start <= addr && addr < fm.End {
729734
return entry.FrameMapping
730735
}
731-
log.Infof("fid %x=%x, %x < %x < %x", entryFid, fid, fm.Start, addr, fm.End)
732736
}
733-
log.Infof("finding %x:%x from %x maps -> %d", fid, addr, len(maps), i)
734-
735737
return libpf.FrameMapping{}
736738
}
737739

0 commit comments

Comments
 (0)