1) Although dbg will be dropped from being supported or bundled with PHPeclipse,...
[phpeclipse.git] / net.sourceforge.phpeclipse.debug.core / src / net / sourceforge / phpdt / internal / debug / core / model / PHPThread.java
index 49a432e..a8ebb2e 100644 (file)
@@ -27,9 +27,10 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
 public class PHPThread extends PHPDebugElement implements IThread {
 
        private PHPStackFrame[] frames;         // The stackframes which belongs to this thread
-       private PHPDebugTarget  target;     //
+       private PHPDebugTarget  target;     // This is doppel moppel, fTarget exists in PHPDebugElement
        private String                  name;       //
        private int                     id;         // The port number through which we communicate to DBG
+       private boolean         fDebug      = true;
 
        private class State {
                private boolean isSuspended  = false;
@@ -94,12 +95,20 @@ public class PHPThread extends PHPDebugElement implements IThread {
         *
         */
        public IStackFrame[] getStackFrames () throws DebugException {
-               return frames;
+               if (isSuspended()) {
+               if (fDebug) {
+                   System.out.println ("PHPThread getStackFrames");
+               }
+
+                       return ((PHPDebugTarget)getDebugTarget()).getStackFrames();
+               } else {
+                       return new IStackFrame[0];
+               }
        }
 
-       public int getStackFramesSize () {
-               return frames.length;
-       }
+//     public int getStackFramesSize () {
+//             return frames.length;
+//     }
 
        public boolean hasStackFrames () {
                if (frames == null) {
@@ -132,9 +141,9 @@ public class PHPThread extends PHPDebugElement implements IThread {
                return target;
        }
 
-       public void setDebugTarget(PHPDebugTarget target) {
-               this.target = target;
-       }
+//     public void setDebugTarget(PHPDebugTarget target) {
+//             this.target = target;
+//     }
 
        public ILaunch getLaunch() {
                return this.getDebugTarget().getLaunch();
@@ -163,10 +172,10 @@ public class PHPThread extends PHPDebugElement implements IThread {
                DebugEvent ev;
 
                state.setSuspended (false);                                 // We will leave the suspended state
-               this.frames = null;                                         // Reset the stackframes
+               frames      = null;                                         // Reset the stackframes
                ev          = new DebugEvent (this, DebugEvent.RESUME, de); // Create an event resume by stepping
 
-               DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });  // Fire the event
+               DebugPlugin.getDefault ().fireDebugEventSet (new DebugEvent[] { ev });  // Fire the event
        }
 
        /**
@@ -297,6 +306,7 @@ public class PHPThread extends PHPDebugElement implements IThread {
                state.setTerminated (true);
                this.frames = null;
                getDebugTarget ().terminate ();
+               fireTerminateEvent ();
        }
 
        /**
@@ -308,22 +318,13 @@ public class PHPThread extends PHPDebugElement implements IThread {
                if (IWorkbenchAdapter.class.equals (arg0)) {
                        return new IWorkbenchAdapter() {
                                public Object[] getChildren(Object o) {
-                                       Object[] children = null;
-
                                        try {
-                                               IStackFrame[] frames = getStackFrames();
-
-                                               if (null != frames) {
-                                                       children = new Object[frames.length];
-                                                       for (int i = 0; i < frames.length; ++i) {
-                                                               children[i] = frames[i];
-                                                       }
-                                               }
+                                               return getStackFrames ();
                                        } catch (DebugException x) {
                                                PHPeclipsePlugin.log ("Unable to get stack frames.", x);
                                        }
 
-                                       return children;
+                                       return new Object[0];
                                }
 
                                public ImageDescriptor getImageDescriptor(Object object) {
@@ -339,8 +340,7 @@ public class PHPThread extends PHPDebugElement implements IThread {
                                }
                        };
                }
-
-               return null;
+               return super.getAdapter(arg0);
        }
 
        /**