From 22f8c9984c0ea0995bd9e83013954d12ff907b38 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Fri, 17 Jun 2005 21:28:31 +0000 Subject: [PATCH] Bug 99217: NPE thrown when fetching deffered children. --- debug/org.eclipse.cdt.debug.core/ChangeLog | 6 ++ .../internal/core/model/CExpression.java | 16 ++--- .../internal/core/model/CValueFactory.java | 64 +++++++++++++++++++ .../debug/internal/core/model/CVariable.java | 8 +-- debug/org.eclipse.cdt.debug.ui/ChangeLog | 4 ++ .../internal/ui/CDebugModelPresentation.java | 11 ++-- 6 files changed, 89 insertions(+), 20 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index a3ac6e93424..71d7f3c9aab 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,9 @@ +2005-06-17 Mikhail Khodjaiants + Bug 99217: NPE thrown when fetching deffered children. + * CExpression.java + * CValueFactory.java + * CVariable.java + 2005-06-17 Mikhail Khodjaiants Bug 100261: Memory veiw: Renderings content disappears when click on Vairable/Module... view. * CDebugElement.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java index 3fee999c90d..3ac9ae58d46 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java @@ -39,7 +39,7 @@ public class CExpression extends CVariable implements IExpression { private CStackFrame fStackFrame; - private IValue fValue; + private IValue fValue = CValueFactory.NULL_VALUE; private ICType fType; @@ -116,7 +116,7 @@ public class CExpression extends CVariable implements IExpression { } protected synchronized IValue getValue( CStackFrame context ) throws DebugException { - if ( fValue == null ) { + if ( fValue.equals( CValueFactory.NULL_VALUE ) ) { if ( context.isSuspended() ) { try { ICDIValue value = fCDIExpression.getValue( context.getCDIStackFrame() ); @@ -156,7 +156,7 @@ public class CExpression extends CVariable implements IExpression { if ( fValue instanceof AbstractCValue ) { ((AbstractCValue)fValue).reset(); } - fValue = null; + fValue = CValueFactory.NULL_VALUE; } /* (non-Javadoc) @@ -180,7 +180,7 @@ public class CExpression extends CVariable implements IExpression { } if ( fValue instanceof AbstractCValue ) { ((AbstractCValue)fValue).dispose(); - fValue = null; + fValue = CValueFactory.NULL_VALUE; } internalDispose( true ); } @@ -190,11 +190,9 @@ public class CExpression extends CVariable implements IExpression { */ public ICType getType() throws DebugException { if ( fType == null ) { - if ( fValue != null ) { - synchronized( this ) { - if ( fType == null ) { - fType = ((AbstractCValue)fValue).getType(); - } + synchronized( this ) { + if ( fType == null ) { + fType = ((AbstractCValue)fValue).getType(); } } } diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java index 667434b0a9b..bda5d8ad5a6 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValueFactory.java @@ -10,16 +10,80 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.core.model; +import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue; +import org.eclipse.cdt.debug.core.model.CDebugElementState; +import org.eclipse.cdt.debug.core.model.ICStackFrame; +import org.eclipse.cdt.debug.core.model.ICType; import org.eclipse.cdt.debug.core.model.ICValue; +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IVariable; /** * The value factory for variable and expressions. */ public class CValueFactory { + static public final ICValue NULL_VALUE = new ICValue() { + + public String getReferenceTypeName() throws DebugException { + return ""; //$NON-NLS-1$ + } + + public String getValueString() throws DebugException { + return ""; //$NON-NLS-1$ + } + + public boolean isAllocated() throws DebugException { + return true; + } + + public IVariable[] getVariables() throws DebugException { + return new IVariable[0]; + } + + public boolean hasVariables() throws DebugException { + return false; + } + + public String getModelIdentifier() { + return CDebugCorePlugin.getUniqueIdentifier(); + } + + public IDebugTarget getDebugTarget() { + return null; + } + + public ILaunch getLaunch() { + return null; + } + + public Object getAdapter( Class adapter ) { + return null; + } + + public ICType getType() throws DebugException { + return null; + } + + public String evaluateAsExpression( ICStackFrame frame ) { + return ""; //$NON-NLS-1$ + } + + public CDebugElementState getState() { + return CDebugElementState.UNDEFINED; + } + + public Object getCurrentStateInfo() { + return null; + } + + }; + static public CValue createValue( CVariable parent, ICDIValue cdiValue ) { if ( cdiValue instanceof ICDIFloatingPointValue ) { return new CFloatingPointValue( parent, cdiValue ); diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java index ef42260d32a..b1e14218e7a 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java @@ -74,7 +74,7 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener { /** * The cache of the current value. */ - private ICValue fValue; + private ICValue fValue = CValueFactory.NULL_VALUE; /** * The change flag. @@ -224,7 +224,7 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener { } synchronized ICValue getValue() throws DebugException { - if ( fValue == null ) { + if ( fValue.equals( CValueFactory.NULL_VALUE ) ) { ICDIVariable var = getCDIVariable(); if ( var != null ) { try { @@ -255,7 +255,7 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener { void invalidateValue() { if ( fValue instanceof AbstractCValue ) { ((AbstractCValue)fValue).dispose(); - fValue = null; + fValue = CValueFactory.NULL_VALUE; } } @@ -433,7 +433,7 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener { } } } - return null; + return CValueFactory.NULL_VALUE; } /* diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index c8c1e815a18..5c3ee2d9d0e 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,7 @@ +2005-06-17 Mikhail Khodjaiants + Bug 99217: NPE thrown when fetching deffered children. + * CDebugModelPresentation.java + 2005-06-12 Mikhail Khodjaiants Bug 100447: NPE generated when Run To Line in Disassembly view. * ResumeAtLineAdapter.java diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java index 7e8b67eba05..50ff8dd064c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java @@ -659,13 +659,10 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode String name = var.getName(); if ( name != null ) label.append( name.trim() ); - IValue value = var.getValue(); - if ( value != null ) { - String valueString = getValueText( value ); - if ( !isEmpty( valueString ) ) { - label.append( " = " ); //$NON-NLS-1$ - label.append( valueString ); - } + String valueString = getValueText( var.getValue() ); + if ( !isEmpty( valueString ) ) { + label.append( " = " ); //$NON-NLS-1$ + label.append( valueString ); } } return label.toString();