2009-12-07 28 views
4

如何在jdb中跳過一個設定次數的斷點?如何在Java的jdb中跳過一個設定次數的斷點?

加多寶的幫助,提供了這種提示:

!!      -- repeat last command 
<n> <command>    -- repeat command n times 
# <command>    -- discard (no-op) 

當我嘗試但是跳過斷點次數n號,這樣的:

80 cont 

或像這樣:

80 run 

jdb barfs:

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 

回答

5

不幸的是,jdb中的斷點不提供任何奇特的功能,如條件斷點或「每n次停止一次」。

但是,由於無論如何您都要遠程連接,因此您可能需要考慮在編輯器中使用調試器,因爲大多數編輯器都會讓您連接到遠程計算機。由於大多數調試工作都是在JVM中完成的,並且只能通過編輯器進行顯示,所以不會比使用jdb慢得多。

+0

嘿。 ;)我的編輯器目前是Notepad ++! :D謝謝你的建議。 – iokevins 2009-12-07 03:33:47

3

這是不完全回答你的問題,而是一個快速的解決方法可能是設置一些全局計數器變量並做

if(counter>=num_skips) 
    {counter++;} //set breakpoint on this line 
else 
    {counter++;} 
+0

嘿,那很聰明。 :) 謝謝你的提示! – iokevins 2009-12-07 17:06:23

+0

沒問題,很樂意幫忙。 – Roman 2009-12-08 06:50:40