[hg] main-silver: #191801: Current value or the value to be assi...

  • From:
  • To:
  • Subject: [hg] main-silver: #191801: Current value or the value to be assi...
  • Date: Thu, 21 Feb 2013 19:39:14 -0800

changeset 70205cbfecc8 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/70205cbfecc8
description:
        #191801: Current value or the value to be assigned to a field is 
available in Variables window. Also the thrown exception is available there 
when exception breakpoint is hit.

diffstat:

 debugger.jpda.ui/nbproject/project.xml                                       
             |   2 +-
 
debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/Bundle.properties
       |  12 +
 
debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
 |  37 ++++
 debugger.jpda/manifest.mf                                                    
             |   2 +-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
      |  46 +++++-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractObjectVariable.java
   |  13 +-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ExceptionVariableImpl.java
    |  75 +++++++++
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/FieldReadVariableImpl.java
    |  76 ++++++++++
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/FieldToBeVariableImpl.java
    |  76 ++++++++++
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java
           |  12 +-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/LocalsTreeModel.java
          |  31 +++-
 
debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ReturnVariableImpl.java
       |   2 +-
 12 files changed, 370 insertions(+), 14 deletions(-)

diffs (625 lines):

diff --git a/debugger.jpda.ui/nbproject/project.xml 
b/debugger.jpda.ui/nbproject/project.xml
--- a/debugger.jpda.ui/nbproject/project.xml
+++ b/debugger.jpda.ui/nbproject/project.xml
@@ -96,7 +96,7 @@
                     <compile-dependency/>
                     <run-dependency>
                         <release-version>2</release-version>
-                        <specification-version>1.36</specification-version>
+                        <specification-version>1.46</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
diff --git 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/Bundle.properties
 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/Bundle.properties
--- 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/Bundle.properties
+++ 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/Bundle.properties
@@ -262,6 +262,18 @@
 MSG_LastOperations_descr = The values of sub-expressions stepped over by 
expression step.
 operationArgumentsNode = Arguments
 operationArgumentsNode_descr = Arguments that are passed to ''{0}'' method.
+# {0} contains the exception class name
+ThrownExceptionVar=Thrown exception {0}
+# {0} contains the name of the field
+FieldValueReadVar=Value read from {0}
+# {0} contains the name of the field
+FieldValueToBeVar=Value to be set to {0}
+# {0} contains the exception class name
+ThrownExceptionVar_descr=Exception {0} was just thrown.
+# {0} contains the name of the field
+FieldValueReadVar_descr=The value is read from {0} field.
+# {0} contains the name of the field
+FieldValueToBeVar_descr=The value is to be set to {0} field.
 NativeMethod = No arguments available for native methods
 NativeMethod_descr = It is not possible to retrieve arguments for native 
methods.
 noDebugInfoWarning = Variable information not available, source compiled 
without -g option
diff --git 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
--- 
a/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
+++ 
b/debugger.jpda.ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java
@@ -65,6 +65,9 @@
 import org.netbeans.api.debugger.jpda.Super;
 import org.netbeans.api.debugger.jpda.This;
 import org.netbeans.api.debugger.jpda.Variable;
+import org.netbeans.modules.debugger.jpda.models.ExceptionVariableImpl;
+import org.netbeans.modules.debugger.jpda.models.FieldReadVariableImpl;
+import org.netbeans.modules.debugger.jpda.models.FieldToBeVariableImpl;
 import org.netbeans.spi.debugger.DebuggerServiceRegistration;
 import org.netbeans.spi.debugger.DebuggerServiceRegistrations;
 import org.netbeans.spi.debugger.jpda.EditorContext.Operation;
@@ -155,6 +158,19 @@
         if (o instanceof ReturnVariable) {
             return "return "+((ReturnVariable) o).methodName()+"()";
         }
+        if (o instanceof ExceptionVariableImpl) {
+            ExceptionVariableImpl ev = (ExceptionVariableImpl) o;
+            //return "Thrown exception "+ev.getExceptionClassName();
+            return NbBundle.getMessage(VariablesNodeModel.class, 
"ThrownExceptionVar", ev.getExceptionClassName());
+        }
+        if (o instanceof FieldReadVariableImpl) {
+            FieldReadVariableImpl frv = (FieldReadVariableImpl) o;
+            return NbBundle.getMessage(VariablesNodeModel.class, 
"FieldValueReadVar", frv.getFieldVariable().getName());
+        }
+        if (o instanceof FieldToBeVariableImpl) {
+            FieldToBeVariableImpl ftbv = (FieldToBeVariableImpl) o;
+            return NbBundle.getMessage(VariablesNodeModel.class, 
"FieldValueToBeVar", ftbv.getFieldVariable().getName());
+        }
         if (o instanceof Operation) {
             Operation op = (Operation) o;
             Operation lastOperation = null;
@@ -230,6 +246,18 @@
                 return NbBundle.getMessage(VariablesNodeModel.class, 
"beforeOperation_descr", op.getMethodName());
             }
         }
