]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
fix cmd call of switchback, and deal with return err 256
authorCerion Armour-Brown <cerion@valgrind.org>
Fri, 4 Mar 2005 14:20:14 +0000 (14:20 +0000)
committerCerion Armour-Brown <cerion@valgrind.org>
Fri, 4 Mar 2005 14:20:14 +0000 (14:20 +0000)
git-svn-id: svn://svn.valgrind.org/vex/trunk@1005

VEX/switchback/binary_switchback.pl

index 47b2f0fdb9f602a2cd8d188a2596dfdf2dfa7be3..1180e200952c91da2dd297449ee053a1df68f4c5 100755 (executable)
@@ -144,16 +144,24 @@ sub SwitchBack {
     }
     my $TMPFILE = ".switchback_output.$n";
 
-    print "=== Calling switchback for basic block $n ===\n";
+    print "=== Calling switchback for bb $n ===\n";
 
-    system("$SWITCHBACK $TEST.o $n >& $TMPFILE");
+    system("$SWITCHBACK $TEST.o $n >& $TMPFILE");
     my $ret = $?;
 
+    if ($ret == 256) {
+       print "Error running switchback - Quitting...\n---\n";
+       open(INFILE, "$TMPFILE");
+       print <INFILE>;
+       close(INFILE);
+
+       unlink($TMPFILE) if (! DEBUG);
+       exit 0; 
+    } 
+
     if ($ret & 127) {
        print "Ctrl-C pressed - Quitting...\n";
-       if (! DEBUG) {
-           unlink($TMPFILE);
-       }
+       unlink($TMPFILE) if (! DEBUG);
        exit 0;
     }
 
@@ -174,12 +182,10 @@ sub SwitchBack {
        my @results = <INFILE>;
        close(INFILE);
 
-       while (!((shift @results) =~ /^---START---/)) {}
+       while (@results && !((shift @results) =~ /^---START---/)) {}
        print @results;
 
-       if (! DEBUG) {
-           unlink($TMPFILE);
-       }
+       unlink($TMPFILE) if (! DEBUG);
        return;
     }
 
@@ -187,9 +193,7 @@ sub SwitchBack {
     my @results = <INFILE>;
     close(INFILE);
 
-    if (! DEBUG) {
-       unlink($TMPFILE);
-    }
+    unlink($TMPFILE) if (! DEBUG);
     return @results;
 }