/
gen_valgrind_suppressions.pl
executable file
·67 lines (59 loc) · 2.06 KB
/
gen_valgrind_suppressions.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
58
59
60
61
62
63
64
65
66
67
#! perl
# Copyright (C) 2009, Parrot Foundation.
use strict;
use warnings;
use IO::File;
# This is written with unix-like systems very much in mind. Feel free to
# update this if/when valgrind is ported to other platforms.
die "Must be run in (built) parrot source directory.\n" unless -f 'parrot';
# create t/op/say_1.pir if necessary
`prove t/op/say.t` unless -f 't/op/say_1.pir';
my $pipe = IO::File->new( "valgrind --suppressions=tools/dev/parrot.supp"
." --freelist-vol=1000000000 --num-callers=500"
." --leak-check=full --leak-resolution=high"
." --show-reachable=yes ./parrot --leak-test"
." t/op/say_1.pir 2>&1 |" );
# simple state machine.
my ($line, $type);
while(defined($line = $pipe->getline)) {
chomp($line);
if($line =~ /^==(\d+)== (.+)$/) {
my ($pid, $message) = ($1, $2);
if($message eq 'Conditional jump or move depends on uninitialised value(s)') {
$type = 'Cond';
}
if($message eq 'Use of uninitialised value of size 8') {
$type = 'Value8';
}
if($message eq 'Use of uninitialised value of size 4') {
$type = 'Value4';
}
elsif($message =~ / at (0x[0-9A-F]+): (\S+) \((.+)\)$/) {
my ($offset, $symbol, $object) = ($1, $2, $3);
if($object =~ m|in /lib[^/]*/ld-.+\.so$|) {
# suppress GNU ld error.
my $supp_name = lc("gnuld-$symbol-$type");
$supp_name =~ s/[-_]+/-/g;
emit($supp_name, $symbol, "Memcheck:$type", '/lib*/ld-*.so');
}
}
}
}
my %already_emitted;
sub emit {
my ($name, $symbol, $type, $object) = @_;
return if exists($already_emitted{$name});
print("{\n");
print(" $name\n");
print(" $type\n");
print(" fun:$symbol\n");
print(" obj:$object\n");
print("}\n");
$already_emitted{$name} = 1;
}
# Local Variables:
# mode: cperl
# cperl-indent-level: 4
# fill-column: 100
# End:
# vim: expandtab shiftwidth=4: