In my java eclipse debugger the variables field is always empty and the step over and step into icons are disabled help me with this issues
I did try all the options from google like adding checking variables attributes in preferences menu but am still unable to find a solution help me friends
This is a issue that is faced sometimes, somethings you might try out are:-
-> Close variable window and open again
-> Reset the perspective and see if variables now show up.
-> Close the variables tab and then reset the perspective, this should reopen the working variables tab.
-> If none of them still works , you can right click on the variable and select inspect, then it should come up in a popup window
Incase you do not know how to show vairables view, Window --> Show View --> Variables
Reference
In order to see the value of variables, you have to set a breakpoint.
See the documentation here: EclipseDebugging
If you already set it, try resetting the perspective
Related
I'm using VSCode for Java development, and at some point in time, the debugging variables do not show the toString() results by default. I have to click on the eyeball icon that has "Click to expand" tooltip. In the example below, the Boolean before and after expanding. Stepping through the code cases the view to reset to non-expanded. How do I get the value to show by default?
You can enable this setting debug.autoExpandLazyVariables
I am not sure if it is recent issue or it was from the "beginning". Is it normal behavior that we can't see the value of variable in debug mode when we tick on it? (It says ctr+shift+I to watch).
You can also use ctrl + shift + D to display the selected content.
Whatever you are trying to get the contents debug should reach that code.
No, this isn't normal behaviour in Eclipse. As soon as a thread hits a breakpoint and enables the debugging perspective, you should be able to inspect your variables either by hovering, Ctrl+Shift+I or with "Inspect" in your context menu.
In what state is Eclipse when you are trying to watch the variable?
How can I watch the contents of several variables (for example, TreeSet's) simultaneously? I can watch contents of one TreeSet, clicking on it in "Variables" window, but I have no idea how to do that for several variables.
You can use Expressions windows: while debugging, menu window -> Show View -> Expressions, then it has place to type variables of which you need to see contents
You can add a watchpoint for each variable you're interested in.
A watchpoint is a special breakpoint that stops the execution of an application whenever the value of a given expression changes, without specifying where it might occur. Unlike breakpoints (which are line-specific), watchpoints are associated with files. They take effect whenever a specified condition is true, regardless of when or where it occurred. You can set a watchpoint on a global variable by highlighting the variable in the editor, or by selecting it in the Outline view.
You can do so by these ways.
Add watchpoint and while debugging you can see variable in debugger window perspective under variable tab.
OR
Add System.out.println("variable = " + variable); and see in console.
And how about selecting the text you want to watch, and then using the shortcut "Ctrl + shift + I"
I'm debugging my code to see if the variable is receiving new values during execution.
How can I watch it and make it stops when the value is changed by something?
I've got a CheckList and set the selectedValues with some values, and for some reason, the values selected are disappearing.
Use the outline view (Window -> Show View -> Outline) to select your variable. Right-click it and select Toggle Watchpoint. It will create a breakpoint for your variable. Right-click this breakpoint, select properties and leave only the checkbox "Field modification" enabled.
I think that this cannot be done for variables declared inside methods, although you can use it for class or instance variables.
You could use a breakpoint with a condition for the value.
You could set a breakpoint on the setter method for the value.
If the debugger does appear to help. esp if the problem doesn't appear when you debug it. You can add logging which can show you where a change is made. e.g.
log.info("Changed "+changeDescription, new Throwable("HERE"));
I'm using Eclipse to code Java (for Android) and I'm trying to debug the code as I normally do (i normally do C# though).
From what I can tell, debugging in Eclipse is really bad. I don't know if I'm doing something wrong, but it seems to be just awful.
This is the code that is being run, I get some sort of exception and I want to see what the Exception is, by breaking in the "catch"-clause and viewing the variable "e":
try
{
ConnectivityManager connectivityManager = (ConnectivityManager) this.getSystemService( Context.CONNECTIVITY_SERVICE );
NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
NetworkInfo mobNetInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
NetworkInfo.State state = mobNetInfo.getState();
}
catch(Exception e)
{
Log.v("MyAp", e.toString()); // I break on this line, and want to see what e is
}
The problem is that I cannot see "e" by holding my mouse over it (as I can in my beloved Visual Studio).
Now, I know that I can bring up the tab "Variables" which lists all variables accessible from when I'm breaking, but that's not optimal.
Just so I know - Eclipse has no way of "hovering" over the variable you are interested in, as in Visual Studio?
Edit
Thanks for the answers. However, still have the same problem =(
Go to Preferences-> Java-> Editor-> Hovers and tick the box 'Variable Values'. If you want Hover to happen automatically then leave the Key Modifier section blank.
There seem to be bugs in Eclipse related to this:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=317045
https://bugs.eclipse.org/bugs/show_bug.cgi?id=330061
https://bugs.eclipse.org/bugs/show_bug.cgi?id=286237
So, yes it is supposed to work, but it doesn't always. I'm having this issues on some classes. It seems to be consistent which classes work and which don't, probably related to what jar the class is coming from etc, but I have no real clue as to what causes it. Would love to see some reproduction scenario.
You can also highlight the variable, right click, and choose to watch it. Then it shows up on the watch tab. You can also set automatic break points that trigger on the exception being thrown rather than at a particular line of code. There is not 'hover' option to view the variable as in Visual Studio in recent versions of Eclipse.
This might seem a bit strange, but do you know that the code window has focus? I have observed that sometimes the appearance of the tooltip depends on whether a view has focus or not (which I guess is an SWT bug).
I have also found that in the "Debug" view (the tab with the little green bug as an icon) where it shows all the threads, Eclipse sometimes doesn't show the variable's values if the currently breakpointed thread isn't selected.
If anyone else runs across this problem, then you might have hit a breakpoint, but the currently running thread isn't the one highlighted in the "Debug" window.
As far as I can tell, you have to be in Debug view in order to hover over objects and see their properties. At least that's how my copy of Eclipse 3.4 works.
Of course, you also need to be in Debug view to have the Step Into, Step Over, Continues, etc... buttons...
Go to Preferences -> Java -> Editor -> Hovers, and click Restore Defaults.
Found it, Goto: Preferences > Java > Editor > Hovers - Javadoc (click on it and remove the ctrl+shift keys from there), then it should work normally.
I think that the correct answer is the #RogerThomas one.
Go to 'Window' -> 'Preferences' -> 'Java' -> 'Editor' -> 'Hovers'
Then check 'Variable Values'.
If the 'Variable Values' option collides with 'Combined Hover', uncheck last one or configure new keys for it.