Debugging AST transforms in Eclipse

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging AST transforms in Eclipse

Val Huber
Hi…

I am running Eclipse 3.6 with Groovy 2.1.0xx=20101007… I have built a trial AST transform, but having real trouble figuring out how to debug it.

I can tell it is running by inserting a divide by 0 as shown in the screen shot.


What I want to do is better debug my AST.  I have tried setting breakpoints in the AST - they are not active for either standard Groovy or scripts.

As a fallback, I have tried:
System.println ("Statement: " + existingStatements)
or  System.out.println("Statement: " + existingStatements)
, but see nothing on either the Console or Error Log views.  I have also not been able to find anything by trolling the web.

Can you recommend a way to debug these ASTs?

Thanks,
Val

Reply | Threaded
Open this post in threaded view
|

Re: Debugging AST transforms in Eclipse

Andy Clement
Hi

Your system.out calls are likely to appear on the console for the eclipse you are launching (not the console that shows up in the eclipse when you are using it).  Start eclipse with the  -consolelog option and you may see them in the extra window that appears.

The transforms are loaded internally by the compiler that is running to build your project, hence you can't really debug them simply by setting a breakpoint and building a project - you aren't running the compiler in debug mode when you do that.

To debug them with breakpoints you could probably launch a runtime workspace (in debug mode) from your existing eclipse.  Actually this will also cause you to see your sysout calls in the host eclipse console view.

Andy

On 21 October 2010 20:32, Val Huber <[hidden email]> wrote:
Hi…

I am running Eclipse 3.6 with Groovy 2.1.0xx=20101007… I have built a trial AST transform, but having real trouble figuring out how to debug it.

I can tell it is running by inserting a divide by 0 as shown in the screen shot.


What I want to do is better debug my AST.  I have tried setting breakpoints in the AST - they are not active for either standard Groovy or scripts.

As a fallback, I have tried:
System.println ("Statement: " + existingStatements)
or  System.out.println("Statement: " + existingStatements)
, but see nothing on either the Console or Error Log views.  I have also not been able to find anything by trolling the web.

Can you recommend a way to debug these ASTs?

Thanks,
Val


Reply | Threaded
Open this post in threaded view
|

Re: Debugging AST transforms in Eclipse

Val Huber
Thanks for getting back so fast!  I will give it a try...

I will not bug you, but I would like to show you what we are planning - you may find it of interest…

Thanks,
Val

On Oct 21, 2010, at 8:47 PM, Andy Clement wrote:

Hi

Your system.out calls are likely to appear on the console for the eclipse you are launching (not the console that shows up in the eclipse when you are using it).  Start eclipse with the  -consolelog option and you may see them in the extra window that appears.

The transforms are loaded internally by the compiler that is running to build your project, hence you can't really debug them simply by setting a breakpoint and building a project - you aren't running the compiler in debug mode when you do that.

To debug them with breakpoints you could probably launch a runtime workspace (in debug mode) from your existing eclipse.  Actually this will also cause you to see your sysout calls in the host eclipse console view.

Andy

On 21 October 2010 20:32, Val Huber <[hidden email]> wrote:
Hi…

I am running Eclipse 3.6 with Groovy 2.1.0xx=20101007… I have built a trial AST transform, but having real trouble figuring out how to debug it.

I can tell it is running by inserting a divide by 0 as shown in the screen shot.

<AST.png>

What I want to do is better debug my AST.  I have tried setting breakpoints in the AST - they are not active for either standard Groovy or scripts.

As a fallback, I have tried:
System.println ("Statement: " + existingStatements)
or  System.out.println("Statement: " + existingStatements)
, but see nothing on either the Console or Error Log views.  I have also not been able to find anything by trolling the web.

Can you recommend a way to debug these ASTs?

Thanks,
Val



Reply | Threaded
Open this post in threaded view
|

Re: Debugging AST transforms in Eclipse

Val Huber
In reply to this post by Andy Clement
Hello, and thanks again for the help…

I am new to running Eclipse under Eclipse, so please bear with me.

I set up a debug config like this in my "Host Eclipse":


This does start a new "Target Eclipse", and I see various threads under my Host Eclipse Debug perspective.

Now in the Target Eclipse/Project,  I put the jar containing my AST under the lib folder.  The target project seems to compile ok (I can see the class, no bad indications in Java Editor), but I not seeing anything to debug in Host Eclipse:
  1. I do not hit a breakpoint, and 
  2. the Console Log does not show my print statements; it is just this:

