Skip to content

Commit

Permalink
bugtool: add pmap out to the dump
Browse files Browse the repository at this point in the history
pmap(1) is an utility that reads /proc/pid/smaps in a nicely format.
This is the proper way of retrieving accurate memory usage per segment
of a Linux process via /proc.

Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com>
  • Loading branch information
mtardy committed Sep 9, 2024
1 parent 60a1db7 commit 7b4e845
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/bugtool/bugtool.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func doBugtool(info *InitInfo, outFname string) error {
si.addGopsInfo(tarWriter)
si.dumpPolicyFilterMap(tarWriter)
si.addGrpcInfo(tarWriter)
si.addPmapOut(tarWriter)
return nil
}

Expand Down Expand Up @@ -607,3 +608,14 @@ func (s *bugtoolInfo) addGrpcInfo(tarWriter *tar.Writer) {

s.multiLog.Infof("dumped tracing policies in %s", fname)
}

func (s bugtoolInfo) addPmapOut(tarWriter *tar.Writer) error {
pmap, err := exec.LookPath("pmap")
if err != nil {
s.multiLog.WithError(err).Warn("Failed to locate pmap. Please install it.")
return fmt.Errorf("failed to locate pmap: %w", err)
}

s.execCmd(tarWriter, "pmap.out", pmap, "-x", fmt.Sprintf("%d", s.info.PID))
return nil
}

0 comments on commit 7b4e845

Please sign in to comment.