Skip to content
Snippets Groups Projects
Commit b75e351f authored by Régis Blanc's avatar Régis Blanc
Browse files

Debug system with level and tags

parent c5995926
Branches
Tags
No related merge requests found
package leon
object Logger {
//the debug level to display, from 0 (no debug information) to 5 (very verbose)
//var level = 0
//each debug information is tagged by a string, the tag variable only display the message with a tag in this set
//if the set is empty then all tags are displayed
//var tags: Set[String] = Set()
val defaultTag = "main"
private def output(msg: String, lvl: Int, tag: String) {
if(lvl <= Settings.debugLevel) {
if(Settings.debugTags.isEmpty || Settings.debugTags.contains(tag)) {
println("DEBUG: [" + tag + "] " + msg)
}
}
}
def debug(msg: String, lvl: Int, tag: String = defaultTag) = output(msg, lvl, tag)
}
...@@ -31,6 +31,7 @@ object Main { ...@@ -31,6 +31,7 @@ object Main {
} }
private def defaultAction(program: Program, reporter: Reporter) : Unit = { private def defaultAction(program: Program, reporter: Reporter) : Unit = {
Logger.debug("Default action on program: " + program, 5, "main")
val passManager = new PassManager(Seq(ImperativeCodeElimination, UnitElimination, FunctionClosure, FunctionHoisting, Simplificator)) val passManager = new PassManager(Seq(ImperativeCodeElimination, UnitElimination, FunctionClosure, FunctionHoisting, Simplificator))
val program2 = passManager.run(program) val program2 = passManager.run(program)
val analysis = new Analysis(program2, reporter) val analysis = new Analysis(program2, reporter)
......
...@@ -6,9 +6,9 @@ class PassManager(passes: Seq[Pass]) { ...@@ -6,9 +6,9 @@ class PassManager(passes: Seq[Pass]) {
def run(program: Program): Program = { def run(program: Program): Program = {
passes.foldLeft(program)((pgm, pass) => { passes.foldLeft(program)((pgm, pass) => {
//println("Running Pass: " + pass.description) Logger.debug("Running Pass: " + pass.description, 1, "passman")
val newPgm = pass(pgm) val newPgm = pass(pgm)
//println("Resulting program: " + newPgm) Logger.debug("Resulting program: " + newPgm, 5, "passman")
newPgm newPgm
}) })
} }
......
...@@ -23,5 +23,6 @@ object Settings { ...@@ -23,5 +23,6 @@ object Settings {
var useParallel : Boolean = false var useParallel : Boolean = false
// When this is None, use real integers // When this is None, use real integers
var bitvectorBitwidth : Option[Int] = None var bitvectorBitwidth : Option[Int] = None
var verbose : Boolean = false var debugLevel: Int = 0
var debugTags: Set[String] = Set.empty
} }
...@@ -40,7 +40,8 @@ class LeonPlugin(val global: Global, val actionAfterExtraction : Option[Program= ...@@ -40,7 +40,8 @@ class LeonPlugin(val global: Global, val actionAfterExtraction : Option[Program=
" --quickcheck Use QuickCheck-like random search" + "\n" + " --quickcheck Use QuickCheck-like random search" + "\n" +
" --parallel Run all solvers in parallel" + "\n" + " --parallel Run all solvers in parallel" + "\n" +
" --noLuckyTests Do not perform additional tests to potentially find models early" + "\n" + " --noLuckyTests Do not perform additional tests to potentially find models early" + "\n" +
" --verbose Print debugging informations" " --debug=[1-5] Debug level" + "\n" +
" --tags=t1:... Filter out debug information that are not of one of the given tags"
) )
/** Processes the command-line options. */ /** Processes the command-line options. */
...@@ -63,7 +64,8 @@ class LeonPlugin(val global: Global, val actionAfterExtraction : Option[Program= ...@@ -63,7 +64,8 @@ class LeonPlugin(val global: Global, val actionAfterExtraction : Option[Program=
case "quickcheck" => leon.Settings.useQuickCheck = true case "quickcheck" => leon.Settings.useQuickCheck = true
case "parallel" => leon.Settings.useParallel = true case "parallel" => leon.Settings.useParallel = true
case "noLuckyTests" => leon.Settings.luckyTest = false case "noLuckyTests" => leon.Settings.luckyTest = false
case "verbose" => leon.Settings.verbose = true case s if s.startsWith("debug=") => leon.Settings.debugLevel = try { s.substring("debug=".length, s.length).toInt } catch { case _ => 0 }
case s if s.startsWith("tags=") => leon.Settings.debugTags = Set(splitList(s.substring("tags=".length, s.length)): _*)
case s if s.startsWith("unrolling=") => leon.Settings.unrollingLevel = try { s.substring("unrolling=".length, s.length).toInt } catch { case _ => 0 } case s if s.startsWith("unrolling=") => leon.Settings.unrollingLevel = try { s.substring("unrolling=".length, s.length).toInt } catch { case _ => 0 }
case s if s.startsWith("functions=") => leon.Settings.functionsToAnalyse = Set(splitList(s.substring("functions=".length, s.length)): _*) case s if s.startsWith("functions=") => leon.Settings.functionsToAnalyse = Set(splitList(s.substring("functions=".length, s.length)): _*)
case s if s.startsWith("extensions=") => leon.Settings.extensionNames = splitList(s.substring("extensions=".length, s.length)) case s if s.startsWith("extensions=") => leon.Settings.extensionNames = splitList(s.substring("extensions=".length, s.length))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment