Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 329911

Summary: [Crossfire] 'suspend' should not put thread into suspended state
Product: [WebTools] JSDT Reporter: Grant Gayed <grant_gayed>
Component: DebugAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED WONTFIX QA Contact: Simon Kaegi <simon_kaegi>
Severity: major    
Priority: P1 CC: Michael_Rennie, thatnitind
Version: 3.3   
Target Milestone: Future   
Hardware: All   
OS: All   
Whiteboard:

Description Grant Gayed CLA 2010-11-10 10:15:57 EST
When a 'suspend' response is received with success == true, JSDT immediately sets the thread's state to suspended and sends a 'backtrace' request.  Neither of these should happen until the subsequent 'onBreak' event has been received.

I see the current implementation sometimes work with the Firefox back-end because Firefox suspends promptly enough that it successfully responds to the 'backtrace' request.  However IE does not suspend quite as quickly, so JSDT ends up in a state where it thinks it's suspended, which makes it not respond to the subsequent 'onBreak' event from IE.
Comment 1 Michael Rennie CLA 2010-11-12 16:20:53 EST
looks like we should handle suspending the same way we do stepping, spawn a 'suspending' thread that listens for the onBreak event for a given timeout, that way we can give users feedback that the thread is trying to suspend, but not actually suspended.
Comment 2 Michael Rennie CLA 2010-11-12 16:26:05 EST
we should also handle the case of delayed resuming.
Comment 3 Grant Gayed CLA 2010-11-12 16:31:56 EST
Should there be a finite timeout when waiting for the resulting onBreak?  It could validly take a long time for the onBreak to arrive if, for instance, there's currently a prompter being shown.

I had assumed that the suspend command would be finished as soon as its response was received, and that the onBreak would just be handled separately whenever it happened to come in.  I'm not sure if this approach would preclude giving the user the "I'm trying to suspend" feedback.
Comment 4 Michael Rennie CLA 2010-11-12 16:53:57 EST
(In reply to comment #3)
> Should there be a finite timeout when waiting for the resulting onBreak?  It
> could validly take a long time for the onBreak to arrive if, for instance,
> there's currently a prompter being shown.
> 

Its tough to say if the timeout should be finite, how long could it take to suspend? as you noted it be a very long time.

> I had assumed that the suspend command would be finished as soon as its
> response was received, and that the onBreak would just be handled separately
> whenever it happened to come in.  I'm not sure if this approach would preclude
> giving the user the "I'm trying to suspend" feedback.

The method would continue, as we would be spawning a new daemon thread and continuing on - see JavaScriptThread#suspendUnderlyingThread() for an example. Looking back at that code (JavaScriptThread#suspendUnderlyingThread()) I see we have the same challenge of a finite timeout as well, waiting for a suspend there can take a very long time. 

To simply test the idea of waiting for the onBreak event, we could remove the LOC state = SUSPENDED; from CFThreadReference line 168. The onBreak even is handled by default in the JavaScriptDebugTarget
Comment 5 Grant Gayed CLA 2011-09-12 14:07:21 EDT
Marking as P1, this seems important to address since the Suspend tool item is right there in a Debug view asking to be pressed by the user.  I don't think that providing user feedback while waiting for the suspend is essential, but leaving the client in a state where it doesn't handle the resulting onBreak event effectively disables this functionality.
Comment 6 Michael Rennie CLA 2013-11-12 13:58:17 EST
In a future release of Firebug, Crossfire support will be dropped completely in favour or JSD2 and RDP, as such no more bugs will be fixed for the Crossfire support.

See:
1. https://wiki.mozilla.org/Firebug/WeeklyUpdates/2013-11-05#Crossfire
2. https://getfirebug.com/wiki/index.php/JSD2_Adoption
3. https://wiki.mozilla.org/Debugger