JIVE
JIVE is a Java debugging tool that allows Eclipse to do forwards and backward debugging. Backwards debugging (also called reverse debugging) allows the user to rewind the program to previous states. This allows the user to go back and time and see what led to incorrect program state. JIVE also has some sequence and object diagramming capabilities.
Install
JIVE does not work on the latest Eclipse versions (as of 20190311, Eclipse 2018-12 does not work). I have tested with Oxygen 4.7.3a and it works in that version of Eclipse. You can try other versions of Neon, Oxygen, or Photon, but they may not work.
Old versions of Eclipse can be found here. Here is a link to a local copy of Eclipse 4.7.3a for Windows 64bit.
Once you have a compatible version of Eclipse, you need to install JIVE. Instructions can be found on the JIVE website. The basic steps are:
- Go to
Help > Install New Software...
- Click
Add...
- Enter name 'JIVE' and URL
http://www.cse.buffalo.edu/jive/update/
- Check the box by the JIVE software to install and proceed through the dialogs
Using
Once JIVE is installed, you need to get it ready to use. Some tutorials are available. Here is the basic setup to use it with a project:
- Open a Java project
- Debug the project at least once to make a debug configuration
- Go to
Run > Debug Configurations...
- Click on the JIVE tab
- Select
Enable Debugging with JIVE
Now you can use the drop-down arrow by the debug icon or Run > Debug As...
to debug with JIVE. This should automatically select the JIVE perpsective.
ParallelAdd
You should have a new parallel add project in your repo. Set a breakpoint at the final print statement. Debug the program using JIVE. It should stop at the breakpoint you just set. The sequence diagram should show all 8 threads and their corresponding run times. What are the colors used for the threads?
You can rewind time by right-clicking a time slice in the sequence diagram and saying 'Jump to' and selecting a target. This can let you see the control flow through the program, but you cannot observe varaiable results easily.
Use search to find when each thread starts. Go to Search > Search...
and click on the JIVE search tab. Find a Method Called with the name run
. You should get a list of the calls in the lower left pane, which tracks to the sequence diagram.
You can also search for variable changes. Search for changes to the finalSum
variable. Inspect the changes to the variable. How does JIVE mark changes in the sequence diagram?
What happens to the object diagram as you switch between variable change instances?
Comment out the thread join near the end of the program and run the code again. Do you notce any differences in the sequence diagram?