在 Eclipse 调试器中查看全局/静态/继承变量
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5665182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
view global/static/inherrited variables in eclipse debugger
提问by drew
This is a minor annoyance for me that keeps coming up. When I'm debugging a program I can see variables in the immediate scope, but I can't see variables which are global, static, or variables inherited by 'this' class. The only way I know how to get these values for testing is to create a dummy variable to store the variable I want within scope of a given function, which isn't efficient or elegant.
这对我来说是一个不断出现的小烦恼。当我调试程序时,我可以看到直接作用域中的变量,但我看不到全局变量、静态变量或“这个”类继承的变量。我知道如何获取这些值进行测试的唯一方法是创建一个虚拟变量来存储我想要的变量在给定函数的范围内,这既不高效也不优雅。
Is there an easier way to see the value of any/all of the three variable types I mentioned while stepping through the debugger?
有没有更简单的方法来查看我在调试器中提到的任何/所有三种变量类型的值?
Thanks
谢谢
采纳答案by sbridges
You can use the Expression Viewto watch an arbitrary expression, including static and global variables.
您可以使用表达式视图查看任意表达式,包括静态和全局变量。
Another handy view is the Displays View, which allows you to execute arbitrary code.
另一个方便的视图是Displays View,它允许您执行任意代码。
回答by no.good.at.coding
Expanding the entry for this
in the Variables
view in the Debug Perspective
should let you view all of those (non-static) members already, by default.
扩大条目this
在Variables
视图Debug Perspective
应该让你查看所有的(非静态)成员已经是,默认情况下。
To view constants and static members, in the Variables
view's menu (opened by clicking the little down arrow at the top right of the view), choose Java > Show Static Variables
or Show Constants
要查看常量和静态成员,请在Variables
视图菜单(通过单击视图右上角的小向下箭头打开)中,选择Java > Show Static Variables
或Show Constants
回答by DaveH
In the Debug Perspective, open the Variables view, click on the downward pointing arrow at the top right of the pane and select Java / Show Static Variables
在 Debug Perspective 中,打开 Variables 视图,单击窗格右上角的向下箭头并选择 Java / Show Static Variables