4

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

私の2番目のウィンドウは次のように始まります:

% jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8000
4

3 に答える 3

5

残念ながら、jdb のブレークポイントには、条件付きブレークポイントや「n 回ごとに停止」などの優れた機能はありません。

ただし、とにかくリモートで接続しているため、ほとんどのエディターでリモート マシンに接続できるため、エディターでデバッガーを使用することを検討することをお勧めします。ほとんどのデバッグ作業は JVM で行われ、表示のみがエディターによって行われるため、jdb を使用するよりもそれほど遅くはありません。

于 2009-12-07T01:15:08.550 に答える
3

これはあなたの質問に正確に答えているわけではありませんが、簡単な回避策は、グローバルカウンター変数を設定して実行することです

if(counter>=num_skips) 
    {counter++;} //set breakpoint on this line
else 
    {counter++;}
于 2009-12-07T08:29:57.870 に答える
2

eclipsenetbeansのような ide を使用しても問題ありませんか?
どちらもヒットカウンターとその他の形式の条件付きブレークポイントを提供します。

于 2009-12-07T01:11:34.267 に答える