tags:

views:

54

answers:

4

I have a strange problem that I never encountered before, with debugging in Eclipse. while debugging, when I break in new code, the variables in the function are not displayed in the "variables" window. The ones that are displayed are only those which were passed to the function as arguments, and they are displayed as arg(0), arg(1) etc, and not by thier names. when I want to watch or inspect a variable in the function, I get the message "such and such cannot be resolved". Some facts: 1. When I rome in the debug stack and look at other functions, the variables are displayed properly 2. The debug run is synchronised with my written code 3. The project that I work in is compiled with external tools (that are using ant). None of my fellow workers ever encountered such a problem although all of them compile with the external tool. 4. The eclipse is 3.2.1 version

A: 

Looks like you discard debug information during compiling. Check the command line parameters of your Ant-Task.

Arne
A: 

Make sure you have the 'Debug Perspective' open before running the code. That solved a similar issue for me once.

Ishtar
Thanks for your advice, I hope I will never have this problem again, but if I do I will try shifting to debbug mode although I am not fond of it.
RBY
+2  A: 

This is a typical behaviour if you compile code without the -g option.

In eclipse: right-click on the Project, select 'Properties' from the context menue and "Java Compiler". Check if "project specific settings" is enabled.

If it is enabled, check if all checkboxes in the lower area are selected, especially "Add variable attributes to generates class files".

If this checkbox is enabled but not selected, check it (press apply), if it is not enabled not selected, select "Configure Workspace Settings" and enable the missing functionality globally (my advice).


External tool - the javac command needs the -g option. Default behaviour (no -g) is not having local variable information. (Reference)

Andreas_D
Thanks, it seems that the -g has done the trick...
RBY
A: 

Another couple things.

  1. Make sure the JDKs you're compiling with and debugging with are the same
  2. If it's a genuine Eclipse error (e.g. Not one of the solutions posted above) you might get some joy out of upgrading.
karianna
1. the JDK's are the same. 2. I am sure I would, but I have to cpmply with the version my group is working with.
RBY