Package it.unive.lisa

Class LiSAConfiguration


  • public class LiSAConfiguration
    extends java.lang.Object
    A holder for the configuration of a LiSA analysis.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int DEFAULT_WIDENING_THRESHOLD
      The default number of fixpoint iteration on a given node after which calls to Lattice.lub(Lattice) gets replaced with Lattice.widening(Lattice).
    • Constructor Summary

      Constructors 
      Constructor Description
      LiSAConfiguration()
      Builds a new configuration object, with default settings.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      LiSAConfiguration addSemanticCheck​(it.unive.lisa.checks.semantic.SemanticCheck<?,​?,​?> check)
      Adds the given semantic check to the ones that will be executed.
      LiSAConfiguration addSemanticChecks​(java.util.Collection<it.unive.lisa.checks.semantic.SemanticCheck<?,​?,​?>> checks)
      Adds the given semantic checks to the ones that will be executed.
      LiSAConfiguration addSyntacticCheck​(it.unive.lisa.checks.syntactic.SyntacticCheck check)
      Adds the given syntactic check to the ones that will be executed.
      LiSAConfiguration addSyntacticChecks​(java.util.Collection<it.unive.lisa.checks.syntactic.SyntacticCheck> checks)
      Adds the given syntactic checks to the ones that will be executed.
      boolean equals​(java.lang.Object obj)  
      it.unive.lisa.analysis.AbstractState<?,​?,​?> getAbstractState()
      Yields the AbstractState for the analysis.
      it.unive.lisa.interprocedural.callgraph.CallGraph getCallGraph()
      Yields the CallGraph for the analysis.
      java.lang.Class<? extends it.unive.lisa.util.collections.workset.WorkingSet<it.unive.lisa.program.cfg.statement.Statement>> getFixpointWorkingSet()
      Yields the concrete class of WorkingSet to be used in fixpoints.
      it.unive.lisa.interprocedural.InterproceduralAnalysis<?,​?,​?> getInterproceduralAnalysis()
      Yields the InterproceduralAnalysis for the analysis.
      it.unive.lisa.interprocedural.OpenCallPolicy getOpenCallPolicy()
      Yields the OpenCallPolicy to use during the analysis.
      java.util.Collection<it.unive.lisa.checks.semantic.SemanticCheck<?,​?,​?>> getSemanticChecks()
      Yields the collection of SemanticChecks that are to be executed during the analysis.
      java.util.Collection<it.unive.lisa.checks.syntactic.SyntacticCheck> getSyntacticChecks()
      Yields the collection of SyntacticChecks that are to be executed during the analysis.
      java.util.function.Function<it.unive.lisa.analysis.AbstractState<?,​?,​?>,​it.unive.lisa.util.collections.externalSet.ExternalSet<it.unive.lisa.type.Type>> getTypeExtractor()
      Yields the function that, given a state computed during type inference, yield the set of types computed for the processed SymbolicExpression.
      it.unive.lisa.analysis.AbstractState<?,​?,​?> getTypeInferenceState()
      Yields the AbstractState for the type inference.
      int getWideningThreshold()
      Yields the number of fixpoint iteration on a given node after which calls to Lattice.lub(Lattice) gets replaced with Lattice.widening(Lattice).
      java.lang.String getWorkdir()
      Yields the working directory where LiSA will dump all of its outputs.
      int hashCode()  
      boolean isDumpAnalysis()
      Yields whether or not the results of analysis, if run, should be dumped in the form of dot files representing results on single CFGs.
      boolean isDumpCFGs()
      Yields whether or not the input program should be dumped in the form of dot files representing single CFGs.
      boolean isDumpTypeInference()
      Yields whether or not the results of type inference, if run, should be dumped in the form of dot files representing results on single CFGs.
      boolean isInferTypes()
      Yields whether or not type inference should be run.
      boolean isJsonOutput()
      Yields whether or not the results a json report file should be dumped at the end of the analysis.
      LiSAConfiguration setAbstractState​(it.unive.lisa.analysis.AbstractState<?,​?,​?> state)
      Sets the AbstractState to use for the analysis.
      LiSAConfiguration setCallGraph​(it.unive.lisa.interprocedural.callgraph.CallGraph callGraph)
      Sets the CallGraph to use for the analysis.
      LiSAConfiguration setDumpAnalysis​(boolean dumpAnalysis)
      Sets whether or not dot files, named analysis__<cfg name>.dot, should be created and dumped in the working directory at the end of the analysis.
      LiSAConfiguration setDumpCFGs​(boolean dumpCFGs)
      Sets whether or not dot files, named <cfg name>.dot, should be created and dumped in the working directory at the start of the execution.
      LiSAConfiguration setDumpTypeInference​(boolean dumpTypeInference)
      Sets whether or not dot files, named typing__<cfg name>.dot, should be created and dumped in the working directory at the end of the type inference.
      LiSAConfiguration setFixpointWorkingSet​(java.lang.Class<? extends it.unive.lisa.util.collections.workset.WorkingSet<it.unive.lisa.program.cfg.statement.Statement>> fixpointWorkingSet)
      Sets the concrete class of WorkingSet to be used in fixpoints.
      LiSAConfiguration setInferTypes​(boolean inferTypes)
      Sets whether or not runtime types should be inferred before executing the semantic analysis.
      LiSAConfiguration setInterproceduralAnalysis​(it.unive.lisa.interprocedural.InterproceduralAnalysis<?,​?,​?> analysis)
      Sets the InterproceduralAnalysis to use for the analysis.
      LiSAConfiguration setJsonOutput​(boolean jsonOutput)
      Sets whether or not a json report file, named report.json, should be created and dumped in the working directory at the end of the analysis.
      LiSAConfiguration setOpenCallPolicy​(it.unive.lisa.interprocedural.OpenCallPolicy openCallPolicy)
      Sets the OpenCallPolicy to use during the analysis.
      LiSAConfiguration setTypeInferenceState​(it.unive.lisa.analysis.AbstractState<?,​?,​?> state, java.util.function.Function<it.unive.lisa.analysis.AbstractState<?,​?,​?>,​it.unive.lisa.util.collections.externalSet.ExternalSet<it.unive.lisa.type.Type>> typeExtractor)
      Sets the AbstractState to use for the type inference.
      LiSAConfiguration setWideningThreshold​(int wideningThreshold)
      Sets the number of fixpoint iteration on a given node after which calls to Lattice.lub(Lattice) gets replaced with Lattice.widening(Lattice).
      LiSAConfiguration setWorkdir​(java.lang.String workdir)
      Sets the working directory for this instance of LiSA, that is, the directory files will be created, if any.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_WIDENING_THRESHOLD

        public static final int DEFAULT_WIDENING_THRESHOLD
        The default number of fixpoint iteration on a given node after which calls to Lattice.lub(Lattice) gets replaced with Lattice.widening(Lattice).
        See Also:
        Constant Field Values
    • Constructor Detail

      • LiSAConfiguration

        public LiSAConfiguration()
        Builds a new configuration object, with default settings. By default:
        • no syntactic check is executed
        • no AbstractState is set for the analysis
        • no CallGraph is set for the analysis
        • no InterproceduralAnalysis is set for the analysis
        • the workdir is the one where LiSA was executed
        • the input program will not be dumped
        • no type inference will be run
        • the type inference will not be dumped
        • the results of the analysis will not be dumped
        • the json report will not be dumped
        • the default warning threshold (5) will be used
        • the open call policy used is WorstCasePolicy
    • Method Detail

      • addSyntacticCheck

        public LiSAConfiguration addSyntacticCheck​(it.unive.lisa.checks.syntactic.SyntacticCheck check)
        Adds the given syntactic check to the ones that will be executed. These checks will be immediately executed after LiSA is started.
        Parameters:
        check - the check to execute
        Returns:
        the current (modified) configuration
      • addSyntacticChecks

        public LiSAConfiguration addSyntacticChecks​(java.util.Collection<it.unive.lisa.checks.syntactic.SyntacticCheck> checks)
        Adds the given syntactic checks to the ones that will be executed. These checks will be immediately executed after LiSA is started.
        Parameters:
        checks - the checks to execute
        Returns:
        the current (modified) configuration
      • addSemanticCheck

        public LiSAConfiguration addSemanticCheck​(it.unive.lisa.checks.semantic.SemanticCheck<?,​?,​?> check)
        Adds the given semantic check to the ones that will be executed. These checks will be executed after the fixpoint iteration has been completed.
        Parameters:
        check - the check to execute
        Returns:
        the current (modified) configuration
      • addSemanticChecks

        public LiSAConfiguration addSemanticChecks​(java.util.Collection<it.unive.lisa.checks.semantic.SemanticCheck<?,​?,​?>> checks)
        Adds the given semantic checks to the ones that will be executed. These checks will be executed after the fixpoint iteration has been completed.
        Parameters:
        checks - the checks to execute
        Returns:
        the current (modified) configuration
      • setCallGraph

        public LiSAConfiguration setCallGraph​(it.unive.lisa.interprocedural.callgraph.CallGraph callGraph)
        Sets the CallGraph to use for the analysis. Any existing value is overwritten.
        Parameters:
        callGraph - the callgraph to use
        Returns:
        the current (modified) configuration
      • setInterproceduralAnalysis

        public LiSAConfiguration setInterproceduralAnalysis​(it.unive.lisa.interprocedural.InterproceduralAnalysis<?,​?,​?> analysis)
        Sets the InterproceduralAnalysis to use for the analysis. Any existing value is overwritten.
        Parameters:
        analysis - the interprocedural analysis to use
        Returns:
        the current (modified) configuration
      • setTypeInferenceState

        public LiSAConfiguration setTypeInferenceState​(it.unive.lisa.analysis.AbstractState<?,​?,​?> state,
                                                       java.util.function.Function<it.unive.lisa.analysis.AbstractState<?,​?,​?>,​it.unive.lisa.util.collections.externalSet.ExternalSet<it.unive.lisa.type.Type>> typeExtractor)
        Sets the AbstractState to use for the type inference. Any existing value is overwritten.
        Parameters:
        state - the abstract state to use
        typeExtractor - the function that, given a state computed during type inference, yield the set of types computed for the processed SymbolicExpression. This value will be considered as the set of runtime types for the Statement that generated such expression.
        Returns:
        the current (modified) configuration
      • setAbstractState

        public LiSAConfiguration setAbstractState​(it.unive.lisa.analysis.AbstractState<?,​?,​?> state)
        Sets the AbstractState to use for the analysis. Any existing value is overwritten.
        Parameters:
        state - the abstract state to use
        Returns:
        the current (modified) configuration
      • setInferTypes

        public LiSAConfiguration setInferTypes​(boolean inferTypes)
        Sets whether or not runtime types should be inferred before executing the semantic analysis. If type inference is not executed, the runtime types of expressions will correspond to their static type.
        Parameters:
        inferTypes - if true, type inference will be ran before the semantic analysis
        Returns:
        the current (modified) configuration
      • setDumpCFGs

        public LiSAConfiguration setDumpCFGs​(boolean dumpCFGs)
        Sets whether or not dot files, named <cfg name>.dot, should be created and dumped in the working directory at the start of the execution. These files will contain a dot graph representing the each input CFGs' structure.

        To customize where the graphs should be generated, use setWorkdir(String).
        Parameters:
        dumpCFGs - if true, a dot graph will be generated before starting the analysis for each input cfg
        Returns:
        the current (modified) configuration
      • setDumpTypeInference

        public LiSAConfiguration setDumpTypeInference​(boolean dumpTypeInference)
        Sets whether or not dot files, named typing__<cfg name>.dot, should be created and dumped in the working directory at the end of the type inference. These files will contain a dot graph representing the each input CFGs' structure, and whose nodes will contain a textual representation of the results of the type inference on each Statement.

        To decide whether or not the type inference should be executed, use setInferTypes(boolean).

        To customize where the graphs should be generated, use setWorkdir(String).
        Parameters:
        dumpTypeInference - if true, a dot graph will be generated after the type inference for each input cfg
        Returns:
        the current (modified) configuration
      • setDumpAnalysis

        public LiSAConfiguration setDumpAnalysis​(boolean dumpAnalysis)
        Sets whether or not dot files, named analysis__<cfg name>.dot, should be created and dumped in the working directory at the end of the analysis. These files will contain a dot graph representing the each input CFGs' structure, and whose nodes will contain a textual representation of the results of the semantic analysis on each Statement.

        To customize where the graphs should be generated, use setWorkdir(String).
        Parameters:
        dumpAnalysis - if true, a dot graph will be generated after the semantic analysis for each input cfg
        Returns:
        the current (modified) configuration
      • setJsonOutput

        public LiSAConfiguration setJsonOutput​(boolean jsonOutput)
        Sets whether or not a json report file, named report.json, should be created and dumped in the working directory at the end of the analysis. This file will contain all the Warnings that have been generated, as well as a list of produced files.

        To customize where the report should be generated, use setWorkdir(String).
        Parameters:
        jsonOutput - if true, a json report will be generated after the analysis
        Returns:
        the current (modified) configuration
      • setWorkdir

        public LiSAConfiguration setWorkdir​(java.lang.String workdir)
        Sets the working directory for this instance of LiSA, that is, the directory files will be created, if any. If files need to be created and this method has not been invoked, LiSA will create them in the directory where it was executed from.
        Parameters:
        workdir - the path (relative or absolute) to the working directory
        Returns:
        the current (modified) configuration
      • setFixpointWorkingSet

        public LiSAConfiguration setFixpointWorkingSet​(java.lang.Class<? extends it.unive.lisa.util.collections.workset.WorkingSet<it.unive.lisa.program.cfg.statement.Statement>> fixpointWorkingSet)
        Sets the concrete class of WorkingSet to be used in fixpoints.
        Parameters:
        fixpointWorkingSet - the class
        Returns:
        the current (modified) configuration
      • setWideningThreshold

        public LiSAConfiguration setWideningThreshold​(int wideningThreshold)
        Sets the number of fixpoint iteration on a given node after which calls to Lattice.lub(Lattice) gets replaced with Lattice.widening(Lattice).
        Parameters:
        wideningThreshold - the threshold
        Returns:
        the current (modified) configuration
      • setOpenCallPolicy

        public LiSAConfiguration setOpenCallPolicy​(it.unive.lisa.interprocedural.OpenCallPolicy openCallPolicy)
        Sets the OpenCallPolicy to use during the analysis.
        Parameters:
        openCallPolicy - the policy to use
        Returns:
        the current (modified) configuration
      • getCallGraph

        public it.unive.lisa.interprocedural.callgraph.CallGraph getCallGraph()
        Yields the CallGraph for the analysis. Might be null if none was set.
        Returns:
        the call graph for the analysis
      • getInterproceduralAnalysis

        public it.unive.lisa.interprocedural.InterproceduralAnalysis<?,​?,​?> getInterproceduralAnalysis()
        Yields the InterproceduralAnalysis for the analysis. Might be null if none was set.
        Returns:
        the interprocedural analysis for the analysis
      • getTypeInferenceState

        public it.unive.lisa.analysis.AbstractState<?,​?,​?> getTypeInferenceState()
        Yields the AbstractState for the type inference. Might be null if none was set. If this is not null, then getTypeExtractor() is not null either.
        Returns:
        the abstract state for the type inference
      • getTypeExtractor

        public java.util.function.Function<it.unive.lisa.analysis.AbstractState<?,​?,​?>,​it.unive.lisa.util.collections.externalSet.ExternalSet<it.unive.lisa.type.Type>> getTypeExtractor()
        Yields the function that, given a state computed during type inference, yield the set of types computed for the processed SymbolicExpression. This value will be considered as the set of runtime types for the Statement that generated such expression.
        Returns:
        the function that is used to extract types
      • getAbstractState

        public it.unive.lisa.analysis.AbstractState<?,​?,​?> getAbstractState()
        Yields the AbstractState for the analysis. Might be null if none was set.
        Returns:
        the abstract state for the analysis
      • getSyntacticChecks

        public java.util.Collection<it.unive.lisa.checks.syntactic.SyntacticCheck> getSyntacticChecks()
        Yields the collection of SyntacticChecks that are to be executed during the analysis.
        Returns:
        the syntactic checks
      • getSemanticChecks

        public java.util.Collection<it.unive.lisa.checks.semantic.SemanticCheck<?,​?,​?>> getSemanticChecks()
        Yields the collection of SemanticChecks that are to be executed during the analysis.
        Returns:
        the semantic checks
      • isInferTypes

        public boolean isInferTypes()
        Yields whether or not type inference should be run.
        Returns:
        true if type inference should be run
      • isDumpCFGs

        public boolean isDumpCFGs()
        Yields whether or not the input program should be dumped in the form of dot files representing single CFGs.
        Returns:
        true if input program should be dumped
      • isDumpTypeInference

        public boolean isDumpTypeInference()
        Yields whether or not the results of type inference, if run, should be dumped in the form of dot files representing results on single CFGs.
        Returns:
        true if type inference should be dumped
      • isDumpAnalysis

        public boolean isDumpAnalysis()
        Yields whether or not the results of analysis, if run, should be dumped in the form of dot files representing results on single CFGs.
        Returns:
        true if the analysis should be dumped
      • isJsonOutput

        public boolean isJsonOutput()
        Yields whether or not the results a json report file should be dumped at the end of the analysis.
        Returns:
        true if the report should be produced
      • getWorkdir

        public java.lang.String getWorkdir()
        Yields the working directory where LiSA will dump all of its outputs.
        Returns:
        the working directory
      • getFixpointWorkingSet

        public java.lang.Class<? extends it.unive.lisa.util.collections.workset.WorkingSet<it.unive.lisa.program.cfg.statement.Statement>> getFixpointWorkingSet()
        Yields the concrete class of WorkingSet to be used in fixpoints.
        Returns:
        the working set class
      • getWideningThreshold

        public int getWideningThreshold()
        Yields the number of fixpoint iteration on a given node after which calls to Lattice.lub(Lattice) gets replaced with Lattice.widening(Lattice).
        Returns:
        the widening threshold
      • getOpenCallPolicy

        public it.unive.lisa.interprocedural.OpenCallPolicy getOpenCallPolicy()
        Yields the OpenCallPolicy to use during the analysis.
        Returns:
        the policy
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object