[jboss-svn-commits] JBL Code SVN: r26488 - in labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug: core and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue May 12 23:45:32 EDT 2009


Author: mark.proctor at jboss.com
Date: 2009-05-12 23:45:32 -0400 (Tue, 12 May 2009)
New Revision: 26488

Modified:
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/DebugUtil.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java
Log:
-enabled some code that was commented out
-disabled caching
-synced on the fthread

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/DebugUtil.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/DebugUtil.java	2009-05-13 01:23:17 UTC (rev 26487)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/DebugUtil.java	2009-05-13 03:45:32 UTC (rev 26488)
@@ -146,10 +146,9 @@
 
         private IJavaObject fEvaluationValue;
         private IJavaReferenceType fEvaluationType;
-        private IJavaThread fThread;
+        private volatile IJavaThread fThread;
         private IAstEvaluationEngine fEvaluationEngine;
         private volatile IEvaluationResult fResult;
-        private volatile boolean evaluated = false;
 
         public EvaluationBlock(IJavaObject value, IJavaReferenceType type,
                 IJavaThread thread, IAstEvaluationEngine evaluationEngine) {
@@ -160,9 +159,9 @@
         }
 
         public void evaluationComplete(IEvaluationResult result) {
-            synchronized (this) {
+            synchronized ( fThread ) {
                 fResult = result;
-                evaluated = true;
+                fThread.notifyAll();
             }
         }
 
@@ -184,12 +183,14 @@
             fEvaluationEngine.evaluateExpression(compiledExpression,
                     fEvaluationValue, fThread, this,
                     DebugEvent.EVALUATION_IMPLICIT, false);
-            synchronized (this) {
-                while ( !evaluated ) {
-                    try {
-                        this.wait( 100 );
-                    } catch ( InterruptedException e ) {
-                    }
+            synchronized ( fThread ) {
+                while ( fResult == null ) {
+                        try {
+                            this.wait( 100 );
+                        } catch ( InterruptedException e ) {
+                            // TODO Auto-generated catch block
+                            e.printStackTrace();
+                        }
                 }
             }
             if (fResult == null) {

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java	2009-05-13 01:23:17 UTC (rev 26487)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java	2009-05-13 03:45:32 UTC (rev 26488)
@@ -111,83 +111,83 @@
     }
 
 // I don't see the need for any of this custom stepOver stuff, why is it here?
-//    public synchronized void stepOver() throws DebugException {
-//
-//        // Detection for active stackframe
-//        if ( !(getTopStackFrame() instanceof MVELStackFrame) ) {
-//            super.stepOver();
-//            return;
-//        }
-//
-//        //MVEL step over
-//        MVELStackFrame mvelStack = (MVELStackFrame) getTopStackFrame();
-//
-//        if ( !canStepOver() || !mvelStack.canStepOver() ) {
-//            return;
-//        }
-//
-//        if ( !setRemoteOnBreakReturn( Debugger.STEP ) ) {
-//            return;
-//        }
-//
-//        setRunning( true );
-//
-//        preserveStackFrames();
-//
-//        fireEvent( new DebugEvent( this,
-//                                   DebugEvent.RESUME,
-//                                   DebugEvent.STEP_OVER ) );
-//
-//        try {
-//            getUnderlyingThread().resume();
-//        } catch ( RuntimeException e ) {
-//            //stepEnd();
-//            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIThread_exception_stepping,
-//                                                       new String[]{e.toString()} ),
-//                                 e );
-//        }
-//
-//    }
-//
-//    private boolean setRemoteOnBreakReturn(int step_over) throws DebugException {
-//
-//        JDIStackFrame top = (JDIStackFrame) getTopStackFrame();
-//        if ( top == null || (!(top instanceof MVELStackFrame)) ) {
-//            return false;
-//        }
-//
-//        Iterator handleriter = getVM().classesByName( "org.drools.base.mvel.MVELDebugHandler" ).iterator();
-//        Object debugHandlerClass = handleriter.next();
-//
-//        int line = step_over;
-//
-//        ReferenceType refType = (ReferenceType) debugHandlerClass;
-//        Method m = (Method) refType.methodsByName( "setOnBreakReturn" ).iterator().next();
-//        List args = new ArrayList();
-//        IntegerValue lineVal = getVM().mirrorOf( line );
-//        //ObjectReference realVal = val.getUnderlyingObject();
-//        args.add( lineVal );
-//
-//        try {
-//            ClassType tt = (ClassType) debugHandlerClass;
-//            tt.invokeMethod( getUnderlyingThread(),
-//                             m,
-//                             args,
-//                             ObjectReference.INVOKE_SINGLE_THREADED );
-//
-//        } catch ( Exception e ) {
-//            DroolsEclipsePlugin.log( e );
-//            return false;
-//        }
-//        return true;
-//    }
-//
-//    public synchronized void resume() throws DebugException {
-//        // clear up the step over flag. step over button never calls this method.
-//        setRemoteOnBreakReturn( Debugger.CONTINUE );
-//        super.resume();
-//    }
+    public synchronized void stepOver() throws DebugException {
 
+        // Detection for active stackframe
+        if ( !(getTopStackFrame() instanceof MVELStackFrame) ) {
+            super.stepOver();
+            return;
+        }
+
+        //MVEL step over
+        MVELStackFrame mvelStack = (MVELStackFrame) getTopStackFrame();
+
+        if ( !canStepOver() || !mvelStack.canStepOver() ) {
+            return;
+        }
+
+        if ( !setRemoteOnBreakReturn( Debugger.STEP ) ) {
+            return;
+        }
+
+        setRunning( true );
+
+        preserveStackFrames();
+
+        fireEvent( new DebugEvent( this,
+                                   DebugEvent.RESUME,
+                                   DebugEvent.STEP_OVER ) );
+
+        try {
+            getUnderlyingThread().resume();
+        } catch ( RuntimeException e ) {
+            //stepEnd();
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIThread_exception_stepping,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        }
+
+    }
+
+    private boolean setRemoteOnBreakReturn(int step_over) throws DebugException {
+
+        JDIStackFrame top = (JDIStackFrame) getTopStackFrame();
+        if ( top == null || (!(top instanceof MVELStackFrame)) ) {
+            return false;
+        }
+
+        Iterator handleriter = getVM().classesByName( "org.drools.base.mvel.MVELDebugHandler" ).iterator();
+        Object debugHandlerClass = handleriter.next();
+
+        int line = step_over;
+
+        ReferenceType refType = (ReferenceType) debugHandlerClass;
+        Method m = (Method) refType.methodsByName( "setOnBreakReturn" ).iterator().next();
+        List args = new ArrayList();
+        IntegerValue lineVal = getVM().mirrorOf( line );
+        //ObjectReference realVal = val.getUnderlyingObject();
+        args.add( lineVal );
+
+        try {
+            ClassType tt = (ClassType) debugHandlerClass;
+            tt.invokeMethod( getUnderlyingThread(),
+                             m,
+                             args,
+                             ObjectReference.INVOKE_SINGLE_THREADED );
+
+        } catch ( Exception e ) {
+            DroolsEclipsePlugin.log( e );
+            return false;
+        }
+        return true;
+    }
+
+    public synchronized void resume() throws DebugException {
+        // clear up the step over flag. step over button never calls this method.
+        setRemoteOnBreakReturn( Debugger.CONTINUE );
+        super.resume();
+    }
+
     protected synchronized void disposeStackFrames() {
         super.disposeStackFrames();
     }

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java	2009-05-13 01:23:17 UTC (rev 26487)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java	2009-05-13 03:45:32 UTC (rev 26488)
@@ -51,7 +51,7 @@
  */
 public class MVELStackFrame extends DroolsStackFrame {
 
-    private final MVELStackFrameContext ctxCache = new MVELStackFrameContext();
+    //private final MVELStackFrameContext ctxCache = new MVELStackFrameContext();
 
     public MVELStackFrame(DroolsThread thread,
                           StackFrame frame,
@@ -82,10 +82,10 @@
                 return new IVariable[0];
             }
 
-            IVariable[] cache = ctxCache.getCacheVariables();
-            if ( cache != null ) {
-                return cache;
-            }
+//            IVariable[] cache = ctxCache.getCacheVariables();
+//            if ( cache != null ) {
+//                return cache;
+//            }
 
             List<IVariable> result = new ArrayList<IVariable>( 0 );
 
@@ -139,7 +139,7 @@
                                      }
                                  }
                              } );
