xref: /minix/minix/commands/profile/tools/profextr.pl (revision 433d6423)
1#!/usr/local/bin/perl
2
3$SAMPLE_SZ = 12;
4
5$file = shift;
6
7open (FILE, $file) or die ("Unable to open $file: $!");
8
9$_ = <FILE>;
10
11until (eof(FILE)) {
12  read(FILE, $buf, $SAMPLE_SZ) == $SAMPLE_SZ  or die ("Short read.");
13  ($exe, $pc) = unpack("A8i", $buf);
14
15  # System and clock task are in kernel image.
16#  $exe =~ s/^system/kernel/;
17#  $exe =~ s/^clock/kernel/;
18
19  # Memory has p_name "mem" in kernel.
20#  $exe =~ s/^mem/memory/;
21
22  $pcs{$pc}++ if ($exe eq "fs");
23}
24
25foreach $pc (sort { $a <=> $b } keys %pcs) {
26	print "$pc $pcs{$pc}\n";
27}
28