3

I just started developing Android apps in Eclipse. I usually code in Visual Studio, and there is one thing that I just cant figure out how to do in Eclipse:

For example, if i have the following method, and want to inspect the variable i:

public void Foo()
{
    int i = 1;
} 

In visual studio, I am able to set the breakpoint on the closing }, and can inspect the variable:

public void Foo()
{
    int i = 1;
} // <-- Breakpoint here

But in Eclipse, I'm only able to set it on the variable itself:

public void Foo()
{
    int i = 1; //<-- Here
} 

Which result in that i cannot inspect the variable, unless i add another line of code and break later in the method.

TL;DR: How do I inspect a variable in Eclipse while I'm in debug mode?

Johan
  • 35,120
  • 54
  • 178
  • 293

3 Answers3

1

Create a method exit breakpoint instead of a normal breakpoint.

Bananeweizen
  • 21,797
  • 8
  • 68
  • 88
1

Just F6 over your allowed breakpoint and cntrl+shift+i on the variable you wish to inspect. Jobs a good 'un. The closing brace is a line of code so the debugger won't skip out of the method thus losing your reference.

BrantApps
  • 6,362
  • 2
  • 27
  • 60
0

In debug mode you could right click on variable and you will see "Watch" click on that. In Expression tab you will see your variable changes. If you just want to see variable value you can do "Inspect" after right click on it.

someone
  • 6,577
  • 7
  • 37
  • 60
  • Watch will not update until the breakpoint has passed the row, right? And if i try to inspect a variable, all i get is "i cannot be resolved to a variable" – Johan Nov 25 '12 at 16:23
  • Yes you have to put debug point where you want to watch. in that case on the "int i = 1" I think that wont be a issue for debug your codes. – someone Nov 25 '12 at 16:34
  • The problem is that the value isnt set until the debugger has passed the breakpoint. – Johan Nov 25 '12 at 16:37