[cfe-commits] r55749 - /cfe/trunk/utils/ccc-analyzer
Ted Kremenek
kremenek at apple.com
Wed Sep 3 17:02:34 PDT 2008
Author: kremenek
Date: Wed Sep 3 19:02:34 2008
New Revision: 55749
URL: http://llvm.org/viewvc/llvm-project?rev=55749&view=rev
Log:
ccc-analyzer:
- Capture the STDERR output of 'clang' to a file for use with crash reporting.
Modified:
cfe/trunk/utils/ccc-analyzer
Modified: cfe/trunk/utils/ccc-analyzer
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/ccc-analyzer?rev=55749&r1=55748&r2=55749&view=diff
==============================================================================
--- cfe/trunk/utils/ccc-analyzer (original)
+++ cfe/trunk/utils/ccc-analyzer Wed Sep 3 19:02:34 2008
@@ -32,7 +32,7 @@
}
sub ProcessClangFailure {
- my ($Lang, $file, $Args, $HtmlDir, $ErrorType) = @_;
+ my ($Lang, $file, $Args, $HtmlDir, $ErrorType, $ofile) = @_;
my $Dir = "$HtmlDir/crashes";
mkpath $Dir;
my ($PPH, $PPFile) = tempfile("clang_crash_XXXXXX",
@@ -46,6 +46,7 @@
print OUT "$ErrorType\n";
print OUT "@$Args\n";
close OUT;
+ system 'mv',$ofile,"$PPFile.output";
}
##----------------------------------------------------------------------------##
@@ -109,18 +110,33 @@
if (defined $ENV{'CCC_UBI'}) {
push @CmdArgs,"--analyzer-viz-egraph-ubigraph";
}
-
- my $Result = system $Cmd, at CmdArgs;
- # Did the command die because of a signal?
- if ($Result & 127 and $Cmd eq $Clang and defined $HtmlDir) {
- ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
- "Crash");
- }
- elsif ($Result) {
- ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
- "Parser Rejects");
- }
+ # Capture the STDERR of clang and send it to a temporary file.
+ # Capture the STDOUT of clang and reroute it to ccc-analyzer's STDERR.
+ # We save the output file in the 'crashes' directory if clang encounters
+ # any problems with the file.
+ my ($ofh, $ofile) = tempfile("clang_output_XXXXXX", DIR => $HtmlDir);
+ my $pid = fork();
+ if ($pid == 0) {
+ open(STDOUT,">&", \*STDERR);
+ open(STDERR,">&", $ofh);
+ exec $Cmd, @CmdArgs;
+ }
+ close ($ofh);
+ wait;
+ my $Result = $?;
+
+ # Did the command die because of a signal?
+ if ($Result & 127 and $Cmd eq $Clang and defined $HtmlDir) {
+ ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
+ "Crash", $ofile);
+ }
+ elsif ($Result) {
+ ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
+ "Parser Rejects", $ofile);
+ }
+
+ `rm -f $ofile`;
}
##----------------------------------------------------------------------------##
More information about the cfe-commits
mailing list