Beispiel #1
0
            protected override int Do(IWorkId work)
            {
                var args = this.MakeArgs(work).ToArray();

                var bufferedOutput = BufferedTextWriter.Create();

                try
                {
                    bufferedOutput.WriteLine("Analysis of dll: {0}", work.SliceId.Dll);

                    return(this.callClousotMain(args, bufferedOutput));
                }
                finally
                {
                    this.output.WriteLine(bufferedOutput.ToString());
                }
            }
Beispiel #2
0
            protected override int Do(IWorkId work)
            {
                var args = this.MakeArgs(work).ToArray();

                var bufferedOutput = BufferedTextWriter.Create();

                try
                {
                    var outputFactory = new FullTextWriterOutputFactory <Method, Assembly>(bufferedOutput);

                    this.output.WriteLine("[SlicerWorker: {0}] Analysis of dll (Time stamp {1}) {2}", DateTime.Now, work.Time, work.SliceId.Dll);

                    return(this.callClousotMain(args, outputFactory, this.db.AsEnumerable()));
                }
                finally
                {
                    this.output.WriteLine(bufferedOutput.ToString());
                }
            }
Beispiel #3
0
        /// <summary>
        /// Wait for this worker to complete
        /// </summary>
        /// <param name="Writer">Writer for log output</param>
        /// <returns>Return code from the thread</returns>
        public SequenceProbeResult Join(LineBasedTextWriter Writer)
        {
            // Finish the task instance
            BufferedTextWriter BufferedWriter = new BufferedTextWriter();
            int ExitCode = ActiveInstance.Join(BufferedWriter);

            ActiveInstance.Dispose();
            ActiveInstance = null;

            // Read the new state
            FileReference  OutputFile = new FileReference(TaskStateFile.FullName + ".out");
            SequenceWorker NewWorker  = SequenceWorker.Deserialize(OutputFile.FullName);

            OutputFile.Delete();

            // Make sure the exit code reflects the failure state. XGE can sometimes fail transferring back.
            if (ExitCode == 0 && !NewWorker.bResult)
            {
                ExitCode = -1;
            }

            // If it's a hard failure, print the compile log to the regular log
            if (ExitCode == -1)
            {
                Writer.WriteLine("Failed to compile {0}, exit code {1}:", UniqueName, ExitCode);
                foreach (string Line in NewWorker.CompileLog)
                {
                    Writer.WriteLine("    > {0}", Line.Replace("error:", "err:"));
                }
            }

            // Annotate the log data if this is from a failed attempt. It still may be useful for debugging purposes.
            if (ExitCode != 0)
            {
                NewWorker.SummaryLog.Insert(0, String.Format("ExitCode={0}", ExitCode));
                NewWorker.SummaryLog = NewWorker.SummaryLog.Select(x => "FAIL > " + x).ToList();

                NewWorker.CompileLog.Insert(0, String.Format("ExitCode={0}", ExitCode));
                NewWorker.CompileLog = NewWorker.CompileLog.Select(x => "FAIL > " + x).ToList();
            }

            // Append the log data back to the local output
            File.AppendAllLines(SummaryLogFile.FullName, NewWorker.SummaryLog);
            NewWorker.SummaryLog.Clear();

            File.AppendAllLines(CompileLogFile.FullName, NewWorker.CompileLog);
            NewWorker.CompileLog.Clear();

            // If we failed, return the
            if (ExitCode != 0)
            {
                if (ExitCode == -1)
                {
                    Writer.WriteLine("Warning: Failed to compile {0}, exit code {1}. Aborting.", UniqueName, ExitCode);
                    return(SequenceProbeResult.Failed);
                }
                else
                {
                    Writer.WriteLine("Warning: Failed to compile {0}; exit code {1}. Will retry.", UniqueName, ExitCode);
                    return(SequenceProbeResult.FailedAllowRetry);
                }
            }

            // Update the task
            Worker = NewWorker;

            // Check if this is just an incremental update
            if (Type == SequenceProbeType.Verify)
            {
                // Save the task
                Worker.Serialize(TaskStateFile.FullName);

                // Return that we're done
                return(SequenceProbeResult.Completed);
            }
            else if (Type == SequenceProbeType.Optimize)
            {
                if (Worker.RemainingFragmentCount > 0)
                {
                    // Get the top-most fragment - the one we've just established is a dependency for this leaf node - and add it to the list of known dependencies
                    SourceFragment NextFragment = Fragments[Worker.RemainingFragmentCount - 1];
                    AddDependency(Worker, Fragments, Worker.RemainingFragmentCount - 1);
                    Worker.SummaryLog.Add(String.Format("         [Added {0}: {1}]", Worker.RemainingFragmentCount - 1, Fragments[Worker.RemainingFragmentCount - 1].Location));

                    // Save the task
                    Worker.Serialize(TaskStateFile.FullName);

                    // Otherwise, return that we've just updated
                    return(SequenceProbeResult.Updated);
                }
                else
                {
                    // Save the task
                    Worker.Serialize(TaskStateFile.FullName);

                    // Return that we're done
                    SetCompletedDependencies();
                    return(SequenceProbeResult.Completed);
                }
            }
            else
            {
                throw new NotImplementedException();
            }
        }