Ejemplo n.º 1
0
        void taskLoadZ3LogFile(string logFile)
        {
            statusUpdate(0);

            FileInfo fi      = new FileInfo(logFile);
            long     curPos  = 0;
            int      lineNo  = 0;
            int      oldperc = 0;

            processor.model.LogFileName = logFile;
            try
            {
                using (var rd = File.OpenText(logFile))
                {
                    string l;
                    while ((l = rd.ReadLine()) != null && !isCancelled)
                    {
                        if (rd.Peek() != -1)
                        {
                            try
                            {
                                processor.ParseSingleLine(l);
                            }
                            catch (LogProcessor.OldLogFormatException)
                            {
                                System.Windows.Forms.MessageBox.Show("Please pass \"PROOF=true\" to Z3 when generating logs.", "Invalid Log File");
                                isCancelled = true;
                                return;
                            }
                            catch (LogProcessor.Z3VersionException)
                            {
                                System.Windows.Forms.MessageBox.Show("The version of Z3 that generated this log is not supported. Please upgrade to the latest version.", "Unsupported Z3 Version");
                                isCancelled = true;
                                return;
                            }
#if !DEBUG
                            catch (Exception e)
                            {
                                System.Windows.Forms.MessageBox.Show($"An exception occured while parsing the log: {e.Message}", "Parsing Log Failed");
                                isCancelled = true;
                                return;
                            }
#endif
                        }
                        curPos += l.Length + 2;

                        if (fi.Length == 0)
                        {
                            continue;
                        }

                        lineNo++;
                        int perc = (int)(curPos * 999 / fi.Length);
                        if (oldperc != perc)
                        {
                            statusUpdate(perc);
                            oldperc = perc;
                        }
                    }
                    processor.Finish();
                    processor.ComputeCost();
                    processor.model.BuildInstantiationDAG();
                }
            }
            catch (FileNotFoundException)
            {
                System.Windows.Forms.MessageBox.Show("The provided file path was invalid.", "File Not Found");
                isCancelled = true;
            }
            statusUpdate(1000);
        }