+        if (o instanceof ExceptionVariableImpl) {
+            ExceptionVariableImpl ev = (ExceptionVariableImpl) o;
+            return NbBundle.getMessage(VariablesNodeModel.class, 
"ThrownExceptionVar_descr", ev.getExceptionClassName());
+        }
+        if (o instanceof FieldReadVariableImpl) {
+            FieldReadVariableImpl frv = (FieldReadVariableImpl) o;
+            return NbBundle.getMessage(VariablesNodeModel.class, 
"FieldValueReadVar_descr", frv.getFieldVariable().getName());
+        }
+        if (o instanceof FieldToBeVariableImpl) {
+            FieldToBeVariableImpl ftbv = (FieldToBeVariableImpl) o;
+            return NbBundle.getMessage(VariablesNodeModel.class, 
"FieldValueToBeVar_descr", ftbv.getFieldVariable().getName());
+        }
         if (o == "lastOperations") { // NOI18N
             return NbBundle.getMessage(VariablesNodeModel.class, 
"MSG_LastOperations_descr");
         }
@@ -366,6 +394,9 @@
         if (o instanceof JPDAClassType) return ;
         if (o instanceof ClassVariable) return ;
         if (o instanceof ReturnVariable) return ;
+        if (o instanceof ExceptionVariableImpl) return ;
+        if (o instanceof FieldReadVariableImpl) return ;
+        if (o instanceof FieldToBeVariableImpl) return ;
         if (o instanceof Operation) return ;
         throw new UnknownTypeException (o);
     }
@@ -431,6 +462,12 @@
         if (node instanceof ReturnVariable || node == "lastOperations") {
             return RETURN;
         }
+        if (node instanceof ExceptionVariableImpl) {
+            return RETURN;
+        }
+        if (node instanceof FieldReadVariableImpl || node instanceof 
FieldToBeVariableImpl) {
+            return FIELD;
+        }
         if (node == "noDebugInfoWarning") {
             return NO_DEBUG_INFO;
         }
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.45
+OpenIDE-Module-Specification-Version: 1.46
 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/breakpoints/BreakpointImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java
@@ -45,13 +45,17 @@
 package org.netbeans.modules.debugger.jpda.breakpoints;
 
 import com.sun.jdi.AbsentInformationException;
+import com.sun.jdi.Field;
 import com.sun.jdi.ObjectReference;
 import com.sun.jdi.ReferenceType;
 import com.sun.jdi.ThreadReference;
 import com.sun.jdi.VMDisconnectedException;
 import com.sun.jdi.Value;
 import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.event.AccessWatchpointEvent;
 import com.sun.jdi.event.Event;
+import com.sun.jdi.event.ExceptionEvent;
+import com.sun.jdi.event.ModificationWatchpointEvent;
 import com.sun.jdi.request.EventRequest;
 import com.sun.jdi.request.EventRequestManager;
 import com.sun.jdi.request.StepRequest;
@@ -89,16 +93,22 @@
 import 
org.netbeans.modules.debugger.jpda.jdi.InvalidRequestStateExceptionWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.MirrorWrapper;
 import 
org.netbeans.modules.debugger.jpda.jdi.ObjectCollectedExceptionWrapper;
+import org.netbeans.modules.debugger.jpda.jdi.ObjectReferenceWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.PrimitiveValueWrapper;
+import org.netbeans.modules.debugger.jpda.jdi.ReferenceTypeWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.ThreadReferenceWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.VMDisconnectedExceptionWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.ValueWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.VirtualMachineWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.event.EventWrapper;
+import org.netbeans.modules.debugger.jpda.jdi.event.WatchpointEventWrapper;
 import 
org.netbeans.modules.debugger.jpda.jdi.request.EventRequestManagerWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.request.EventRequestWrapper;
 import org.netbeans.modules.debugger.jpda.jdi.request.StepRequestWrapper;
 import org.netbeans.modules.debugger.jpda.models.AbstractObjectVariable;
