diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index 742914cee27..330cacfc847 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,10 @@ +2004-06-28 Mikhail Khodjaiants + Partial fix for bug 45535: Performance problems when debugging. + Cache the double and float presentations of the floating point types. + * CDebugUtils.java + * CFloatingPointValue.java: new + * CValueFactory.java + 2004-06-24 Mikhail Khodjaiants Temporary fix for bug 56520: Debug Perspective doesn't get called when a breakpoint is hit. * CThread.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java index 1aa7e227371..dba4fcfc88d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java @@ -16,23 +16,18 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; - import javax.xml.transform.OutputKeys; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; - import org.eclipse.cdt.core.model.IFunction; import org.eclipse.cdt.core.model.IMethod; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleValue; -import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatValue; import org.eclipse.cdt.debug.core.model.ICValue; -import org.eclipse.cdt.debug.internal.core.model.CValue; +import org.eclipse.cdt.debug.internal.core.model.CFloatingPointValue; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; @@ -354,19 +349,11 @@ public class CDebugUtils public static Number getFloatingPointValue( ICValue value ) { - if ( value instanceof CValue ) + if ( value instanceof CFloatingPointValue ) { try { - ICDIValue cdiValue = ((CValue)value).getUnderlyingValue(); - if ( cdiValue instanceof ICDIDoubleValue ) - { - return new Double( ((ICDIDoubleValue)cdiValue).doubleValue() ); - } - if ( cdiValue instanceof ICDIFloatValue ) - { - return new Float( ((ICDIFloatValue)cdiValue).floatValue() ); - } + return ((CFloatingPointValue)value).getFloatingPointValue(); } catch( CDIException e ) { diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CFloatingPointValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CFloatingPointValue.java new file mode 100644 index 00000000000..d6ce47d4ace --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CFloatingPointValue.java @@ -0,0 +1,44 @@ +/********************************************************************** + * Copyright (c) 2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ +package org.eclipse.cdt.debug.internal.core.model; + +import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleValue; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatValue; + +/** + * Represents a value of a float or double variable type. + */ +public class CFloatingPointValue extends CValue { + + private Number fFloatingPointValue; + + /** + * Constructor for CFloatingPointValue. + */ + public CFloatingPointValue( CVariable parent, ICDIValue cdiValue ) { + super( parent, cdiValue ); + } + + public Number getFloatingPointValue() throws CDIException { + if ( fFloatingPointValue == null ) { + ICDIValue cdiValue = getUnderlyingValue(); + if ( cdiValue instanceof ICDIDoubleValue ) { + fFloatingPointValue = new Double( ((ICDIDoubleValue)cdiValue).doubleValue() ); + } + else if ( cdiValue instanceof ICDIFloatValue ) { + fFloatingPointValue = new Float( ((ICDIFloatValue)cdiValue).floatValue() ); + } + } + return fFloatingPointValue; + } +} 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 1d4c2c9aab0..5710779c4eb 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 @@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.internal.core.model; import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue; import org.eclipse.debug.core.DebugException; /** @@ -25,6 +26,9 @@ public class CValueFactory { static public CValue createValue( CVariable parent, ICDIValue cdiValue ) throws DebugException { + if ( cdiValue instanceof ICDIFloatingPointValue ) { + return new CFloatingPointValue( parent, cdiValue ); + } return new CValue( parent, cdiValue ); }