Debugging a SourceChecker in IDE

6 views
Skip to first unread message

Ales

unread,
Oct 19, 2009, 3:28:33 PM10/19/09
to Checker Framework discussion
Hi all,

We are developing our own set of checkers based on the SourceChecker
from the framework.

I was wondering, is there any way how to configure an IDE (Eclipse,
Maia, etc.) to launch a debugging mode to see what is our
SourceChecker doing?

Is there anyone who configured his IDE in this way? Could you provide
an excerpt of your IDE configuration file?
Any hints which source directories to include in the buildpath and
where to find the main method to supply the parameters?

Thank you for any help,
Ales

Günther Noack

unread,
Oct 20, 2009, 10:52:36 AM10/20/09
to Checker Framework discussion
Hi!

I'm currently writing a diploma thesis implementing a type checker.
There are the steps I noted down for reproducing my Eclipse setup (on
Linux, assuming Eclipse and JDK6 or JDK7 are already installed):

How to set up Checkers and JSR308-langtools from scratch using Eclipse
1. Unpack the jsr308-langtools and the checker ZIP files in the same
directory. (There should be two folders, with the same names as the
ZIP files.)
2. In jsr308-langtools/make, run “ant build-javac build-javap”. This
creates JARs in jsr308-langtools/dist/lib, containing the JSR308
javac compiler and disassembler. The compiler has support for
“commented-out” style type qualifiers like /*@NonNull*/, which
makes it work better with current IDEs.
3. In the same directory, you may also wish to run “ant build”, which
among other things, creates a src.zip which has all the compiler
source code in it.
4. Ensure that Ant works in the Checkers directory. (This is a bit
more tricky on MacOS, at one point the Ant file must be changed
to run java with a -Xbootclasspath/p: argument pointing to the
javac.jar in jsr308-langtools.) Be aware that you may need to
modify build.preferences in case you have nonstandard paths.
5. Create an Eclipse project in the Checkers directory.
6. For easier linking, I created a symlink from checkers/langtools-
dist
to jsr308-langtools/dist.
7. Link to the javac.jar, doclets.jar and javadoc.jar from the
Checkers
project. (They are created into dist/lib in langtools. You may
need to run another special Ant target to create the Javadoc-
related
Jars.)
8. In the Eclipse project properties, go to “Build Path->Order and
Export” and make sure the “JRE system library” entry is
overshadowed
by the javac.jar, so the JSR308 compiler is seen instead of the
one installed in your JDK.
9. When setting up JUnit Run Configurations, give the following VM
argument:
-Xbootclasspath/p:${workspace_loc:checkers}/langtools-dist/lib/
javac.jar

Note 1: If developing on MacOS X, you'll possibly need to override the
-Xbootclasspath.
Note 2: For reference, here's my Eclipse .classpath file:
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="tests/src"/>
<classpathentry kind="lib" path="checkers.jar"
sourcepath="src"/>
<classpathentry kind="lib" path="lib/asmx.jar"/>
<classpathentry kind="lib" path="lib/javaparser.jar"/>
<classpathentry kind="lib" path="tests/junit.jar"/>
<classpathentry kind="lib" path="langtools-dist/lib/
doclets.jar" sourcepath="langtools-dist/lib/src.zip"/>
<classpathentry kind="lib" path="langtools-dist/lib/
javadoc.jar"/>
<classpathentry kind="lib" path="langtools-dist/lib/javac.jar"/
>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

I hope this helps. Let me know if it worked for you.

Best regards,
Günther

Adam Warski

unread,
Oct 22, 2009, 2:31:34 AM10/22/09
to checker-fram...@googlegroups.com
Hello,

I use Idea and do it maybe a bit simplistically, but it works ;).

First, you need to create a new JVM in Idea using the jars from a jdk7
distribution and the jars provided with the checkers framework.

To debug, I start the checker (using a small script) from the command
line and attach a remote debugger to it (then you can debug from any
IDE in fact) on port 5005:

#!/bin/bash
export PATH=/Users/adamw/jsr308/soylatte16-i386-1.0.3/bin:$PATH
export CLASSPATH=/Users/adamw/jsr308/checkers/checkers.jar:/Users/
adamw/jsr308/jsr308-typestate-checker/build
export DEBUGOPTS="-J-Xms48m -J-Xdebug -J-
Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

CHECKER=checkers.typestate.TypestateChecker

SOURCES=tests/work/work/Test6.java

javac $DEBUGOPTS -processor $CHECKER -sourcepath src -cp $CLASSPATH -d
build $SOURCES

Maybe this will help as well :)
Adam

Reply all
Reply to author
Forward
0 new messages