forked from OSchip/llvm-project
ccc-analyzer:
- Capture the STDERR output of 'clang' to a file for use with crash reporting. llvm-svn: 55749
This commit is contained in:
parent
e039d5580e
commit
370de84b50
|
|
@ -32,7 +32,7 @@ sub GetPPExt {
|
||||||
}
|
}
|
||||||
|
|
||||||
sub ProcessClangFailure {
|
sub ProcessClangFailure {
|
||||||
my ($Lang, $file, $Args, $HtmlDir, $ErrorType) = @_;
|
my ($Lang, $file, $Args, $HtmlDir, $ErrorType, $ofile) = @_;
|
||||||
my $Dir = "$HtmlDir/crashes";
|
my $Dir = "$HtmlDir/crashes";
|
||||||
mkpath $Dir;
|
mkpath $Dir;
|
||||||
my ($PPH, $PPFile) = tempfile("clang_crash_XXXXXX",
|
my ($PPH, $PPFile) = tempfile("clang_crash_XXXXXX",
|
||||||
|
|
@ -46,6 +46,7 @@ sub ProcessClangFailure {
|
||||||
print OUT "$ErrorType\n";
|
print OUT "$ErrorType\n";
|
||||||
print OUT "@$Args\n";
|
print OUT "@$Args\n";
|
||||||
close OUT;
|
close OUT;
|
||||||
|
system 'mv',$ofile,"$PPFile.output";
|
||||||
}
|
}
|
||||||
|
|
||||||
##----------------------------------------------------------------------------##
|
##----------------------------------------------------------------------------##
|
||||||
|
|
@ -110,17 +111,32 @@ sub Analyze {
|
||||||
push @CmdArgs,"--analyzer-viz-egraph-ubigraph";
|
push @CmdArgs,"--analyzer-viz-egraph-ubigraph";
|
||||||
}
|
}
|
||||||
|
|
||||||
my $Result = system $Cmd,@CmdArgs;
|
# 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?
|
# Did the command die because of a signal?
|
||||||
if ($Result & 127 and $Cmd eq $Clang and defined $HtmlDir) {
|
if ($Result & 127 and $Cmd eq $Clang and defined $HtmlDir) {
|
||||||
ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
|
ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
|
||||||
"Crash");
|
"Crash", $ofile);
|
||||||
}
|
}
|
||||||
elsif ($Result) {
|
elsif ($Result) {
|
||||||
ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
|
ProcessClangFailure($Lang, $file, \@CmdArgsSansAnalyses, $HtmlDir,
|
||||||
"Parser Rejects");
|
"Parser Rejects", $ofile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
`rm -f $ofile`;
|
||||||
}
|
}
|
||||||
|
|
||||||
##----------------------------------------------------------------------------##
|
##----------------------------------------------------------------------------##
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue