Search code examples
javaeclipsedebuggingbreakpoints

Eclipse - Execute Expression on at Point in Code?


Is it possible to have Eclipse execute an arbitrary expression at a particular point in code when debugging?

The Execute/Display functionality allows you to run arbitrary code in the context of debugging. A breakpoint stops flow.

What I'd like is something like a breakpoint that can be inserted at a particular point in a class, doesn't suspend application flow, but instead executes a snippet of code.

The background is I'm trying to debug some multithreaded code which I can't edit, and I want to do some naive System.out.printlns to see when various things happen. If I use breakpoints then the flow of the events will be disturbed.


Solution

  • Aha! There's an undocumented feature whereby conditional breakpoints can execute other code, dubbed 'Printpoints'.

    enter image description here