Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

Wiki Markup
{redirect:https://www.jetbrains.com/idea/help/debugging-with-chronon.html

...

|delay

...

=0}

Table of Contents

What this tutorial is about

...

Preparing an example

Let’s see how Chronon works on a simple example of a two-thread class. One thread performs quick sorting, while the second thread performs bubble sorting.

...

Open the Settings/Preferences dialog. To do that, click on the main toolbar, or press

span
classshortcut
Wiki Markup
{span:class=shortcut}Ctrl+Alt+S{span}
. Under the IDE Settings
span
classshortcut
Wiki Markup
{span:class=shortcut}IDE Settings{span}
, click the node Plugins
span
classshortcut
Wiki Markup
{span:class=shortcut}Plugins{span}
.

The Chronon plugin is not bundled with IntelliJ IDEA, that's why you have to look for it in the JetBrains Plugins Repository. This is how it's done...

In the Plugins page, click the button

Install JetBrains
span
classshortcut
Wiki Markup
{span:class=shortcut}Install JetBrains plugin...{span}
to download and install plugins from the JetBrains repository. In the Browse JetBrains Plugins
span
classshortcut
Wiki Markup
{span:class=shortcut}Browse JetBrains Plugins{span}
dialog box, find the Chronon plugin - you can type the search string in the filter area:

...

After restart, pay attention to the following changes:

  • Dedicated Run with Chronon
    span
    classshortcut
    Wiki Markup
    {span:class=shortcut}Run with Chronon{span}
    icon appears on the main toolbar. By now, this icon is disabled. It will become enabled as soon as the corresponding run/debug configuration appears.
  • Chronon tool window (which becomes available on launching a run/debug configuration with Chronon, or on opening a Chronon record).
  • Chronon tab appears in the run/debug configuration of the Application type (and some other types as well).
  • Run
    span
    classshortcut
    Wiki Markup
    {span:class=shortcut}Run{span}
    menu is extended with two commands:
    • span
      classshortcut
      Run <run/debug configuration name> with Chronon
    • span
      classshortcut
      Open Chronon recording
    span
    classshortcut
    Run <run/debug configuration name> with Chronon
    and span
    classshortcut
    Add logging statement
    • Wiki Markup
      {span:class=shortcut}Run &lt;run/debug configuration name&gt; with Chronon{span}
    • Wiki Markup
      {span:class=shortcut}Open Chronon recording{span}
  • Wiki Markup
    {span:class=shortcut}Run &lt;run/debug configuration name&gt; with Chronon{span}
    and
    Wiki Markup
    {span:class=shortcut}Add logging statement{span}
    commands appear on the editor's context menu.

...

To launch our application, we need a run/debug configuration. Let's create one.

On the main menu, choose

Run→Edit Configuration
span
classshortcut
Wiki Markup
{span:class=shortcut}Run&rarr;Edit Configuration{span}
, and in the Run/Debug Configurations dialog box, click . We are going to create a new run/debug configuration of the Application type, so select this type:

...

First, give this run/debug configuration a name. Let it be ChrononDemo. Next, press

span
classshortcut
Wiki Markup
{span:class=shortcut}Shift+Enter{span}
and find the class with the main method ChrononDemo.java. This class resides in the package demo:

...

Defining include/exclude patterns

Next, click the tab

Chronon
span
classshortcut
Wiki Markup
{span:class=shortcut}Chronon{span}
. In this tab, you have to specify which classes IntelliJ IDEA should look at. This is done by Include / Exclude Patterns:

...

OK, it's time to launch our application. To do that, either click the Chronon button on the main toolbar, or choose

Run→Run ChrononDemo with Chronon
span
classshortcut
Wiki Markup
{span:class=shortcut}Run&rarr;Run ChrononDemo with Chronon{span}
on the main menu.

Let's choose the first way:

...

By the way, if you want to open one of the previous records, use

Run→Open Chronon recording
span
classshortcut
Wiki Markup
{span:class=shortcut}Run&rarr;Open Chronon recording{span}
on the main menu, and then choose the desired record:

...

Actually, you can use either the stepping commands of the

Run
span
classshortcut
Wiki Markup
{span:class=shortcut}Run{span}
menu, or the stepping buttons of the Chronon tool window. Unlike the debugger that allows only stepping forward, Chronon makes it possible to step through the applications in the reverse direction also. So, besides the traditional stepping buttons, there is Step Backwards button and Run Backwards to Cursor button .

...

This is how logging works. In the editor, right-click the statement of interest, and choose

Add logging statement
span
classshortcut
Wiki Markup
{span:class=shortcut}Add logging statement{span}
on the context menu. Then, in the dialog box that opens, specify the variable you want to watch in the format

...