[GRADLE-2197] Full debugging information not included in compiled classes with new Milestone-9 compiler Created: 26/Mar/12  Updated: 04/Jan/13  Resolved: 01/Apr/12

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-9
Fix Version/s: 1.0-rc-1

Type: Bug
Reporter: Gradle Forums Assignee: Unassigned
Resolution: Fixed Votes: 0


 Description   

Hi guys,

Attempting to upgrade to milestone-9 and discovered a bunch of our integration tests failing. After a bit of hunting around, I discovered the problem is that the new non-ant Javac compiler is not including variable name debugging in the generated classes. Frameworks like Spring tend to use this to do some of their nifty wiring (which was the cause of the failure)

I've changed our build script to get around it with something like:

compileJava.options.debugOptions.debugLevel = "source,lines,vars"
compileTestJava.options.debugOptions.debugLevel = "source,lines,vars"

Justing wondering:
a) was this change intentional?
b) if so, would definately be worth adding it to the milestone-9 breaking changes.

Thanks for the awesome work!
Joel



 Comments   
Comment by Gradle Forums [ 26/Mar/12 ]

Hello Joel,
thanks for your efforts to pointing out that problem. I think this change wasn't intentional. I would like to reproduce your problem. Can provide a tiny sample project to reproduce this problem.

Comment by Gradle Forums [ 26/Mar/12 ]

Hi Rene,

I've created a small sample, using javap to print out the class file information:

git://github.com/joelrobotham/gradle9-no-debugging.git

Cheers,
Joel

Comment by Gradle Forums [ 26/Mar/12 ]

Both the Ant javac task and the javac command-line compiler use the same defaults as the new Gradle Java compiler integration - they will generate debug info for sources and lines, but not for vars. Also I can't find any indication that our old Ant-based compiler integration (which is still available by setting `options.useAnt=true`) ever generated debug info for vars by default. Therefore I don't yet understand why some people started to get problems with m9. Any pointers are appreciated.

Comment by Gradle Forums [ 26/Mar/12 ]

If I compile from the command line using javac without specifying any debugging parameters, as suggested, you get source and lines, but not variables.

When I show the debug info when using the ant compiler through gradle, it explicitly passes in a -g which causes all source, lines and vars to be included. (without specifying anything in the build script)

For the new gradle compiler integration, there's no compiler arguments relating to debugging info unless you explicitly provided them in the build script. (hence we only get source and lines)

Comment by Gradle Forums [ 26/Mar/12 ]

I downgraded back to milestone 8 when I noticed I could no longer access debug info in IntelliJ, and I didn't have time to look into it further.

My preference would be for it to work the way it previously did, even if one can explicitly configure the project to add the debug info like Joel pointed out above.

Comment by Szczepan Faber [ 15/May/12 ]

Please try out the latest Gradle (rc-3 ATM). The debug info on local variables is included by default!

Comment by Brian Harris [ 01/Jun/12 ]

Today I build REL_1.0-rc3 branch from source, unzipped the resulting -all zip file in the distribution directory, ran a build on my own project in windows using bin/gradle.bat with -Xdebug flags set in GRADLE_OPTS, attached to it with a dummy intellij project that references the rc3 sources, and intellij said the local variable info was unavailable: the typical message when debugging symbols not enabled.

So next I added to build.gradle (in root of gradle repo) this:

allprojects { tasks.withType(Compile)

{ Compile compile -> compile.options.debug=true }

}

Did same process as above but still no debug symbols. Also tried compile.options.compilerArgs = ['-g'] but it didn't work either.

Ideas?

Comment by Niclas Hedhman [ 03/Jun/12 ]

Brian,
Shouldn't you use org.gradle.jvmargs in GRADLE_OPTS to pass on the -g flag??

http://gradle.org/docs/current/userguide/userguide_single.html#sec:gradle_configuration_properties

But in today's time and age, debugging information should be on by default. I don't see why it should be removed for mainstream development, so no settings should be required.

Comment by Brian Harris [ 03/Jun/12 ]

Well, the -g needs to be passed to javac not java.

Agreed that debug symbols should be on by default; it looks like this issue was raised in agreement. I'm just confused that it's marked Fixed given my experience. Maybe it just isn't working when building gradle itself, like the bootstrapper is doing something special.

Comment by Szczepan Faber [ 10/Jul/12 ]

@Brian,

The reason is that REL_1.0-rc3 is built with a Gradle version that is not rc-3 (see the wrapper setting).

The problem is fixed, though

Comment by Daz DeBoer [ 11/Jul/12 ]

@Brian

To clarify: if you just get the source to the REL_1.0-rc3 branch and run ./gradlew install, then you're not actually using Gradle 1.0 to build, so the resulting Gradle jars may not have debug info.

Instead, try downloading Gradle 1.0 and compiling some source files with the downloaded version: you should find that any jar files produced this way will have the debug information included.

Generated at Wed Jun 30 12:15:21 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.