>FULL BUILD STATS for: demoapp
>   compiled 3287 lines in 878ms:3743.7lines/s
>   parse: 63 ms (7.1%), resolve: 188 ms (21.4%), analyze: 6 ms (0.6%), generate: 51 ms (5.8%)

So, I am stumped….  Suggestions?

Thanks,
Val



On Oct 21, 2010, at 8:47 PM, Andy Clement wrote:

Hi

Your system.out calls are likely to appear on the console for the eclipse you are launching (not the console that shows up in the eclipse when you are using it).  Start eclipse with the  -consolelog option and you may see them in the extra window that appears.

The transforms are loaded internally by the compiler that is running to build your project, hence you can't really debug them simply by setting a breakpoint and building a project - you aren't running the compiler in debug mode when you do that.

To debug them with breakpoints you could probably launch a runtime workspace (in debug mode) from your existing eclipse.  Actually this will also cause you to see your sysout calls in the host eclipse console view.

Andy

On 21 October 2010 20:32, Val Huber <[hidden email]> wrote:
Hi…

I am running Eclipse 3.6 with Groovy 2.1.0xx=20101007… I have built a trial AST transform, but having real trouble figuring out how to debug it.

I can tell it is running by inserting a divide by 0 as shown in the screen shot.

<AST.png>

What I want to do is better debug my AST.  I have tried setting breakpoints in the AST - they are not active for either standard Groovy or scripts.

As a fallback, I have tried:
System.println ("Statement: " + existingStatements)
or  System.out.println("Statement: " + existingStatements)
, but see nothing on either the Console or Error Log views.  I have also not been able to find anything by trolling the web.

Can you recommend a way to debug these ASTs?

Thanks,
Val



Reply | Threaded
Open this post in threaded view
|

Re: Debugging AST transforms in Eclipse

Andrew Eisenberg
I am not actually convinced that this is the best way to debug your ast transform.

This may work:

1. Create a groovy script (ensure it is matched by a script filter, see Preferences -> Groovy -> Compiler)
2. Have this script use your transform in some way.
3. Set a breakpoint somewhere in the transform
4. Perform Debug as -> Groovy script on your script

This should work because we are ensuring that the script gets compiled at runtime.


On Fri, Oct 22, 2010 at 7:18 AM, Val Huber <[hidden email]> wrote:
Hello, and thanks again for the help…

I am new to running Eclipse under Eclipse, so please bear with me.

I set up a debug config like this in my "Host Eclipse":


This does start a new "Target Eclipse", and I see various threads under my Host Eclipse Debug perspective.

Now in the Target Eclipse/Project,  I put the jar containing my AST under the lib folder.  The target project seems to compile ok (I can see the class, no bad indications in Java Editor), but I not seeing anything to debug in Host Eclipse:
  1. I do not hit a breakpoint, and 
  2. the Console Log does not show my print statements; it is just this:

>FULL BUILD STATS for: demoapp
>   compiled 3287 lines in 878ms:3743.7lines/s
>   parse: 63 ms (7.1%), resolve: 188 ms (21.4%), analyze: 6 ms (0.6%), generate: 51 ms (5.8%)

So, I am stumped….  Suggestions?

Thanks,
Val



On Oct 21, 2010, at 8:47 PM, Andy Clement wrote:

Hi

Your system.out calls are likely to appear on the console for the eclipse you are launching (not the console that shows up in the eclipse when you are using it).  Start eclipse with the  -consolelog option and you may see them in the extra window that appears.

The transforms are loaded internally by the compiler that is running to build your project, hence you can't really debug them simply by setting a breakpoint and building a project - you aren't running the compiler in debug mode when you do that.

To debug them with breakpoints you could probably launch a runtime workspace (in debug mode) from your existing eclipse.  Actually this will also cause you to see your sysout calls in the host eclipse console view.

Andy

On 21 October 2010 20:32, Val Huber <[hidden email]> wrote:
Hi…

I am running Eclipse 3.6 with Groovy 2.1.0xx=20101007… I have built a trial AST transform, but having real trouble figuring out how to debug it.

I can tell it is running by inserting a divide by 0 as shown in the screen shot.

<AST.png>

What I want to do is better debug my AST.  I have tried setting breakpoints in the AST - they are not active for either standard Groovy or scripts.

As a fallback, I have tried:
System.println ("Statement: " + existingStatements)
or  System.out.println("Statement: " + existingStatements)
, but see nothing on either the Console or Error Log views.  I have also not been able to find anything by trolling the web.

Can you recommend a way to debug these ASTs?

Thanks,
Val