Name: rm29839 Date: 11/14/97
package sun.tools.debug.* : Debugging java applications
When the debugee VM hits a breakpoint (either user specified or from
a step/next call to RemoteThread) the debugger callback is notified. Prior
to this notification, all threads in the debugee's VM are
suspended. This allows the debugger to inspect thread information. When
control is given back to the VM (via step/next), ALL threads are issued a
resume() command from resumeLastSuspendedThreads(). Unfortunately, the
sun.tools.debug API and the JVM do not distinguish suspending/resuming threads
for debugging purposes and suspending/resuming threads as part of the
debugee's normal execution. Thus a debugee thread that was meant to be
resumed ONLY by another debugee thread WILL be incorrectly resumed by the
debugger. This means that your debugee's behaviour may exhibit incorrect
results as a result of debugging it (waking up threads your application wanted
suspended)
For example, consider the following java code:
public MyClass extends Thread
{
public static void main (String args[])
{
// First thread
new MyClass().start();
try {
while (true) {
System.out.println("You should see this message");
sleep(1000);
}
}
catch (Exception e) { }
}
public void run()
{
// Second thread
suspend(); // I should never wake up
try {
while (true) {
System.out.println("YOU SHOULD NEVER SEE THIS MESSAGE!!!");
sleep(1000);
}
}
catch (Exception e) { }
}
}
The CORRECT behaviour of this program is to display
"You should see this message" every second. The second thread, however, is
suspended immediately and is never resumed by main. Thus you should never see
the second message.
If you attempt to single step this program from jdb (or the debug API
in general) the second thread is resumed and you will see its message also!
This is incorrect!
The JDK exhibits this behaviour on all WIN NT, AIX, Solaris
I believe this is a major design flaw in the sun.tools.debug package.
You should be able to
a) distinguish between threads that have been suspended by the debugee and
those that have been suspended by your debugger
b) resume only the threads the debugger wants to resume (ie. only those that
were suspended by the debugger)
(Review ID: 19636)
======================================================================
- duplicates
-
JDK-4099395 STD: User suspended threads resume on "cont"
-
- Closed
-