Skip to content

JetBrains/capture-points

Repository files navigation

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

About

IDEA debugger sample Capture Points

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published