-                ctxCache.setCacheVariables( vararr );
+//                ctxCache.setCacheVariables( vararr );
                 return vararr;
 
             } catch ( Throwable t ) {
@@ -152,10 +152,10 @@
     @Override
     public int getLineNumber() throws DebugException {
         synchronized ( getThread() ) {
-            int cache = ctxCache.getCacheLineNumber();
-            if ( cache != -1 ) {
-                return cache;
-            }
+//            int cache = ctxCache.getCacheLineNumber();
+//            if ( cache != -1 ) {
+//                return cache;
+//            }
 
             DroolsDebugTarget t = (DroolsDebugTarget) getDebugTarget();
             String sourceName = getMVELName();
@@ -181,15 +181,15 @@
                 System.err.println( "Unable to retrieve fragment line!" );
                 return -1;
             }
-            ctxCache.setCacheLineNumber( res );
+//            ctxCache.setCacheLineNumber( res );
             return res;
         }
     }
 
     private int getBreakpointLineNumber() {
-        if ( ctxCache.getCacheBreakpointLineNumber() != -1 ) {
-            return ctxCache.getCacheBreakpointLineNumber();
-        }
+//        if ( ctxCache.getCacheBreakpointLineNumber() != -1 ) {
+//            return ctxCache.getCacheBreakpointLineNumber();
+//        }
 
         // Drools 4
         try {
@@ -199,7 +199,7 @@
             }
             IntegerValue val = (IntegerValue) o;
             int realval = val.value();
-            ctxCache.setCacheBreakpointLineNumber( realval );
+//            ctxCache.setCacheBreakpointLineNumber( realval );
             return realval;
         } catch ( NullPointerException e ) {
             // Drools 5+
@@ -222,7 +222,7 @@
             }
             IntegerValue val = (IntegerValue) o;
             int realval = val.value();
-            ctxCache.setCacheBreakpointLineNumber( realval );
+//            ctxCache.setCacheBreakpointLineNumber( realval );
             return realval;
         } catch ( NullPointerException e ) {
             // Drools 5+
@@ -239,10 +239,10 @@
                 return null;
             }
 
-            String cache = ctxCache.getCacheMVELName();
-            if ( cache != null ) {
-                return cache;
-            }
+//            String cache = ctxCache.getCacheMVELName();
+//            if ( cache != null ) {
+//                return cache;
+//            }
 
             // Drools 4
             try {
@@ -252,7 +252,7 @@
                 }
                 StringReference res = (StringReference) rem;
                 String realres = res.value();
-                ctxCache.setCacheMVELName( realres );
+//                ctxCache.setCacheMVELName( realres );
                 return realres;
             } catch ( NullPointerException e ) {
                 // Drools 5
@@ -275,7 +275,7 @@
                 }
                 StringReference res = (StringReference) rem;
                 String realres = res.value();
-                ctxCache.setCacheMVELName( realres );
+//                ctxCache.setCacheMVELName( realres );
                 return realres;
             } catch ( Throwable e ) {
                 DroolsEclipsePlugin.log( e );
@@ -359,17 +359,6 @@
         return REF_TYPE;
     }
 
-//    protected JDIStackFrame bind(StackFrame frame,
-//                                 int depth) {
-//        clearCachedData();
-//        return super.bind( frame,
-//                           depth );
-//    }
-
-    protected void clearCachedData() {
-        ctxCache.clear();
-    }
-
     public static class MVELStackFrameContext {
         private int         cacheLineNumber           = -1;
         private int         cacheBreakpointLineNumber = -1;




More information about the jboss-svn-commits mailing list