如何在 jdb 中跳过一定次数的断点?
jdb 的帮助提供了以下提示:
!! -- repeat last command
<n> <command> -- repeat command n times
# <command> -- discard (no-op)
但是,当我尝试跳过断点 n 次时,如下所示:
80 cont
或者像这样:
80 run
jdb 酒吧:
main[1] 80 cont
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
Breakpoint hit: main[1] > Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.Exception in thread "event-handler" java.lang.NullPointerException
at com.sun.tools.example.debug.tty.TTY.printCurrentLocation(TTY.java:212)
at com.sun.tools.example.debug.tty.TTY.vmInterrupted(TTY.java:189)
at com.sun.tools.example.debug.tty.EventHandler.run(EventHandler.java:86)
at java.lang.Thread.run(Thread.java:619)
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
> Nothing suspended.
这里发生了什么?我怎样才能获得所需的行为?
版本:
> version
This is jdb version 1.6 (J2SE version 1.6.0_16)
Java Debug Interface (Reference Implementation) version 1.6
Java Debug Wire Protocol (Reference Implementation) version 1.6
JVM Debug Interface version 1.1
JVM version 1.6.0_17 (Java HotSpot(TM) Client VM, mixed mode, sharing)
澄清一下,我正在远程调试。例如,我的第一个窗口是这样开始的:
% java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n LZWDecompress
我的第二个窗口是这样开始的:
% jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8000
最佳答案
不幸的是,jdb 中的断点没有提供任何花哨的功能,例如条件断点或“每 n 次迭代停止”。
但是,由于无论如何您都是远程连接,您可能需要考虑在编辑器中使用调试器,因为大多数编辑器都允许您连接到远程机器。由于大部分调试工作是在JVM中完成的,只有显示是由编辑器完成的,所以不会比使用jdb慢多少。