3 # Valgrind a Mono-based app.
7 # Nat Friedman <nat@novell.com>
10 # monogrind [valgrind options] foo.exe [foo.exe options]
15 my $valgrind_options = "";
20 foreach my $arg (@ARGV) {
21 if ($arg =~ /.*\.exe$/) {
24 } elsif ($got_exe == 1) {
25 $exe_options .= " $arg";
27 $valgrind_options .= " $arg";
31 my $cmd = "valgrind $valgrind_options mono -v $exe $exe_options";
33 my ($wtr, $rdr, $err);
34 $pid = open3 ($wtr, $rdr, $err, $cmd);
36 # Where we hold the IP/Method mappings
39 # Build up all the stderr stuff and process it en masse at the end
40 $valgrind_output = "";
46 if ($_ =~ /^Method/) {
47 $method = $ip1 = $ip2 = $_;
49 $method =~ s,^Method (.*) emitted at.*$,\1,;
50 $ip1 =~ s,^.*emitted at (0x[a-f0-9]*).*$,\1,;
51 $ip2 =~ s,^.*to (0x[a-f0-9]*).*$,\1,g;
53 my %entry = ( "method" => $method,
59 } elsif ($_ =~ /^==/) {
60 $valgrind_output .= "$_\n";
66 # Read the rest of stderr
68 $valgrind_output .= "$_\n";
71 my @valgrind_lines = split (/\n/, $valgrind_output);
72 foreach my $val_line (@valgrind_lines) {
76 $ip =~ s,^.*by (0x[A-Fa-f0-9]*): \?\?\?.*$,\1,g;
82 foreach my $m (@map) {
83 if (hex ($ip) < hex ($$m{"ip1"})) {
84 $_ =~ s,\?\?\?,$last,g;
87 $last = $$m{"method"};