How to skip a breakpoint a certain number of times in java jdb?

How to skip a breakpoint a certain number of times in jdb?

jdb help contains this hint:

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

When I try to skip breakpoints n times, but like this:

 80 cont 

or like this:

 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. 

What's going on here? How can I get the desired behavior?

Version:

 > 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) 

To clarify, I debug remotely. For example, my first window starts as follows:

 % java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n LZWDecompress 

and my second window starts as follows:

 % jdb -connect com.sun.jdi.SocketAttach:hostname=localhost,port=8000 
+4
source share
3 answers

Unfortunately, breakpoints in jdb do not offer any fancy functions, such as conditional breakpoints or "stop all n iterations".

However, since you still connect remotely, you may need to use the debugger in your editor, since most editors will allow you to connect to remote computers. Since most of the debugging work is done in the JVM, and only editing is done by the editor, this will not be so slower than using jdb.

+5
source

This is not quite the answer to your question, but a quick solution could be to set some global counter variable and

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

Would you use an ideal like eclipse or is netbeans acceptable to you?
Both offer hitcounters and other forms of conditional breakpoints .

+2
source

All Articles