UtBot Symbolic Engine Restructuring #84
Replies: 1 comment
-
[Updated] Me, @CaelmBleidd and @denis-fokin came to this architecture: After the refactoring the engine will consist of these main classes:
All of them, except of [SVM], work with the objects of type ExecutionState
PathSelector[PathSelector] is responsible for choosing the
We can use different algorithms for selecting and prioritizing states depending on what we want to do (e.g. cover all the branches, find deep NPEs, reach to the end as fast as possible, etc.) Traverser[Traverser] is responsible for producing new Traverser is bound to a specific method processing and cannot be reused between different methods. Internally, [Traverser] uses SVM[SVM] is responsible for working with SymbolicAnalyzer[SymbolicAnalyzer] is responsible only for symbolic analysis of our method. It handles one iteration of processing loop and deals with [PathSelector] and [Traverser]. [SymbolicAnalyzer] is an iterator-like object, and it has these methods:
EngineThe [Engine] class manages the control flow of our engine:
Decomposition of the previous Engine into the [SymbolicAnalyzer] and [Engine] allows:
Sequence Diagramof one iteration of sequenceDiagram
participant Engine
participant SymbolicAnalyzer
participant PathSelector
participant Traverser
participant SVM
note right of Engine: one iteration of the inner<br>while (symbolicAnalyzer.hasNext()) loop
Engine->>+SymbolicAnalyzer: poll state
SymbolicAnalyzer->>+PathSelector: poll state
PathSelector-->>-SymbolicAnalyzer: [ExecutionState]
opt If the state type is [SymbolicExecutionState]
SymbolicAnalyzer->>+Traverser: traverse [SymbolicExecutionState]
note left of Traverser: Here we traverse top-level stmt and<br> create new ExecutionStates<br>with the help of SVM
loop For each possible branch
Traverser->>+SVM: Previous SymbolicState + updates
note left of SVM: The actual work with SymbolicMemory<br> and PathConstraints happens here
SVM-->>-Traverser: new SymbolicState
note left of Traverser: ExecutionState with updated<br> SymbolicState is created
end
Traverser-->>-SymbolicAnalyzer: new [ExecutionState]s
note left of Traverser: these states can be of any type:<br> symbolic, terminal, concrete
loop For each new state produced from the polled state
SymbolicAnalyzer->>+PathSelector: add new [ExecutionState]
PathSelector-->>-SymbolicAnalyzer: ok
end
end
SymbolicAnalyzer-->>-Engine: the polled [Execution state]
note right of Engine: Switch on state type
alt is SymbolicExecutionState
note right of Engine: ignores this state, because we already added all<br> successors in SymbolicAnalyser
else is TerminalState
Engine->>Engine: process [TerminalExecutionState]
note right of Engine: usually here we construct models from symbolic variables,<br>call concrete executor and return UtExecution,<br>but this behavior can be overriden
else is ConcreteExecutionState
Engine->>Engine: process [ConcreteExecutionState]
note right of Engine: usually here we do the same as above, except constructing<br> models for stateAfter and result, but it can be overriden
end
Feedback and suggestions are appreciated. |
Beta Was this translation helpful? Give feedback.
-
Current Behavior
The engine (
UtBotSymbolicEngine
class) works as follows now:ExecutionState
and commits it to the state queue (PathSelector
)ExecutionState
UtExecution
and adds to the result flowSadly, it all happens in one 3000-lines-of-code file (
UtBotSymbolicEngine.kt
) and is very unclear.Problem
In some scenarios (e.g. ModelSynthesis) I would like to reuse, extend or replace internal parts of the engine independently. Possible cases:
ExecutionState
symbolicallyPathSelector
) depending on usage scenarioIdeas
[See the comments for more information]
The Engine Structure
Maybe it's possible to introduce such phases:
ExecutionState
traversing [Traverser]UtExecution
sQ: How to organize this structure? Maybe the pipeline pattern? What are the phases?
Refactor the current version of the engine:
ExecutionState
traversing logic to the external class [Traverser]UtBotSymbolicEngine.processResult
logic into two parts:ExecutionState
and passing it to the next stage [Traverser]ExecutionState
toUtExecution
via Resovler [Engine]Beta Was this translation helpful? Give feedback.
All reactions