Skip to content

OCG Visualisation

Cheng-017 edited this page Dec 5, 2021 · 2 revisions

Summary

In certain debugging scenarios, it might be useful to have the Object Construction Graph (OCG) information at hand. As such, we have implemented an experimental functionality to record the Object Construction Graph information for replay and analysis. The relevant details can be found in this branch. The relevant classes are:

  • ConstructionPathSynthesizer, which contains the code for recording the graph visualisation data,
  • GraphVisualisationData, which holds the graph visualisation data for serialisation and deserialisation
  • GraphVisualisationDataBuilder, which builds the GraphVisualisationData.
  • Any other classes used in GraphVisualisationData (e.g. SimplePartialGraph, SimpleControlFlowGraph, SimpleDepVariableWrapper, SimpleStatement).

How to Record

To record the graph visualisation data during Evosuite++ execution, set the isDebugger flag to true during ConstructionPathSynthesizer initialisation. This will trigger recording of graph visualisation data to a JSON file in the user directory during runtime.

Graph Visualisation Data Format

The JSON file is a serialised version of the GraphVisualisationData class. It contains the following:

  • A serialised form of the sliced OCG (SimplePartialGraph)
  • A serialised form of the Control Flow Graph (CFG) (SimpleControlFlowGraph)

The SimplePartialGraph itself consists of the following:

  • A string representation of the target branch
  • A mapping of node label to an object representation of an OCG node

with each node itself (stored as a SimpleDepVariableWrapper) containing

  • A string representation of the original node
  • A list of parent nodes
  • A list of child nodes

For more detailed information, you may want to look at the classes themselves.

OCG Visualization Tool

Configuration:

  • Import from an existing maven file
  • Delete the error file in the build path, and then add annotations.jar and jsr305.jar from the OCGVisualizationTool\Source\jhotdraw7\lib path

Run steps:

  • Run main.java.OCGVisualizationTool.drawGraphPanelSample
  • Open the corresponding JSON file through file->open
  • The PREVIOUS and NEXT buttons are used to traverse the nodes.
  • The OCG panel uses a grid layout. For each node, the node connected on the left is the parent node, and the node connected on the right is the child node. The TestCase panel displays the test case corresponding to the current node.