简体   繁体   English

在Eclipse Debugger(for Java)中,有没有办法检查任意值?

[英]In the Eclipse Debugger (for Java), is there a way to inspect arbitrary values?

I'm wondering if there is a way to look at the values of non-declared variables as they get passed into a function, after that function has been executed . 我想知道在执行该函数之后是否有一种方法可以查看非声明变量的值,因为它们被传递到函数中。 For example, if I am debugging and the line 例如,如果我正在调试和行

foo.setBar(baz.getBar());

has already been passed (but is still within scope), how can I see the value of what got passed in to setBar() ? 已经通过(但仍在范围内),我如何才能看到传入setBar() I know that I can see this many other ways, for instance by stepping into the setBar() call, or by assigning baz.getBar() to a temporary variable - but that's not what I'm asking. 我知道我可以看到很多其他方法,例如通过插入setBar()调用,或者将baz.getBar()分配给临时变量 - 但这不是我要问的。

Edit: Basically, I feel penalized (by losing the ability to see certain information) while debugging, just because I'm not declaring every variable. 编辑:基本上,我在调试时感到受到惩罚(通过失去查看某些信息的能力),因为我没有声明每个变量。

And, I know I could inspect bar after the fact (if I know it hadn't changed) but in this case it's not so simple because I'm dealing with objects that aren't just POJOs or JavaBeans (the object that brought this question up is an HTTP request - and yes, I already did try inspecting it). 并且,我知道我可以在事后检查bar (如果我知道它没有改变)但在这种情况下它不是那么简单,因为我正在处理不仅仅是POJO或JavaBeans的对象(带来这个的对象)问题是HTTP请求 - 是的,我已经尝试过检查它。

在Debug透视图中,打开显示窗口(Window => Show View => Display),编写要显示的代码(例如, baz.getBar() ),选择它,然后右键单击并选择“Display”或使用快捷方式显示其值。

A by far easier way is to select an expression (here: baz.getBar()) and press CTRL+SHIFT+I (for inspect). 一个更简单的方法是选择一个表达式(这里:baz.getBar())并按CTRL + SHIFT + I(用于检查)。 This opens a tooltip like window with all you want to know. 这会打开一个工具提示,就像你想知道的所有窗口一样。

当然,您可以使用“表达式”视图(窗口 - >显示视图 - >表达式)。

in your Expressions view, add the following expression 在“表达式”视图中,添加以下表达式

baz.getBar()

and it will be dispayed while debugging (if it is visible to the debugger ofcourse) 并且它将在调试时调度(如果调试器可以看到它)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM