Skip to content

Commit 7bff1e1

Browse files
EdwinIngJdarko-marinov
authored andcommitted
Added docs about using NonDex with debugger
1 parent a05b4cb commit 7bff1e1

File tree

5 files changed

+110
-0
lines changed

5 files changed

+110
-0
lines changed

docs/images/debugbutton.png

4.34 KB
Loading
10.8 KB
Loading

docs/images/remotejvmdebug.png

70.2 KB
Loading
65.7 KB
Loading

docs/setup-debugger-intellij.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
## Setting Up Remote JVM Debug Configuration in IntelliJ
2+
3+
### Creating the Debug Configuration
4+
5+
1. Open **Run****Edit Configurations** (use the dropdown in the top toolbar)
6+
7+
![Configuration Button](images/toolbarconfigurationbutton.png)
8+
9+
Or use the dropdown next to the debug button:
10+
11+
![Configuration Button 2](images/debugconfigurationbutton.png)
12+
13+
2. Click the **+** button (or **Add New Configuration**)
14+
3. Select **Remote JVM Debug** from the list of templates
15+
16+
![Remote JVM Debug](images/remotejvmdebug.png)
17+
4. Configure the debug settings:
18+
- **Name**: Enter `NondexDebug` (or any descriptive name)
19+
- **Debugger mode**: Select `Attach to remote JVM`
20+
- **Transport**: Keep as `Socket` (default)
21+
- **Host**: Set to `localhost` (default)
22+
- **Port**: Set to `5005` (default)
23+
- **Use module classpath**: Leave blank
24+
5. Click **Apply** then **OK** to save the configuration
25+
26+
The configuration is now ready and will appear in the run configuration dropdown in the toolbar.
27+
28+
## Running Tests with Nondex
29+
Prior to running the debugger, you should run Nondex to confirm that a test is indeed flaky. For example, you should run the following command:
30+
`mvn -pl <module_name> edu.illinois:nondex-maven-plugin:2.2.1:nondex -Dtest=<test_name>`
31+
32+
By default, Nondex will run once without shuffling and three runs with shuffling. The test should fail in some of runs after the first run if it is ID flaky. Make note of the `nondexSeed` that was used in one of the runs that failed. For example, Nondex should output the following before every run:
33+
34+
```
35+
CONFIG: nondexFilter=.*
36+
nondexMode=FULL
37+
nondexSeed=933178
38+
nondexStart=0
39+
nondexEnd=9223372036854775807
40+
nondexPrintstack=false
41+
```
42+
Copy the `nondexSeed` as you would need this later.
43+
44+
## Running Tests with Nondex and Debugger
45+
46+
### Step 1: Set Breakpoints
47+
1. Navigate to the test file or source code you want to debug in IntelliJ
48+
- For example: `MovingAverageIterableTest.java` in your project
49+
2. Click in the **left gutter** (the area to the left of line numbers) to set breakpoints
50+
- A red dot will appear indicating an active breakpoint
51+
3. Set breakpoints at key locations where you want to inspect execution:
52+
- Methods at the top of the stack trace when the test failed
53+
- Test method entry points
54+
- Areas where nondeterministic behavior occurs
55+
56+
### Step 2: Start Nondex with Debug Agent
57+
Run the Maven command to execute Nondex with the remote debug agent enabled. This starts the test execution and suspends immediately, waiting for a debugger to attach on port 5005.
58+
59+
**Multi-line format:**
60+
```bash
61+
mvn -pl <module_name> \
62+
edu.illinois:nondex-maven-plugin:2.2.1:nondex \
63+
-Dtest=<test_name> \
64+
-DnondexSeed=<nondex_seed> -DnondexRuns=1 -DnondexRunsWithoutShuffling=0 \
65+
-Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
66+
```
67+
**Remember to replace <module_name>, <test_name>, and <nondex_seed> with the corresponding values for your test**
68+
69+
**Single-line format:**
70+
```bash
71+
mvn -pl <module_name> edu.illinois:nondex-maven-plugin:2.2.1:nondex -Dtest=<test_name> -DnondexSeed=<nondex_seed> -DnondexRuns=1 -DnondexRunsWithoutShuffling=0 -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005"
72+
```
73+
74+
**Remember to replace <module_name>, <test_name>, and <nondex_seed> with the corresponding values for your test**
75+
76+
**What the command does:**
77+
- `-pl`: Specifies the Maven module to test
78+
- `edu.illinois:nondex-maven-plugin:2.2.1:nondex`: Runs the Nondex plugin
79+
- `-Dtest=`: Specifies the exact test method to run
80+
- `-DnondexSeed=`: Sets a specific seed for reproducible nondeterminism
81+
- `-DnondexRuns=1`: Executes the test once with Nondex
82+
- `-DnondexRunsWithoutShuffling=0`: Tells Nondex to skip the first run without shuffling
83+
- `-Dmaven.surefire.debug=...`: Enables remote debugging with JVM debug agent
84+
- `suspend=y`: Suspends execution until debugger attaches
85+
- `address=5005`: Listens on port 5005
86+
87+
After running this command, you'll see output indicating the test is waiting for a debugger connection:
88+
```
89+
Listening for transport dt_socket at address: 5005
90+
```
91+
92+
### Step 3: Attach the Debugger
93+
1. Return to IntelliJ IDEA
94+
2. Select the **NondexDebug** configuration from the run configuration dropdown (top toolbar)
95+
3. Click the **Debug** button (bug icon)
96+
97+
![Debug Button](images/debugbutton.png)
98+
4. IntelliJ will connect to the waiting JVM process on port 5005
99+
5. The test execution will resume and stop at your breakpoints
100+
6. Use standard debugging controls:
101+
- **Step Over** (F8): Execute current line and move to next
102+
- **Step Into** (F7): Enter into method calls
103+
- **Step Out** (Shift+F8): Exit current method
104+
- **Resume** (F9): Continue execution to next breakpoint
105+
- **Evaluate Expression** (Alt+F8): Inspect variables and expressions
106+
107+
### Tips for Debugging with Nondex
108+
- Watch collections and their iteration order in the Variables panel
109+
- Compare execution across different Nondex seeds to identify nondeterministic behavior
110+
- Set breakpoints in both test code and production code to trace execution flow

0 commit comments

Comments
 (0)