Skip to content
IDEA debugger sample Capture Points
Branch: master
Clone or download
Latest commit 621047a Nov 20, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples simple java examples Oct 3, 2017
LICENSE.txt added license Nov 20, 2018 Mention debugger agen Jul 2, 2018
RxJava1.xml sample capture points for RxJava 1.x Feb 27, 2017
akka-scala.xml support for scala futures and akka actors Feb 22, 2017
java-swing.xml use param number instead of name Mar 30, 2017
java8.xml added CompletableFuture thenAcceptAsync and thenRunAsync Mar 14, 2017
javaFX.xml JavaFx Platform.runLater support Jun 25, 2018
kotlin-coroutines.xml Kotlin coroutines capture points #7 - initial Jun 8, 2018
netty.xml added netty SingleThreadEventExecutor.addTask Mar 14, 2017
quickfix-app-messages.xml Capture config for QuickfixJ Application-level messages Mar 20, 2017
scala.xml simplified capture points for `scala.concurrent.Future` Oct 19, 2017
vert.x.xml added vert.x HttpClientResponseImpl.bodyHandler Mar 16, 2017

IDEA debugger Capture Points official JetBrains project

Read more about the feature in the Jetbrains blog.

In IDEA 2017.3 Async Stack Traces were implemented using the dedicated java agent, which works with much lower overhead, and most settings from this repository were hardcoded into the agent settings. Project specific setup is still available via the code annotations.

To use the capture points

  1. download the xml settings file:
  2. click on the required xml file
  3. right click on Raw and choose "save link as..."
  4. go to IDEA Settings | Build, Execution, Deployment | Debugger | Async Stacktraces and use the Import action
  5. enable the points you need
  6. start debugging

How to write your own

Capture point is a place in your program where debugger collects and saves the stack frames for later use. It is specified by the method name (and containing class) and the key expression which is evaluated and the resulting object is used later to get the information. So first go to your IDEA Settings | Build, Execution, Deployment | Debugger | Async Stacktraces and create a new capture point. Specify the method and the key expression. Usually the key expression is just a parameter name.

For example, javax.swing.SwingUtilities.invokeLater with the key "doRun"
will capture all invocations of the invokeLater and associate them with the Runnable instance parameter

When the debugger stops it starts matching stack frames with insertion point, which is another method and expression. If the method is matched, it evalautes the expression and if the value has some related stack information, it replaces the rest of the stack with it. This way you see what "was happening" at the related capture point.

For example, java.awt.event.InvocationEvent.dispatch with the insert key "runnable"
will insert information captured for invokeLater to the place where the Runnable is executed

Evaluating key expression may slow down your application, so try to use simple expressions, e.g.:

  • this
  • method param name (also you can use param_N, where N is a zero-based param number)
  • local variable or field name

Method invocations are much slower and highly not recommended.

more implementation details here

How to contribute

  1. create a new capture point in the IDEA, test it
  2. go to IDEA Settings | Build, Execution, Deployment | Debugger | Async Stacktraces
  3. select capture points and use export action
  4. create a pull request here with the file created
You can’t perform that action at this time.