+import org.netbeans.modules.debugger.jpda.models.ExceptionVariableImpl;
+import org.netbeans.modules.debugger.jpda.models.FieldReadVariableImpl;
+import org.netbeans.modules.debugger.jpda.models.FieldToBeVariableImpl;
 import org.netbeans.modules.debugger.jpda.models.JPDAThreadImpl;
 import org.netbeans.modules.debugger.jpda.models.ReturnVariableImpl;
 import org.netbeans.modules.debugger.jpda.util.ConditionedExecutor;
@@ -477,7 +487,12 @@
         
         Variable variable = processedReturnVariable.remove(event);
         if (variable == null) {
-            variable = debugger.getVariable(value);
+            try {
+                variable = createBreakpointVariable(event, value, 
referenceType);
+            } catch (InternalExceptionWrapper ex) {
+            } catch (VMDisconnectedExceptionWrapper ex) {
+            } catch (ObjectCollectedExceptionWrapper ex) {
+            }
         }
         JPDABreakpointEvent e;
         Throwable cEx = conditionException.remove(event);
@@ -529,13 +544,40 @@
                 }
             }
             if (!resume) {
-                
getDebugger().getThread(threadReference).setCurrentBreakpoint(breakpoint);
+                
getDebugger().getThread(threadReference).setCurrentBreakpoint(breakpoint, e);
             }
         }
         //S ystem.out.println("BreakpointImpl.perform end");
         return resume; 
     }
     
