CIF 3

Debugging generated code

Warning

This page is primarily intended for the developers of the CIF 3 simulator, and not its end users.

The CIF 3 simulator generates highly optimized code for the specification, to speed up the simulation. By enabling the Debug the generated code (by writing it to disk) debugging output, the generated code can be written to disk, for further debugging.

Output directory

If the simulation is performed from within Eclipse, and a project named nl.tue.cif.v3x0x0.simulator.debug exists, is not closed, and has a src directory, the generated code will be written to that src directory. Otherwise, the generated code will be written to the directory containing the input specification file.

Regardless, the code is also always written to a cifcode sub-directory. If this sub-directory does not yet exist, it is created. If it already exists, all existing .java files are removed from the sub-directory first, before the newly generated code is written.

Written files

The generated code consists of Java files only. This results in several .java files being written to the cifcode directory.

Additionally, an Eclipse launch configuration file (_cif3sim_debug.launch) is written. This launch configuration can be used to reproduce the simulation implemented by the generated code. The launch configuration reproduces the simulation options that were used, and always shows the option dialog. The working directory for the simulation performed via the generated launch configuration is the same working directory as the original simulation. This allows additional files, such as configuration files, to be found.

How to use

To use this feature, follow these steps:

  • Import all CIF 3 related source projects into your Eclipse workspace.
  • Make sure your workspace is automatically rebuilt, by enabling the Build Automatically option in the Project menu.
  • Start a sub-Eclipse application, by right clicking on any plug-in project in the workspace, and choosing Run as ‣ Eclipse Application or Debug as ‣ Eclipse Application.
  • In the sub-Eclipse that opens, make sure the CIF specification (the .cif file) that you like to simulate is available in the workspace.
  • In the sub-Eclipse, import the nl.tue.cif.v3x0x0.simulator.debug source project.
  • Simulate the CIF specification, and make sure you enable the Debug the generated code option.
  • Continue simulation, if desired.
  • Once the simulation has terminated, switch back to the main Eclipse.
  • Refresh the nl.tue.cif.v3x0x0.simulator.debug project.
  • Set breakpoints in the generated Java code, or in the simulator code, as desired.
  • Right click the launch configuration in the src/cifcode directory, and choose Debug as ‣ _cif3sim_debug.
  • Debug the simulation, with the generated code, as you would any Java program.

Starting the simulator with generated code

The launch configuration that is written to disk with the generated code, uses the Load debug code option (Simulator category). Using this option, the classpath (directory) where the already generated code is located, is specified. By specifying it, the simulator knows from where to load it.

Simulations not started from the generated launch configuration, generally don’t use this option. They load the input specification, validate it, generate fresh code, and compile the code in-memory, or use compiled code files

Simulations using the generated code ignore all options related to repeated simulations. That is, the Load debug code option takes priority over the Compile only option (Compiler category), and simulating with compiled code files.

A warning is printed to the console if the generated code was generated with a different version of the simulator than the one used to simulate it. Ignoring the warning may lead to unexpected simulation results, or even simulator crashes.