在 Eclipse 中导航 Java 调用堆栈
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3256369/
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
Navigating Java call stack in Eclipse
提问by Mark
采纳答案by Riduidel
In the "debug perspective", show the view named "debug". For each thread that is currently halted, this view shows the full call stack. Clicking on one element of this stack switches the editor view to display the corresponding class, and "variables" view will show variables of this stack element.
在“调试透视图”中,显示名为“调试”的视图。对于当前暂停的每个线程,此视图显示完整的调用堆栈。单击此堆栈的一个元素可切换编辑器视图以显示相应的类,“变量”视图将显示此堆栈元素的变量。
回答by Omry Yadan
you just click on the stack frame in the Debug view.
您只需单击调试视图中的堆栈帧。
回答by Pablo Santa Cruz
In the visual debugger, you will see the entire stack trace. Just CLICK on the level you want to inspect to do that. Definitely easier than using gdbcommands. :-)
在可视化调试器中,您将看到整个堆栈跟踪。只需单击要检查的级别即可。绝对比使用gdb命令更容易。:-)
回答by Brad Parks
Note that your "Debug Perspective" may be collapsed to "breadcrumb" view mode by default, which means you'll only see one line of the stack trace at a time.
请注意,默认情况下,您的“调试视角”可能会折叠为“面包屑”视图模式,这意味着您一次只能看到一行堆栈跟踪。
To fully expand it, and see the stack trace in a tree:
要完全展开它,并在树中查看堆栈跟踪:
- click on the down arrow in the top right corner of the Debug View.
- choose "Layout | Tree"
- 单击调试视图右上角的向下箭头。
- 选择“布局|树”
回答by Chris Halcrow
First, set one or more breakpoints in your code that you know will be hit, then debug your application in one of the following ways:
首先,在您的代码中设置一个或多个您知道会被命中的断点,然后通过以下方式之一调试您的应用程序:
- Ensure that the file that contains your
main
method is currently selected - Hit F11
- 确保
main
当前选择了包含您的方法的文件 - 按 F11
or
或者
- Right-click the file in Package Explorer that contains your
main
method - Select Debug As > Java Application
- 在包资源管理器中右键单击包含您的
main
方法的文件 - 选择调试为 > Java 应用程序
Eclipse should now show the 'Debug perspective' (this can be opened manually using Window > Perspective > Open Perspective > Debug)
Eclipse 现在应该显示“调试透视图”(可以使用 Window > Perspective > Open Perspective > Debug 手动打开)
Once one of your breakpoints has been hit, you should see a frame in the debug perspective titled 'Debug' (to open manually, use Window > Show View > Debug). It looks like this:
一旦命中了一个断点,您应该会在调试透视图中看到一个标题为“调试”的框架(要手动打开,请使用“窗口”>“显示视图”>“调试”)。它看起来像这样:
The area I've greyed-out is showing each step of the stack trace for the thread that is currently paused on the breakpoint. The actual part of the call stack that is currently being paused is highlighted in grey (so if you have multiple threads, you can see which one is currently paused by looking for the highlighted line). Clicking on any line of the stack trace view will reveal details (e.g 'variables' at that point in the stack)
我变灰的区域显示了当前在断点上暂停的线程的堆栈跟踪的每个步骤。当前正在暂停的调用堆栈的实际部分以灰色突出显示(因此,如果您有多个线程,则可以通过查找突出显示的行来查看当前暂停的是哪一个)。单击堆栈跟踪视图的任何一行将显示详细信息(例如堆栈中该点的“变量”)