Thursday, April 28, 2011

Debugging Eclipse builders

Do you think Eclipse builds too often ? Do you think Eclipse build too much ? At least I do, or maybe I just got tired of seeing 'Building workspace: (12%)' in the status bar. Anyway I decided to see for myself what the heck the builders were doing.

I use JDT and PDE which means there are two builders of interest
  • Java Builder
  • API Analysis Builder
There are also Plug-in Manifest Builder and Extension Point Schema Builder, but I think these two do not do much and hence do not take much time.

To know what these two builders are doing in your running Eclipse instance two things are required
  • Start Eclipse with -debug option, to me more precise I used the following to redirect the debug output to a file as the debug output can grow large very soon and overflow the console buffer
    •  eclipsec –debug > log.txt
  • Enable debug options for three plug-ins (details below)
    • org.eclipse.core.resources
    • org.eclipse.jdt.core
    • org.eclipse.pde.api.tools
All three plug-ins ship a .options file containing all the debug options provided by these plug-ins, just open the the corresponding jars in your eclipse installation to get the .options files. Create a single .options file from these and place it in the same directory as eclipsec.exe before starting eclipse.

I had the following options set to true in my .options file
###################################################################
# Turn on debug tracing for org.eclipse.jdt.core plugin
org.eclipse.jdt.core/debug=true

# Reports java  builder activity : nature of build, built state reading, indictment process
org.eclipse.jdt.core/debug/builder=true

# Reports java builder stats
org.eclipse.jdt.core/debug/builder/stats=true

###################################################################
# Debugging options for the org.eclipse.core.resources plugin.

# Turn on debugging for the org.eclipse.core.resources plugin.
org.eclipse.core.resources/debug=true

# Reports the start and end of all builder invocations
org.eclipse.core.resources/build/invoking=true

# Reports the start and end of build delta calculations
org.eclipse.core.resources/build/delta=true

# For incremental builds, displays which builder is being run
# and because of changes in which project.
org.eclipse.core.resources/build/needbuild=true

# Prints a stack trace every time an operation finishes that requires a build
org.eclipse.core.resources/build/needbuildstack=true

###################################################################
# Turn on debug tracing for org.eclipse.pde.api.tools plugin
org.eclipse.pde.api.tools/debug=true

# Reports incremental builder activity : nature of build, indictment process,...
org.eclipse.pde.api.tools/debug/builder=true

# Print notified compatibility deltas
org.eclipse.pde.api.tools/debug/delta=true

# for the tag scanner
org.eclipse.pde.api.tools/debug/tagscanner=true

# for API profile
org.eclipse.pde.api.tools/debug/apiprofile=true

#for api analyzer
org.eclipse.pde.api.tools/debug/apianalyzer=true

#for our workspace delta processor
org.eclipse.pde.api.tools/debug/workspacedeltaprocessor=true
###################################################################

So far I have found a few scenarios where the builders could do less work - Bug 344090, Bug 344110, Bug 344163, Bug 344137. I think there are more issues, but getting a reproducible test case is proving to be a little hard in some cases.

JDT at Eclipse Day India

Satyam and I will be speaking at Eclipse Day India 2011 in Bangalore next week. We have one session JDT Bootcamp. This session consists of two parts. 

JDT - Tips and Tricks (30 min) - In the first 30 mins we will show off useful tips and tricks when working with JDT and Eclipse in general such as tricks in content assist, Java Editor tips, code navigation and debugging aids. 

Extending JDT (60 min) - In the next one hour, we will take you through APIs and extension points that JDT exposes to enable you to extend and customize the Java tooling. Using these APIs, one could create their own cleaunps, refactorings, quick fixes and other utilities.

You may also be interested in Ayush's talk What's new in Java 7 (30 min). This talk intends to describe new features of Java 7 such as switch on strings, binary integral literals and underscores in numeric literals, multi-catch and precise rethrow, diamond, try with resources, etc. The talk will also be interesting to those who want to know the status of Java 7 work in Eclipse compiler.

The three of us will be around the whole day, and would love to answer any questions or get into interesting discussions around JDT :)

See you at Eclipse Day!

Monday, April 25, 2011

Evaluating expressions in JDT Debugger


You can use the Display View to type in an expression and evaluate it in the context of the current stack frame. (The name Display is not great - see bug 342144).

- Use content assist to type expressions

- Select the expression and use Ctrl+Shift+I (Inspect) to show the result in a pop-up. You can also invoke the Inspect command from the context menu.

- Press Ctrl+Shift+I again to persist the result in the Expressions view.

See also Eclipse help.