File: memprof2calltree

package info (click to toggle)
kcachegrind 4%3A16.08.3-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,844 kB
  • ctags: 3,250
  • sloc: cpp: 28,541; perl: 325; python: 235; makefile: 7; sh: 5
file content (38 lines) | stat: -rwxr-xr-x 644 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl
#
# Convert the memory profiles of memprof to calltree format,
# loadable with KCachegrind
#
# (C) 2004, Josef Weidendorfer

print "events: Allocated\n";

while(<>) {
  if (/^(\S.*)$/) {
    $next = 0;
    print "\nfn=$1\n";
    next;
  }
  if (/^  children:/) {
    $next = 1; #children
    next;
  }
  if (/^  inherited:/) {
    $next = 2; #inherited
    next;
  }
  if (/^  total:/) {
    # ignore, is calculated
    next;
  }
  if (/^  self:\s*(\d+)/) {
    if ($1 ne "0") {
      print "0 $1\n";
    }
    next;
  }
  if (/^\s+(\S.*?):\s*(\d+)$/) {
    if ($next < 2) { next; }
    print "cfn=$1\ncalls=0 0\n0 $2\n";
  }
}