What this tutorial is about

This tutorial aims to walk you step-by-step through debugging a Java application with Chronon.

What this tutorial is not about

The basics of Java programming, and using Chronon are out of scope of this tutorial. Refer to the Chronon documentation for details.

Before you start...

Make sure that:

It is essential to understand that Chronon is not literally a debugger - it only helps you record the execution progress and then play it back, like a videotape.

Preparing example

Let’s see how Chronon works on a simple example.

First, create a project as described in the page Creating and running your first Java application.

Next, add Java classes to the src directory. The first class is called ChrononDemo.java and it performs two-threaded array sorting:

package demo;

import org.jetbrains.annotations.NotNull;

import java.util.AbstractMap;
import java.util.Arrays;
import java.util.Random;

public class ChrononDemo {

    public static final int SIZE = 1000;
    public static final Random GENERATOR = new Random();

    public static void main(String[] args) throws InterruptedException {
        final int[] array = new int[SIZE];
        for (int i = 0; i < SIZE; i++) {
            array[i] = GENERATOR.nextInt();
        }
        final Thread quickSortThread = new Thread(new Runnable() {
            @Override
            public void run() {
                QuickSort.sort(Arrays.copyOf(array, array.length));
            }
        }, "Quick sort");

        final Thread bubbleThread = new Thread(new Runnable() {
            @Override
            public void run() {
                BubbleSort.sort(Arrays.copyOf(array, array.length));
            }
        }, "Bubble sort");

        quickSortThread.start();
        bubbleThread.start();

        quickSortThread.join();
        bubbleThread.join();
    }
}

The second is the class QuickSort.java that performs quick sorting:

package demo;

class QuickSort {
    private static int partition(int arr[], int left, int right) {
        int i = left, j = right;
        int tmp;
        int pivot = arr[(left + right) / 2];

        while (i <= j) {
            while (arr[i] < pivot)
                i++;
            while (arr[j] > pivot)
                j--;
            if (i <= j) {
                tmp = arr[i];
                arr[i] = arr[j];
                arr[j] = tmp;
                i++;
                j--;
            }
        }

        return i;
    }

    public static void sort(int arr[], int left, int right) {
        int index = partition(arr, left, right);
        if (left < index - 1)
            sort(arr, left, index - 1);
        if (index < right)
            sort(arr, index, right);
    }

    public static void sort(int arr[]) {
        sort(arr, 0, arr.length - 1);
    }
}

And, finally, the third one is the class BubbleSort.java that performs bubble sorting:

package demo;

public class BubbleSort {
    public static void sort(int[] arr) {
        boolean swapped = true;
        int j = 0;
        int tmp;
        while (swapped) {
            swapped = false;
            j++;
            for (int i = 0; i < arr.length - j; i++) {
                if (arr[i] > arr[i + 1]) {
                    tmp = arr[i];
                    arr[i] = arr[i + 1];
                    arr[i + 1] = tmp;
                    swapped = true;
                }
            }
        }
    }
}

Installing plugin

Changes to the UI

Creating Chronon run/debug configuration.

Defining include/exclude patterns

Launching the application with Chronon