开发者

Changing variables in realtime when debugging in eclipse?

Using Eclipse, when debugging is it p开发者_如何学编程ossible to change the value of variables during runtime of a project for testing purposes.

For example, say I have a method that returns the number 5 but for testing purposes i want to output 10 instead. This isn't the problem I'm facing its a little more complex but its just to get my idea across.


You should be able to set a break-point, go into debug mode, open the variables views and here change the content of the variables.

Changing variables in realtime when debugging in eclipse?


You can access variables through the Variables view. There you can right click on any variable and select "Change value ...".


Resources :

  • standford.edu - eclipse guide
  • help.eclipse.org - change var value


... and you can do much, much more:-) Just to give you and idea.
You may change the code during debug which is hot swapped and is effectively changed (recompiled) in given debug session. You may run given method run (e.g. after catching breakpoint) few times without rerunning debug -> use drop to frame feature on method stack.


After you have changed the code you have to save it (cntrl-S) to make it effective. You will see your running application respond to the code-change after the cntrl-S

I hope this works for you. it took me some time to figure this out.


Run your application in debug mode then go to variables window. select the parameter then change values according to your requirements. then save (ctrl+s). and go ahead with your changes. Hope this will help.

If variables window is missing. then goto eclipse window->show views->variables

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