diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-09-04 00:02:34 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-09-04 00:02:34 +0000 |
commit | 370de84b50f19a0e621c5c57d6cebd1e601d9566 (patch) | |
tree | 2f9165b64ae343c80db6af48e867af67d9230f5c /clang | |
parent | e039d5580ebdc27871e8a8d2b18dcbd74e4a07d8 (diff) | |
download | bcm5719-llvm-370de84b50f19a0e621c5c57d6cebd1e601d9566.tar.gz bcm5719-llvm-370de84b50f19a0e621c5c57d6cebd1e601d9566.zip |
ccc-analyzer:
- Capture the STDERR output of 'clang' to a file for use with crash reporting.
llvm-svn: 55749
Diffstat (limited to 'clang')
-rwxr-xr-x | clang/utils/ccc-analyzer | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/clang/utils/ccc-analyzer b/clang/utils/ccc-analyzer index c46b6e95d7a..323d529fa8e 100755 --- a/clang/utils/ccc-analyzer +++ b/clang/utils/ccc-analyzer @@ -32,7 +32,7 @@ sub GetPPExt { } 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 @@ sub ProcessClangFailure { print OUT "$ErrorType\n"; print OUT "@$Args\n"; close OUT; + system 'mv',$ofile,"$PPFile.output"; } ##----------------------------------------------------------------------------## @@ -109,18 +110,33 @@ sub Analyze { if (defined $ENV{'CCC_UBI'}) { push @CmdArgs,"--analyzer-viz-egraph-ubigraph"; } + + # 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); + } - my $Result = system $Cmd,@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"); - } + `rm -f $ofile`; } ##----------------------------------------------------------------------------## |