如何使用Eclipse的显示视图进行调试?
在下面的链接中,它解释了“显示视图允许您以剪贴簿类型的方式操作实时代码(参见图 8)。要操作变量,只需在显示视图中键入变量的名称,然后您就可以迎接熟悉的内容协助。”
http://www.ibm.com/developerworks/library/os-ecbug/
但是,我我无法让它正常工作。我打开了视图,但所有按钮都被禁用。我尝试过在运行和不运行调试时将代码放入视图中,在视图中选择代码,在其他视图中选择代码,但视图上启用的唯一按钮是“清除控制台”。
关于我做错了什么的建议?
At the link below it explains that the "display view allows you to manipulate live code in a scrapbook type fashion (see Figure 8). To manipulate a variable, simply type the name of the variable in the Display view, and you'll be greeted with a familiar content assist."
http://www.ibm.com/developerworks/library/os-ecbug/
However, I am having trouble getting it to work. I have the view open but all the buttons are disabled. I have tried putting code in the view, selecting code in the view, selecting code in other views, while running and while not running debug, but the only button that is ever enabled on the view is "clear console".
Suggestions on what I am doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以将
Display
视图视为可以在运行时检查各种变量和布尔表达式的位置。当您的调试器冻结在断点上时,例如开始键入对象变量的名称,当您开始调用方法或字段以访问更深的类数据结构时,您将获得自动完成功能。然后,当您选择/标记需要检查的部分或所有内容时,“显示”视图上的按钮将是可单击的。您始终可以在选择上执行Ctrl+Shift+I
快捷键来查看选择的当前运行时状态,即变量、对象、布尔表达式等You can view the
Display
view as a place where you can inspect all sorts of variables and boolean expressions during runtime. While your debugger is frozen on a breakpoint start typing the name of an object variable for instance and you'll get autocomplete functionality as you start calling methods or fields to reach deeper class datastructures. Then when you select/mark the portion you need to inspect or everything, the buttons on the Display view will be clickable. You can always perform theCtrl+Shift+I
shortcut on the selection to view what's the current runtime state of your selection i.e. variable, object, boolean exrepssion etc我认为这个强大功能应该更频繁地使用。
Window ->显示视图-> (搜索)Display
myObject.getSomeData();
,您可以自动完成(Ctrl+空格)不知道为什么默认情况下不存在此视图,它应该是!
I think this powerful feature should be used way more often.
Window -> Show View -> (search for) Display
myObject.getSomeData();
, you can autocomplete (Ctrl+Space)Not sure why this view is not there by default, it should be !
从 Eclipse Photon 版本 (4.8.0) 开始,
可以在
Debug Shell
内执行相同的功能。我通过以下方式执行此操作:Debug Shell
执行所选文本
,或显示评估所选文本的结果
我之所以包含此答案,是因为截至 2018 年,随着 Photon 版本的发布,我无法获得显示视图可以以任何身份工作甚至显示。但我能够通过这种方法完成相同的工作。
As of Eclipse Photon Release (4.8.0)
This same functionality can be performed inside the the
Debug Shell
. I do this by:Debug Shell
Execute Selected Text
, orDisplay Result of Evaluating Selected Text
I'm including this answer because as of 2018, with the Photon Release, I was unable to get the Display view to work in any capacity or to even show up. But I was able to perform the same work through this method.
当您停在断点处时,您可以将代码写入或粘贴到“显示”视图中,选择它,然后按 Ctrl+Shift+I 检查(即评估)选择。
When you've stopped at a breakpoint, you can write or paste code into the Display view, select it, and press Ctrl+Shift+I to inspect (i.e. evaluate) the selection.
它只能在调试中运行时起作用,并且您只能操作当前线程上下文中存在的变量,这意味着您需要在要检查的变量所在的位置(或之后)放置一个断点变得活跃。当您按住断点时,您可以使用显示选项卡与变量选项卡中可以看到的所有变量进行交互(执行代码片段、评估等)
It will only work while running in debug, and you can only manipulate variables that are live in the context of the currrent thread, which means that you need to place a breakpoint at (or just after) the point where the variables you want to inspect become active. Whilst you hold on the breakpoint you can use the Display tab to interact (execute code snippets, evaluate etc..) with all the variables that you can see in the Variables tab