+    private Variable createBreakpointVariable(Event event, Value value, 
ReferenceType referenceType)
+                                              throws 
InternalExceptionWrapper,
+                                                     
VMDisconnectedExceptionWrapper,
+                                                     
ObjectCollectedExceptionWrapper {
+        Variable var;
+        if (event instanceof ExceptionEvent && value instanceof 
ObjectReference) {
+            String exceptionClassName;
+            exceptionClassName = 
ReferenceTypeWrapper.name(ObjectReferenceWrapper.referenceType((ObjectReference)
 value));
+            var = new ExceptionVariableImpl(debugger, value, null, 
exceptionClassName);
+        } else if (event instanceof AccessWatchpointEvent) {
+            AccessWatchpointEvent aevent = (AccessWatchpointEvent) event;
+            Field field = WatchpointEventWrapper.field(aevent);
+            ObjectReference or = WatchpointEventWrapper.object(aevent);
+            org.netbeans.api.debugger.jpda.Field fieldVar = 
AbstractObjectVariable.getField(debugger, field, or, null);
+            var = new FieldReadVariableImpl(debugger, value, null, fieldVar);
+        } else if (event instanceof ModificationWatchpointEvent) {
+            ModificationWatchpointEvent mevent = 
(ModificationWatchpointEvent) event;
+            Field field = WatchpointEventWrapper.field(mevent);
+            ObjectReference or = WatchpointEventWrapper.object(mevent);
+            org.netbeans.api.debugger.jpda.Field fieldVar = 
AbstractObjectVariable.getField(debugger, field, or, null);
+            var = new FieldToBeVariableImpl(debugger, value, null, fieldVar);
+        } else {
+            var = debugger.getVariable(value);
+        }
+        return var;
+    }
+    
     private void enableDisableDependentBreakpoints() {
         Set<Breakpoint> breakpoints = breakpoint.getBreakpointsToEnable();
         for (Breakpoint b : breakpoints) {
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractObjectVariable.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractObjectVariable.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractObjectVariable.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/AbstractObjectVariable.java
@@ -947,12 +947,21 @@
         ObjectReference or, 
         String parentID
     ) {
+        return getField(getDebugger(), f, or, parentID);
+    }
+    
+    public static org.netbeans.api.debugger.jpda.Field getField (
+        JPDADebuggerImpl debugger,
+        com.sun.jdi.Field f, 
+        ObjectReference or, 
+        String parentID
+    ) {
         if (f.signature().length() == 1) {
             // Must be a primitive type or the void type
-            return new FieldVariable(getDebugger(), f, parentID, or);
+            return new FieldVariable(debugger, f, parentID, or);
         } else {
             return new ObjectFieldVariable (
-                getDebugger(),
+                debugger,
                 f,
                 parentID,
                 JPDADebuggerImpl.getGenericSignature(f),
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ExceptionVariableImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ExceptionVariableImpl.java
new file mode 100644
--- /dev/null
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ExceptionVariableImpl.java
@@ -0,0 +1,75 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.debugger.jpda.models;
+
+import com.sun.jdi.Value;
+import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
+
+/**
+ * Represents a variable containing thrown exception.
+ * 
+ * @author Martin
+ */
+public class ExceptionVariableImpl extends AbstractObjectVariable {
+    
+    private final String exceptionClassName;
+    
+    /** Creates a new instance of ExceptionVariableImpl */
+    public ExceptionVariableImpl(
+        JPDADebuggerImpl debugger,
+        Value exceptionValue,
+        String parentID,
+        String exceptionClassName
+    ) {
+        super (
+            debugger,
+            exceptionValue,
+            parentID + ".throw " + exceptionClassName + "=" + 
ReturnVariableImpl.getStringValue(exceptionValue) // To have good equals()
+        );
+        this.exceptionClassName = exceptionClassName;
+    }
+    
+    public String getExceptionClassName() {
+        return exceptionClassName;
+    }
+    
+}
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/FieldReadVariableImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/FieldReadVariableImpl.java
new file mode 100644
--- /dev/null
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/FieldReadVariableImpl.java
@@ -0,0 +1,76 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.debugger.jpda.models;
+
+import com.sun.jdi.Value;
+import org.netbeans.api.debugger.jpda.Field;
+import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
+
+/**
+ * Represents a variable containing value of a field, which is just being 
read.
+ * 
+ * @author Martin
+ */
+public class FieldReadVariableImpl extends AbstractObjectVariable {
+    
+    private final Field fieldVar;
+    
+    /** Creates a new instance of FieldReadVariableImpl */
+    public FieldReadVariableImpl(
+        JPDADebuggerImpl debugger,
+        Value readValue,
+        String parentID,
+        Field fieldVar
+    ) {
+        super (
+            debugger,
+            readValue,
+            parentID + "." + fieldVar.getName() + "=" + 
ReturnVariableImpl.getStringValue(readValue) // To have good equals()
+        );
+        this.fieldVar = fieldVar;
+    }
+    
+    public Field getFieldVariable() {
+        return fieldVar;
+    }
+    
+}
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/FieldToBeVariableImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/FieldToBeVariableImpl.java
new file mode 100644
--- /dev/null
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/FieldToBeVariableImpl.java
@@ -0,0 +1,76 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License.  When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2013 Sun Microsystems, Inc.
+ */
+package org.netbeans.modules.debugger.jpda.models;
+
+import com.sun.jdi.Value;
+import org.netbeans.api.debugger.jpda.Field;
+import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
+
+/**
+ * Represents a variable containing value that is going to be set to a field.
+ * 
+ * @author Martin
+ */
+public class FieldToBeVariableImpl extends AbstractObjectVariable {
+    
+    private final Field fieldVar;
+    
+    /** Creates a new instance of FieldToBeVariableImpl */
+    public FieldToBeVariableImpl(
+        JPDADebuggerImpl debugger,
+        Value toBeValue,
+        String parentID,
+        Field fieldVar
+    ) {
+        super (
+            debugger,
+            toBeValue,
+            parentID + "." + fieldVar.getName() + "=" + 
ReturnVariableImpl.getStringValue(toBeValue) // To have good equals()
+        );
+        this.fieldVar = fieldVar;
+    }
+    
+    public Field getFieldVariable() {
+        return fieldVar;
+    }
+    
+}
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java
@@ -96,6 +96,7 @@
 import org.netbeans.api.debugger.jpda.MonitorInfo;
 import org.netbeans.api.debugger.jpda.ObjectVariable;
 import org.netbeans.api.debugger.jpda.Variable;
+import org.netbeans.api.debugger.jpda.event.JPDABreakpointEvent;
 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl;
 import org.netbeans.modules.debugger.jpda.SingleThreadWatcher;
 import 
org.netbeans.modules.debugger.jpda.jdi.IllegalThreadStateExceptionWrapper;
@@ -178,6 +179,7 @@
     private int                 cachedFramesTo = -1;
     private final Object        cachedFramesLock = new Object();
     private JPDABreakpoint      currentBreakpoint;
+    private JPDABreakpointEvent breakpointEvent;
     private String              threadName;
     private final Object        lockerThreadsLock = new Object();
     //private Map<JPDAThread, Variable> lockerThreads;
@@ -377,11 +379,16 @@
         return currentBreakpoint;
     }
 
-    public void setCurrentBreakpoint(JPDABreakpoint currentBreakpoint) {
+    public synchronized JPDABreakpointEvent getCurrentBreakpointEvent() {
+        return breakpointEvent;
+    }
+
+    public void setCurrentBreakpoint(JPDABreakpoint currentBreakpoint, 
JPDABreakpointEvent breakpointEvent) {
         JPDABreakpoint oldBreakpoint;
         synchronized (this) {
             oldBreakpoint = this.currentBreakpoint;
             this.currentBreakpoint = currentBreakpoint;
+            this.breakpointEvent = breakpointEvent;
         }
         pch.firePropertyChange(PROP_BREAKPOINT, oldBreakpoint, 
currentBreakpoint);
     }
@@ -940,7 +947,10 @@
         waitUntilMethodInvokeDone();
         setReturnVariable(null); // Clear the return var on resume
         setCurrentOperation(null);
+        synchronized (this) {
         currentBreakpoint = null;
+            breakpointEvent = null;
+        }
         if (!doKeepLastOperations) {
             clearLastOperations();
         }
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/LocalsTreeModel.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/LocalsTreeModel.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/LocalsTreeModel.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/LocalsTreeModel.java
@@ -71,6 +71,7 @@
 import org.netbeans.api.debugger.jpda.JPDADebugger;
 import org.netbeans.api.debugger.jpda.JPDAThread;
 import org.netbeans.api.debugger.jpda.Variable;
+import org.netbeans.api.debugger.jpda.event.JPDABreakpointEvent;
 import org.netbeans.spi.debugger.jpda.EditorContext.Operation;
 import org.netbeans.spi.viewmodel.ModelEvent;
 import org.netbeans.spi.viewmodel.TreeModel;
@@ -539,17 +540,17 @@
                 return new String [] {"No current thread"};
             ObjectReference thisR = StackFrameWrapper.thisObject 
(stackFrame);
             List<Operation> operations = thread.getLastOperations();
-            ReturnVariableImpl returnVariable;
+            Variable breakpointVariable;
             boolean haveLastOperations;
             if (operations != null && operations.size() > 0 && 
operations.get(0).getReturnValue() != null) {
                 haveLastOperations = true;
-                returnVariable = null;
+                breakpointVariable = null;
             } else {
-                returnVariable = thread.getReturnVariable();
+                breakpointVariable = getBreakpointVar(thread);
                 haveLastOperations = false;
             }
             //int retValShift = (haveLastOperations || returnVariable != 
null) ? 1 : 0;
-            int retValShift = (returnVariable != null) ? 1 : 0;
+            int retValShift = (breakpointVariable != null) ? 1 : 0;
             Operation currentOperation = thread.getCurrentOperation();
             //int currArgShift = (currentOperation != null && 
CallStackFrameImpl.IS_JDK_160_02) ? 1 : 0;
             int currArgShift = (currentOperation != null) ? 1 : 0;
@@ -565,7 +566,7 @@
                 );
                 Object[] result = new Object [avs.length + shift + 1];
                 if (from < 1 && retValShift > 0) {
-                    result[0] = returnVariable;
+                    result[0] = breakpointVariable;
                 }
                 if (from < 1 && currArgShift > 0) {
                     //result[retValShift] = "operationArguments " + 
currentOperation.getMethodName(); // NOI18N
@@ -587,7 +588,7 @@
                 );
                 Object[] result = new Object [avs.length + shift + 1];
                 if (from < 1 && retValShift > 0) {
-                    result[0] = returnVariable;
+                    result[0] = breakpointVariable;
                 }
                 if (from < 1 && currArgShift > 0) {
                     //result[retValShift] = "operationArguments " + 
currentOperation.getMethodName(); // NOI18N
@@ -696,6 +697,24 @@
     }
      */
     
+    private Variable getBreakpointVar(JPDAThreadImpl thread) {
+        Variable bv = thread.getReturnVariable();
+        if (bv == null) {
+            JPDABreakpointEvent be = thread.getCurrentBreakpointEvent();
+            if (be != null) {
+                bv = be.getVariable();
+            }
+        }
+        if (bv != null) {
+            Class<? extends Variable> clazz = bv.getClass();
+            if (clazz == AbstractObjectVariable.class || clazz == 
AbstractVariable.class) {
+                // Anonymous variable, ignore
+                bv = null;
+            }
+        }
+        return bv;
+    }
+    
     private void updateVarListeners(Object[] vars) {
         varListeners = new PropertyChangeListener[vars.length];
         for (int i = 0; i < vars.length; i++) {
diff --git 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ReturnVariableImpl.java
 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ReturnVariableImpl.java
--- 
a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ReturnVariableImpl.java
+++ 
b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/models/ReturnVariableImpl.java
@@ -80,7 +80,7 @@
         this.methodName = methodName;
     }
     
-    private static String getStringValue(Value v) {
+    static String getStringValue(Value v) {
         if (v == null) {
             return "null";
         }

[hg] main-silver: #191801: Current value or the value to be assi...

mentlicher 02/22/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 20131025.e7cbc9d). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close