简体   繁体   English

有没有办法在 NetBeans 调试器中查看程序计数器?

[英]Is there a way to see the program counter in NetBeans debugger?

Is there a way to see the line/method that's currently executing in the NetBeans debugger, without doing step-by-step execution?有没有办法查看当前在 NetBeans 调试器中执行的行/方法,而无需逐步执行?

I know I could set breakpoints, but I'm curious if there's a way to do it without breakpoints.我知道我可以设置断点,但我很好奇是否有没有断点的方法。

VisualVM与 Java JDK 捆绑在一起,可以向您显示实时可跟踪的方法执行。

From the right border of the code editor, you should see a lot of colored short lines (which indicate warnings, errors, searches etc), among them there is an line with an small green box in the middle of the line, click it and you will locate the program counter.从代码编辑器的右边框,你应该看到很多彩色短线(表示警告、错误、搜索等),其中有一行中间有一个小绿框,点击它并您将找到程序计数器。

The line is small so not easy to click.线很小,所以不容易点击。

In most IDEs, there is a tool bar button and menu to locate current executing line.在大多数 IDE 中,都有一个工具栏按钮和菜单来定位当前执行的行。

@Leon is showing how to locate the current position of the caret , which does not necessarily coincide with the program counter. @Leon 正在展示如何定位插入符号的当前位置,这不一定与程序计数器重合。

In the right border of the code editor, there are, indeed, small colored lines (which indicate lines where there are warnings, errors, breakpoints, etc.), among which is one line with a small box in its middle.在代码编辑器的右边框中,确实有彩色的小线(表示有警告、错误、断点等的行),其中一行中间有一个小框。 But it shows the line where the caret happens to be located .但它显示了插入符号碰巧所在

This is not necessarily the location of the program counter because the caret position may have changed since reaching the last breakpoint or other line of code.不一定是程序计数器的位置,因为插入符号位置可能在到达最后一个断点或其他代码行后发生了变化。

The program counter being represented by a (too-small) green block arrow in the left margin of the code editor, where a breakpoint symbol and others can further obfuscate it, no amount of enlarging the editor window contents will make it significantly easier to find the program counter.程序计数器由代码编辑器左边距中的(太小)绿色块箭头表示,其中断点符号和其他符号可以进一步混淆它,再放大编辑器窗口内容也不会使它更容易找到程序计数器。

在此处输入图片说明

Of course, the program counter will change to where it will be visible by stepping out of, into, or over whatever's at the current program counter line.当然,程序计数器将通过跳出、进入或越过当前程序计数器行上的任何内容而更改为可见的位置。 This isn't ideal.这并不理想。 And there's a better way.还有更好的方法。

Alt+Shift+9 will open the Debugging window (below), which will show a number that represents the line number of the program counter . Alt+Shift+9将打开Debugging窗口(下图),其中将显示一个代表程序计数器行号的数字

在此处输入图片说明

Moreover, an expanded + dropdown indicator will show a line containing the same pertinent info, but double-clicking this line will open the window containing the program counter and clearly enough show it .此外,展开的+下拉指示符将显示包含相同相关信息的一行,但双击该行将打开包含程序计数器的窗口并足够清楚地显示它

At least that's my experience so far.至少这是我目前的经验。

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

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