在 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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 16:10:20  来源:igfitidea点击:

view global/static/inherrited variables in eclipse debugger

javaeclipsedebugging

提问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 thisin the Variablesview in the Debug Perspectiveshould let you view all of those (non-static) members already, by default.

扩大条目thisVariables视图Debug Perspective应该让你查看所有的(非静态)成员已经是,默认情况下。

To view constants and static members, in the Variablesview's menu (opened by clicking the little down arrow at the top right of the view), choose Java > Show Static Variablesor Show Constants

要查看常量和静态成员,请在Variables视图菜单(通过单击视图右上角的小向下箭头打开)中,选择Java > Show Static VariablesShow Constants

Show Static Variables

显示静态变量

回答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