Author: benm
Date: 2005-03-09 10:51:30 -0500 (Wed, 09 Mar 2005)
New Revision: 41603
Added:
trunk/mcs/tools/monogrind.pl
Removed:
trunk/mcs/tools/valgrind-monofunc.pl
Modified:
trunk/mcs/tools/ChangeLog
Log:
2005-03-09 Ben Maurer <[EMAIL PROTECTED]>
* monogrind.pl: Renamed valgrind-monofunc.pl to this, per
Nat. Updated with Nat's fixes.
Modified: trunk/mcs/tools/ChangeLog
===================================================================
--- trunk/mcs/tools/ChangeLog 2005-03-09 15:10:59 UTC (rev 41602)
+++ trunk/mcs/tools/ChangeLog 2005-03-09 15:51:30 UTC (rev 41603)
@@ -1,3 +1,8 @@
+2005-03-09 Ben Maurer <[EMAIL PROTECTED]>
+
+ * monogrind.pl: Renamed valgrind-monofunc.pl to this, per
+ Nat. Updated with Nat's fixes.
+
2005-03-08 Ben Maurer <[EMAIL PROTECTED]>
* valgrind-monofunc.pl: Add this wonderful script from Nat.
Copied: trunk/mcs/tools/monogrind.pl (from rev 41582,
trunk/mcs/tools/valgrind-monofunc.pl)
===================================================================
--- trunk/mcs/tools/valgrind-monofunc.pl 2005-03-09 03:45:04 UTC (rev
41582)
+++ trunk/mcs/tools/monogrind.pl 2005-03-09 15:51:30 UTC (rev 41603)
@@ -0,0 +1,92 @@
+#!/usr/bin/perl
+#
+# Valgrind a Mono-based app.
+#
+# 8 March 2005
+#
+# Nat Friedman <[EMAIL PROTECTED]>
+#
+# Usage:
+# monogrind [valgrind options] foo.exe [foo.exe options]
+#
+
+use IPC::Open3;
+
+my $valgrind_options = "";
+my $exe_options = "";
+my $exe = "";
+my $got_exe = 0;
+
+foreach my $arg (@ARGV) {
+ if ($arg =~ /.*\.exe$/) {
+ $exe = $arg;
+ $got_exe = 1;
+ } elsif ($got_exe == 1) {
+ $exe_options .= " $arg";
+ } else {
+ $valgrind_options .= " $arg";
+ }
+}
+
+my $cmd = "valgrind $valgrind_options mono -v $exe $exe_options";
+
+my ($wtr, $rdr, $err);
+$pid = open3 ($wtr, $rdr, $err, $cmd);
+
+# Where we hold the IP/Method mappings
+my @map = ();
+
+# Build up all the stderr stuff and process it en masse at the end
+$valgrind_output = "";
+
+while (<$rdr>) {
+ $_ =~ s,\n,,g;
+ $_ =~ s,\r,,g;
+
+ if ($_ =~ /^Method/) {
+ $method = $ip1 = $ip2 = $_;
+
+ $method =~ s,^Method (.*) emitted at.*$,\1,;
+ $ip1 =~ s,^.*emitted at (0x[a-f0-9]*).*$,\1,;
+ $ip2 =~ s,^.*to (0x[a-f0-9]*).*$,\1,g;
+
+ my %entry = ( "method" => $method,
+ "ip1" => $ip1,
+ "ip2" => $ip2 );
+
+ push (@map, \%entry);
+ $i ++;
+ } elsif ($_ =~ /^==/) {
+ $valgrind_output .= "$_\n";
+ } else {
+ print "$_\n";
+ }
+}
+
+# Read the rest of stderr
+while (<$err>) {
+ $valgrind_output .= "$_\n";
+}
+
+my @valgrind_lines = split (/\n/, $valgrind_output);
+foreach my $val_line (@valgrind_lines) {
+ $_ = $val_line;
+ if ($_ =~ /\?\?\?/) {
+ $ip = $_;
+ $ip =~ s,^.*by (0x[A-Fa-f0-9]*): \?\?\?.*$,\1,g;
+ $ip = lc ($ip);
+ $ip =~ s,\n,,g;
+ $ip =~ s,\r,,g;
+
+ my $last = "UNKNOWN";
+ foreach my $m (@map) {
+ if (hex ($ip) < hex ($$m{"ip1"})) {
+ $_ =~ s,\?\?\?,$last,g;
+ break;
+ }
+ $last = $$m{"method"};
+ }
+ }
+
+ print "$_\n";
+}
Deleted: trunk/mcs/tools/valgrind-monofunc.pl
===================================================================
--- trunk/mcs/tools/valgrind-monofunc.pl 2005-03-09 15:10:59 UTC (rev
41602)
+++ trunk/mcs/tools/valgrind-monofunc.pl 2005-03-09 15:51:30 UTC (rev
41603)
@@ -1,76 +0,0 @@
-#!/usr/bin/perl
-#
-# Make Valgrind output for Mono applications readable.
-#
-# 8 March 2005
-#
-# Nat Friedman <[EMAIL PROTECTED]>
-#
-# Usage:
-# valgrind --leak-check=full mono -v foo.exe > mono-v.out 2> valgrind.out
-# valgrind-monofunc.pl mono-v.out valgrind.out > valgrind-monofunc.out
-#
-
-my $path = $ARGV[0];
-
-if (! open (FILE, $path)) {
- die ("Could not open $path");
-}
-
-my @map = ();
-my $i = 0;
-while (<FILE>) {
-
- $_ =~ s,\n,,g;
- $_ =~ s,\r,,g;
-
- if ($_ =~ /^Method/) {
-
- $method = $ip1 = $ip2 = $_;
-
- $method =~ s,^Method (.*) emitted at.*$,\1,;
- $ip1 =~ s,^.*emitted at (0x[a-f0-9]*).*$,\1,;
- $ip2 =~ s,^.*to (0x[a-f0-9]*).*$,\1,g;
-
- my %entry = ( "method" => $method,
- "ip1" => $ip1,
- "ip2" => $ip2 );
-
- push (@map, \%entry);
- $i ++;
- }
-}
-
-print "Loaded $i method VMAs from $path\n";
-
-#foreach my $foo (@map) {
-# print $$foo{"ip1"} . " - " . $$foo{"ip2"} . " " . $$foo{"method"} .
"\n\n";
-#}
-
-my $path2 = $ARGV[1];
-
-if (! open (FILE2, $path2)) {
- die ("Could not open $path");
-}
-
-while (<FILE2>) {
- if ($_ =~ /\?\?\?/) {
- $ip = $_;
- $ip =~ s,^.*by (0x[A-Fa-f0-9]*): \?\?\?.*$,\1,g;
- $ip = lc ($ip);
- $ip =~ s,\n,,g;
- $ip =~ s,\r,,g;
-
- my $last = "UNKNOWN";
- foreach my $m (@map) {
-# print "Comparing $ip to " . $$m{"ip1"} . "(" . $$m{"method"} . ")
...\n";
- if (hex ($ip) < hex ($$m{"ip1"})) {
- $_ =~ s,\?\?\?,$last,g;
- break;
- }
- $last = $$m{"method"};
- }
- }
-
- print $_;
-}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches