[hg] main-silver: #224716: Step into Lambda implementation is ma...

  • From:
  • To:
  • Subject: [hg] main-silver: #224716: Step into Lambda implementation is ma...
  • Date: Sun, 24 Mar 2013 08:08:31 -0700

changeset b32557783edb in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/b32557783edb
description:
        #224716: Step into Lambda implementation is made to work. Lambda 
methods are not considered to be synthetic and we step over the 
initialization code.

diffstat:

 debugger.jpda/manifest.mf                                                    
        |   2 +-
 debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDAStepImpl.java       
        |  30 +++++++-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepActionProvider.java
 |  38 +++++----
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepIntoNextMethod.java
 |  14 ++-
 4 files changed, 59 insertions(+), 25 deletions(-)

diffs (219 lines):

diff --git a/debugger.jpda/manifest.mf b/debugger.jpda/manifest.mf
--- a/debugger.jpda/manifest.mf
+++ b/debugger.jpda/manifest.mf
@@ -2,6 +2,6 @@
 OpenIDE-Module: org.netbeans.modules.debugger.jpda/2
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/debugger/jpda/Bundle.properties
 OpenIDE-Module-Layer: 
org/netbeans/modules/debugger/jpda/resources/mf-layer.xml
-OpenIDE-Module-Specification-Version: 1.47
+OpenIDE-Module-Specification-Version: 1.48
 OpenIDE-Module-Provides: 
org.netbeans.api.debugger.jpda.JPDADebuggerEngineImpl
 OpenIDE-Module-Requires: org.netbeans.spi.debugger.jpda.EditorContext, 
org.netbeans.spi.debugger.jpda.SourcePathProvider
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDAStepImpl.java 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDAStepImpl.java
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDAStepImpl.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/JPDAStepImpl.java
@@ -760,16 +760,21 @@
                         return false;   // Already running.
                     }
                     // Synthetic method?
-                    Method m = 
LocationWrapper.method(StackFrameWrapper.location(ThreadReferenceWrapper.frame(tr,
 0)));
+                    Location loc = 
StackFrameWrapper.location(ThreadReferenceWrapper.frame(tr, 0));
+                    Method m = LocationWrapper.method(loc);
                     boolean doStepAgain = false;
                     int doStepDepth = getDepth();
 
                     boolean filterSyntheticMethods = useStepFilters && 
p.getBoolean("FilterSyntheticMethods", true);
                     boolean filterStaticInitializers = useStepFilters && 
p.getBoolean("FilterStaticInitializers", false);
                     boolean filterConstructors = useStepFilters && 
p.getBoolean("FilterConstructors", false);
-                    if (filterSyntheticMethods && 
TypeComponentWrapper.isSynthetic(m)) {
+                    int syntheticStep = isSyntheticMethod(m, loc);
+                    if (filterSyntheticMethods && syntheticStep != 0) {
                         //S ystem.out.println("In synthetic method -> STEP 
INTO again");
                         doStepAgain = true;
+                        if (syntheticStep > 0) {
+                            doStepDepth = syntheticStep;
+                        }
                     }
                     if (filterStaticInitializers && 
MethodWrapper.isStaticInitializer(m) ||
                         filterConstructors && 
MethodWrapper.isConstructor(m)) {
@@ -931,6 +936,27 @@
         }
     }
     
+    /**
+     * Test whether the method is considered to be synthetic
+     * @param m The method
+     * @param loc The current location in that method
+     * @return  0 when not synthetic
+     *          positive when suggested step depth is returned
+     *          negative when is synthetic and no further step depth is 
suggested.
+     */
+    public static int isSyntheticMethod(Method m, Location loc) throws 
InternalExceptionWrapper, VMDisconnectedExceptionWrapper {
+        String name = TypeComponentWrapper.name(m);
+        if (name.startsWith("lambda$")) {                                    
   // NOI18N
+            int lineNumber = LocationWrapper.lineNumber(loc);
+            if (lineNumber == 1) {
+                // We're in the initialization of the Lambda. We need to 
step over it.
+                return StepRequest.STEP_OVER;
+            }
+            return 0; // Do not treat Lambda methods as synthetic, because 
they contain user code.
+        }
+        return TypeComponentWrapper.isSynthetic(m) ? -1 : 0;
+    }
+    
     public static final class MethodExitBreakpointListener implements 
JPDABreakpointListener {
         
         private MethodBreakpoint mb;
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepActionProvider.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepActionProvider.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepActionProvider.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepActionProvider.java
@@ -80,6 +80,7 @@
 import org.netbeans.api.debugger.jpda.JPDAThread;
 import org.netbeans.api.debugger.jpda.SmartSteppingFilter;
 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
+import org.netbeans.modules.debugger.jpda.JPDAStepImpl;
 import 
org.netbeans.modules.debugger.jpda.jdi.IllegalThreadStateExceptionWrapper;
 import 
org.netbeans.modules.debugger.jpda.jdi.InvalidRequestStateExceptionWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.LocatableWrapper;
@@ -120,7 +121,7 @@
     private StepRequest             stepRequest;
     private ContextProvider         lookupProvider;
     private MethodExitBreakpointListener lastMethodExitBreakpointListener;
-    private boolean                 isSyntheticLocation;
+    private int                     syntheticStep;
     //private SingleThreadedStepWatch stepWatch;
     private boolean smartSteppingStepOut;
     private Properties p;
@@ -392,10 +393,10 @@
             int suspendPolicy = getDebuggerImpl().getSuspend();
             
             // Synthetic method?
-            if (isSyntheticLocation) {
+            if (syntheticStep != 0) {
                 //S ystem.out.println("In synthetic method -> STEP OVER/OUT 
again");
 
-                int step = StepRequestWrapper.depth(sr);
+                int step = (syntheticStep > 0) ? syntheticStep : 
StepRequestWrapper.depth(sr);
                 VirtualMachine vm = getDebuggerImpl ().getVirtualMachine ();
                 if (vm == null) {
                     removeBPListener();
@@ -498,14 +499,14 @@
             stepWatch.done();
             stepWatch = null;
         }*/
-        if (!isSyntheticLocation && lastMethodExitBreakpointListener != 
null) {
+        if (syntheticStep == 0 && lastMethodExitBreakpointListener != null) {
             lastMethodExitBreakpointListener.destroy();
             lastMethodExitBreakpointListener = null;
         }
     }
 
     private void removeBPListener() {
-        isSyntheticLocation = false;
+        syntheticStep = 0;
         if (lastMethodExitBreakpointListener != null) {
             lastMethodExitBreakpointListener.destroy();
             lastMethodExitBreakpointListener = null;
@@ -517,14 +518,14 @@
         if (lastMethodExitBreakpointListener != null) {
             returnValue = lastMethodExitBreakpointListener.getReturnValue();
         }
-        isSyntheticLocation = !setLastOperation(tr, getDebuggerImpl(), 
returnValue);
-        if (!isSyntheticLocation && lastMethodExitBreakpointListener != 
null) {
+        syntheticStep = setLastOperation(tr, getDebuggerImpl(), returnValue);
+        if (syntheticStep == 0 && lastMethodExitBreakpointListener != null) {
             lastMethodExitBreakpointListener.destroy();
             lastMethodExitBreakpointListener = null;
         }
     }
 
-    public static boolean setLastOperation(ThreadReference tr, 
JPDADebuggerImpl debugger, Variable returnValue) throws 
VMDisconnectedExceptionWrapper {
+    public static int setLastOperation(ThreadReference tr, JPDADebuggerImpl 
debugger, Variable returnValue) throws VMDisconnectedExceptionWrapper {
         Location loc;
         try {
             loc = 
StackFrameWrapper.location(ThreadReferenceWrapper.frame(tr, 0));
@@ -541,20 +542,21 @@
                 // A bad state - ignore
             }
             logger.fine("Incompatible Thread State: 
"+itsex.getLocalizedMessage());
-            return true;
+            return 0;
         } catch (IllegalThreadStateExceptionWrapper itsex) {
-            return true;
+            return 0;
         } catch (InternalExceptionWrapper iex) {
-            return true;
+            return 0;
         } catch (InvalidStackFrameExceptionWrapper iex) {
-            return true;
+            return 0;
         } catch (ObjectCollectedExceptionWrapper iex) {
-            return true;
+            return 0;
         }
         try {
-            if 
(TypeComponentWrapper.isSynthetic0(LocationWrapper.method(loc))) {
+            int syntheticStep = 
JPDAStepImpl.isSyntheticMethod(LocationWrapper.method(loc), loc);
+            if (syntheticStep != 0) {
                 // Ignore synthetic methods
-                return false;
+                return syntheticStep;
             }
         } catch (InternalExceptionWrapper ex) {
         }
@@ -565,12 +567,12 @@
         try {
             url = sourcePath.getURL(loc, language);
         } catch (InternalExceptionWrapper iex) {
-            return true;
+            return 0;
         } catch (ObjectCollectedExceptionWrapper iex) {
-            return true;
+            return 0;
         }
         setOperationsLazily(debugger.getThread(tr), returnValue, debugger, 
loc, url);
-        return true;
+        return 0;
     }
     
     private static final long OPERATION_TIMEOUT = 200;
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepIntoNextMethod.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepIntoNextMethod.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepIntoNextMethod.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/actions/StepIntoNextMethod.java
@@ -44,6 +44,7 @@
 
 import com.sun.jdi.ThreadReference;
 import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.Location;
 import com.sun.jdi.StackFrame;
 import com.sun.jdi.VirtualMachine;
 import com.sun.jdi.event.Event;
@@ -67,6 +68,7 @@
 import org.netbeans.api.debugger.jpda.SmartSteppingFilter;
 import org.netbeans.modules.debugger.jpda.SourcePath;
 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
+import org.netbeans.modules.debugger.jpda.JPDAStepImpl;
 import 
org.netbeans.modules.debugger.jpda.jdi.IllegalThreadStateExceptionWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.InternalExceptionWrapper;
 import 
org.netbeans.modules.debugger.jpda.jdi.InvalidRequestStateExceptionWrapper;
@@ -289,12 +291,16 @@
                 boolean filterSyntheticMethods = useStepFilters && 
p.getBoolean("FilterSyntheticMethods", true);
                 boolean filterStaticInitializers = useStepFilters && 
p.getBoolean("FilterStaticInitializers", false);
                 boolean filterConstructors = useStepFilters && 
p.getBoolean("FilterConstructors", false);
-                com.sun.jdi.Method m = 
LocationWrapper.method(StackFrameWrapper.location(
-                        ThreadReferenceWrapper.frame(tr, 0)));
-                if (filterSyntheticMethods && 
TypeComponentWrapper.isSynthetic(m)) {
+                Location loc = 
StackFrameWrapper.location(ThreadReferenceWrapper.frame(tr, 0));
+                com.sun.jdi.Method m = LocationWrapper.method(loc);
+                int syntheticStep = JPDAStepImpl.isSyntheticMethod(m, loc);
+                if (filterSyntheticMethods && syntheticStep != 0) {
                     //S ystem.out.println("In synthetic method -> STEP INTO 
again");
                     smartLogger.finer(" stoped in a synthetic method.");
-                    StepRequest newSR = setStepRequest 
(StepRequest.STEP_INTO);
+                    if (syntheticStep < 0) {
+                        syntheticStep = StepRequest.STEP_INTO;
+                    }
+                    StepRequest newSR = setStepRequest (syntheticStep);
                     return newSR != null;
                 }
                 if (filterStaticInitializers && 
MethodWrapper.isStaticInitializer(m) ||

[hg] main-silver: #224716: Step into Lambda implementation is ma...

mentlicher 03/25/2013

Project Features

About this Project

Debugger was started in November 2009, is owned by tpavek, and has 29 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close