Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant configurations - Meaning of debuglevel attributes var lines and source

Tags:

javac

ant

Can you please explain the meaning of debug level attributes var , lines and source in Apache Ant. It is clear that this help to generate all debugging information helping the attribute debug=true.

  1. What is the purpose of defining debuglevel="lines,vars,source". Is this restricting the debug information?

  2. What is the role if each value 1. lines 2. vars 3. source ?

  3. Should I need to turn on debug to make this attribute works ?

The specification says:

Keyword list to be appended to the -g command-line switch. This will be ignored by all implementations except modern, classic(ver >= 1.2) and jikes. Legal values are none or a comma-separated list of the following keywords: lines, vars, and source. If debuglevel is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored.

like image 698
Kasun Avatar asked Mar 25 '14 22:03

Kasun


People also ask

What happens if DEBUG level is not set in ant?

If debuglevel is not specified, by default, nothing will be appended to -g. If debug is not turned on, this attribute will be ignored. Show activity on this post. In Ant, you must use both debug=true and debuglevel=... to get debugging to work.

How to pass command line arguments in Apache Ant?

Apache Ant Command Line Arguments Sometimes, project's task require arguments which will be passed to another process by using command line. Ant allows command line arguments, even arguments which contains space characters. It supports <arg> element to pass arguments and uses various attribute given below.

What is-L and-a command line argument in ant?

It is a single line command line argument having space characters. A command line argument with two separate options : -l and -a. when we run only ant from command line without any argument, Ant look for the default file build.xml and execute target.

What do ant developers think about compiler warnings?

The Ant developers are aware that this is ugly and inflexible – expect a better solution in the future. All the options are boolean, and must be set to true or yes to be interpreted as anything other than false. By default, build.compiler.warnings is true, while all others are false.


2 Answers

In Ant, you must use both debug=true and debuglevel=... to get debugging to work. The lines,vars,source basically links Java code back to the line number, the variable name in the source, and the name of the source itself. This way, tools like Findbugs and point back to the line in the source code even though they work on the classfile.

There's no difference between running a Java app that has this information embedded vs. not being embedded. In C, it use to make a difference. C debug information took up more room in the binary and C could be slower to execute because of the debug information embedded in the binary. This is not true in the Java world where the code is coded to an intermediate file that's interpreted by a Java Realtime Environment.

I have yet seen a Java shop that doesn't compile with this information embedded in the classfiles. Java is a runtime code, and the debugging information embedded in the code doesn't slow it down. JIT compiling greatly speeds things up, and that ignores the embedded debugging information. Besides, if speed is really that important, you shouldn't be using Java (Sorry. Truth hurts.1)

My recommendation is to go ahead and compile with debug on, and debuglevel set to lines,vars,source. It's probably more important to have this debugging information embedded than whatever possible microscopic speed improvement you'll see by removing it.


1. Before the nasty comments: I mainly working in the Java environment. There are many reasons why you may want to use Java over C or C++, but speed isn't one of them.

However, there's a difference between programming in 1980 when you had a 8085 chip running a full blazing 8 bits at 3MHz and now where even the junkiest system runs quad core 64bit chips running in the GHz realm. It's more important to write easy to maintain and debug programs than efficient programs.

like image 130
David W. Avatar answered Oct 23 '22 04:10

David W.


It sounds like you are getting confused by compile Java code from the command line vs using the Ant task.

The -g is a command line flag to passed to javac to compile the source files. For more information you can run javac -help and get the following output. In our build files - we just set debug=on inside the <javac> task to handle requesting the correct debugging information be written out.

    Usage: javac <options> <source files>
    where possible options include:
    -g                         Generate all debugging info
    -g:none                    Generate no debugging info
    -g:{lines,vars,source}     Generate only some debugging info
    -nowarn                    Generate no warnings
    -verbose                   Output messages about what the compiler is doing
    -deprecation               Output source locations where deprecated APIs are used
    -classpath <path>          Specify where to find user class files and annotation processors
    -cp <path>                 Specify where to find user class files and annotation processors
    -sourcepath <path>         Specify where to find input source files
    -bootclasspath <path>      Override location of bootstrap class files
    -extdirs <dirs>            Override location of installed extensions
    -endorseddirs <dirs>       Override location of endorsed standards path
    -proc:{none,only}          Control whether annotation processing and/or compilation is done.
    -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
    -processorpath <path>      Specify where to find annotation processors
    -d <directory>             Specify where to place generated class files
    -s <directory>             Specify where to place generated source files
    -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
    -encoding <encoding>       Specify character encoding used by source files
    -source <release>          Provide source compatibility with specified release
    -target <release>          Generate class files for specific VM version
    -version                   Version information
    -help                      Print a synopsis of standard options
    -Akey[=value]              Options to pass to annotation processors
    -X                         Print a synopsis of nonstandard options
    -J<flag>                   Pass <flag> directly to the runtime system
    -Werror                    Terminate compilation if warnings occur
    @<filename>                Read options and filenames from file
like image 42
mikemil Avatar answered Oct 23 '22 02:10

mikemil