@@ -8,7 +8,6 @@ package viper.silicon
88
99import java .text .SimpleDateFormat
1010import java .util .concurrent .{Callable , Executors , TimeUnit , TimeoutException }
11-
1211import scala .collection .immutable .ArraySeq
1312import scala .util .{Left , Right }
1413import ch .qos .logback .classic .{Level , Logger }
@@ -19,7 +18,7 @@ import viper.silver.frontend.{DefaultStates, SilFrontend}
1918import viper .silver .reporter ._
2019import viper .silver .verifier .{AbstractVerificationError => SilAbstractVerificationError , Failure => SilFailure , Success => SilSuccess , TimeoutOccurred => SilTimeoutOccurred , VerificationResult => SilVerificationResult , Verifier => SilVerifier }
2120import viper .silicon .interfaces .Failure
22- import viper .silicon .logger .SymbExLogger
21+ import viper .silicon .logger .{ MemberSymbExLogger , SymbExLogger }
2322import viper .silicon .reporting .{MultiRunRecorders , condenseToViperResult }
2423import viper .silicon .verifier .DefaultMainVerifier
2524import viper .silicon .decider .{Cvc5ProverStdIO , Z3ProverStdIO }
@@ -93,6 +92,10 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
9392 private var _config : Config = _
9493 final def config = _config
9594
95+ private var _symbExLog : SymbExLogger [_ <: MemberSymbExLogger ] = _
96+ final def symbExLog = _symbExLog
97+ final def symbExLog_= (log : SymbExLogger [_ <: MemberSymbExLogger ]) = { _symbExLog = log }
98+
9699 private sealed trait LifetimeState
97100
98101 private object LifetimeState {
@@ -113,6 +116,7 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
113116 lifetimeState = LifetimeState .Configured
114117
115118 _config = new Config (args)
119+ _symbExLog = SymbExLogger .ofConfig(_config)
116120 }
117121
118122 def debugInfo (debugInfo : Seq [(String , Any )]): Unit = { this .debugInfo = debugInfo }
@@ -129,7 +133,7 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
129133
130134 setLogLevelsFromConfig()
131135
132- verifier = new DefaultMainVerifier (config, reporter)
136+ verifier = new DefaultMainVerifier (config, reporter, symbExLog )
133137 verifier.start()
134138 }
135139
@@ -202,10 +206,9 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
202206 result = Some (condenseToViperResult(failures))
203207 } catch { /* Catch exceptions thrown during verification (errors are not caught) */
204208 case _ : TimeoutException =>
205- // verification was interrupted, therefore close the current member's scope:
206- SymbExLogger .currentLog().closeMemberScope()
207209 if (config.ideModeAdvanced()) {
208- reporter report ExecutionTraceReport (SymbExLogger .memberList, List (), List ())
210+ symbExLog.close()
211+ reporter report ExecutionTraceReport (symbExLog.logs.toSeq, List (), List ())
209212 }
210213 result = Some (SilFailure (SilTimeoutOccurred (config.timeout(), " second(s)" ) :: Nil ))
211214 case exception : Exception if ! config.disableCatchingExceptions() =>
@@ -240,21 +243,23 @@ class Silicon(val reporter: Reporter, private var debugInfo: Seq[(String, Any)]
240243
241244 /* verifier.bookkeeper.*/ elapsedMillis = System .currentTimeMillis() - /* verifier.bookkeeper.*/ startTime
242245
243- val failures =
244- results.flatMap(r => r :: r.previous.toList)
245- .collect{ case f : Failure => f } /* Ignore successes */
246- .pipe(allResults => {
247- /* If branchconditions are to be reported we collect the different failure contexts
248- * of all failures that report the same error (but on different branches, with different CounterExample)
249- * and put those into one failure */
250- if (config.enableBranchconditionReporting())
251- allResults.groupBy(failureFilterAndGroupingCriterion).map{case (_ : String , fs: List [Failure ]) =>
252- fs.head.message.failureContexts = fs.flatMap(_.message.failureContexts)
253- Failure (fs.head.message)
254- }.toList
255- else allResults.distinctBy(failureFilterAndGroupingCriterion)
256- })
257- .sortBy(failureSortingCriterion)
246+ val failures = results
247+ // note that we do not extract 'previous' verification errors from VerificationResult's `previous` field
248+ // because this is expected to have already been done in `verifier.verify` (for each member).
249+ .collect{ case f : Failure => f } /* Ignore successes */
250+ .pipe(allResults => {
251+ /* If branchconditions are to be reported we collect the different failure contexts
252+ * of all failures that report the same error (but on different branches, with different CounterExample)
253+ * and put those into one failure
254+ */
255+ if (config.enableBranchconditionReporting())
256+ allResults.groupBy(failureFilterAndGroupingCriterion).map{case (_ : String , fs: List [Failure ]) =>
257+ fs.head.message.failureContexts = fs.flatMap(_.message.failureContexts)
258+ Failure (fs.head.message)
259+ }.toList
260+ else allResults.distinctBy(failureFilterAndGroupingCriterion)
261+ })
262+ .sortBy(failureSortingCriterion)
258263
259264// if (config.showStatistics.isDefined) {
260265// val proverStats = verifier.decider.statistics()
@@ -335,6 +340,8 @@ class SiliconFrontend(override val reporter: Reporter,
335340
336341 protected var siliconInstance : Silicon = _
337342
343+ override def backendTypeFormat : Option [String ] = Some (" SMTLIB" )
344+
338345 def createVerifier (fullCmd : String ) = {
339346 siliconInstance = new Silicon (reporter, Seq (" args" -> fullCmd))
340347
@@ -344,7 +351,7 @@ class SiliconFrontend(override val reporter: Reporter,
344351 def configureVerifier (args : Seq [String ]) = {
345352 siliconInstance.parseCommandLine(args)
346353
347- if (siliconInstance.config.error.isEmpty) {
354+ if (siliconInstance.config.error.isEmpty && ! siliconInstance.config.exit ) {
348355 /** Parsing the provided command-line options might fail, in which the resulting error
349356 * is recorded in `siliconInstance.config.error`
350357 * (see also [[viper.silver.frontend.SilFrontendConfig.onError ]]).
0 commit comments