-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathparseJiveHeap.pl
executable file
·57 lines (49 loc) · 1.46 KB
/
parseJiveHeap.pl
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl
# parseJiveHeap.pl
#
# walks the xml tree of a jive.heap memory dump and attempts to
# breakdown the components of userdata objects (surface, icon, window, etc.) currently
# in memory
#
# requires XML::Twig, which also requires XML::Parser and expat. XML::* modules available from CPAN
# expat can be found on sourceforge
#
# first version: bklaas 03.08
use strict;
use XML::Twig;
use Data::Dump qw( dump );
my %userdata;
my %userdataIds;
my %rootTableId;
my $file = $ARGV[0] || 'heap.xml';
die "no such file readable" unless -r $file;
my $t = XML::Twig->new(
twig_handlers => {
userdata => sub {
my ( $t, $g ) = @_;
#print dump($g);
my $userdata = {
id => $g->{'att'}->{'id'},
cycle => $g->{'att'}->{'cycle'},
metatable => $g->first_child('metatable'),
};
if ($userdata->{'metatable'}->{'att'}->{'cycle'} ne 'true') {
my $metatableId = $userdata->{'metatable'}->{'att'}->{'id'};
$rootTableId{$metatableId} = $userdata->{id};
}
$userdataIds{$userdata->{id}}++;
if ($g->first_child =~ /HASH/) {
$userdata->{metatable} = $g->first_child->{'att'}->{'id'};
if ($userdata->{cycle} ne 'true') {
#print "$userdata->{id}\t$userdata->{metatable}\n";
$userdata{$userdata->{metatable}}++;
}
}
$t->purge;
},
}
);
$t->parsefile($file);
for my $key ( sort { $userdata{$b} <=> $userdata{$a} } keys %userdata ) {
print "$key\t$userdata{$key}\t$rootTableId{$key}\n";
}