Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check on debug symbol status with Eclipse?

While discussing another question I asked, @Aaron Digulla pointed out the following:

If you installed the Java SDK, there should be a "src.zip" file in the root directory of the Java installation. If it's missing, download Java again. Eclipse should find the source automatically and show it to you when you open the type JTable (or when you click on the line in the stack trace).

The file src.zip is present for me, but I still can't access the source of JTable like @Aaron said. What could be the problem? How can I solve this with Eclipse?

The "Unknown Source" worries me, though. it means your version of Java doesn't have debug symbols. Make sure that you a) use a SDK while developing, b) that your SDK contains debug symbols, c) don't tell the command java to strip debug symbols when it loads classes.

a) I'm using Eclipse, why shouldn't I being using SDK?

b) How do I know if my SDK contains debug symbols? And if it doesn't, how can I add them?

c) How can I check if Eclipse is telling java to strip debug symbols?

Sorry for these banal questions, but I feel like I don't fully understand the Java development process.

like image 640
Heisenbug Avatar asked Jun 01 '11 15:06

Heisenbug


People also ask

How do I debug a program in Eclipse?

Eclipse - Debugging Program. Debugging a Java Program. The quickest way to debug a Java program is to using the Package Explorer view. Right click on the java class that contains the main method.

How do I know if I'm debugging or not?

Switch to the "Debug" perspective and look at the Debug pane. If it looks like this, you're not debugging: And if it looks like this, you are debugging: Thanks for contributing an answer to Stack Overflow!

How to debug a Java application?

Right click on the java class that contains the main method. Select Debug As → Java Application. The same action can be performed using the Package Explorer by selecting the class that contains the main method and clicking Alt + Shift + D, J. Either actions mentioned above create a new Debug Configuration and use it to start the Java application.

How do I use the debug view of a program?

When the execution of a program is paused, the debug view can be used to inspect the call stack. The variables view can be used to inspect the value of variables. The run menu has menu items that allow you to Resume execution, step over a line of code, step into a function etc.


1 Answers

a) Eclipse comes with it's own Java compiler, so if you are using the Java Runtime Environment, you won't run into many issues, except that extras like jarsigner and possibly the JRE source code may be missing. The best way to verify your installation is through your package manager; however, if you installed by some other means, careful directory observation can usually differentiate the two (see below).

b) JRE libraries are typically compiled without debugging symbols present. SDK libraries typically have them. Java debugging is done by starting the JVM with command line options which open a debugging port. The SDK talks to the JVM requesting breakpoints be set through this port. Later if you decide to step the JVM, it also sends the step / jump / rewind debugging commands through this port. The "debugging" symbols are actually JVM bytecode tables, which reference which line of source code is in effect starting at a particular bytecode instruction. This allows debuggers to associate the running bytecodes with line numbers in the original source code.

c) Verify it by (from the menu) Window->Preferences (on the selector column) expand "Java", expand "Build Path" under "Java", and select "ClassPath variables". You will see a few variables, including one called "JRE_SRC", which should point to the src.zip file containing the public facing JRE library source code. It is a good idea to verify JRE_LIB at the same time.

A JDK home directory typically contains a "bin" sub-directory and a "jre" sub-directory, so if you only see a "bin" sub-directory, odds are good you are in a JRE home directory. With this knowledge, hopefully you'll be able to figure the rest out.

like image 81
Edwin Buck Avatar answered Sep 28 '22 04:09

Edwin Buck