File indexing completed on 2024-11-24 05:07:35

0001 #!/usr/bin/perl
0002 #
0003 # Convert the memory profiles of memprof to calltree format,
0004 # loadable with KCachegrind
0005 #
0006 # (C) 2004, Josef Weidendorfer
0007 
0008 print "events: Allocated\n";
0009 
0010 while(<>) {
0011   if (/^(\S.*)$/) {
0012     $next = 0;
0013     print "\nfn=$1\n";
0014     next;
0015   }
0016   if (/^  children:/) {
0017     $next = 1; #children
0018     next;
0019   }
0020   if (/^  inherited:/) {
0021     $next = 2; #inherited
0022     next;
0023   }
0024   if (/^  total:/) {
0025     # ignore, is calculated
0026     next;
0027   }
0028   if (/^  self:\s*(\d+)/) {
0029     if ($1 ne "0") {
0030       print "0 $1\n";
0031     }
0032     next;
0033   }
0034   if (/^\s+(\S.*?):\s*(\d+)$/) {
0035     if ($next < 2) { next; }
0036     print "cfn=$1\ncalls=0 0\n0 $2\n";
0037   }
0038 }