From 3711c05a245821713a2859d6a649d7ec9ae11119 Mon Sep 17 00:00:00 2001 From: John Cortell Date: Tue, 18 Nov 2008 21:48:34 +0000 Subject: [PATCH] 255717. Introduced support in CDI for >64 bit values --- .../cdi/model/type/ICDIBigIntegerValue.java | 23 +++++++++++++ .../cdt/debug/internal/core/model/CValue.java | 32 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/type/ICDIBigIntegerValue.java diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/type/ICDIBigIntegerValue.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/type/ICDIBigIntegerValue.java new file mode 100644 index 00000000000..4729f9ce36b --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/type/ICDIBigIntegerValue.java @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2008 Freescale Semiconductor and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Freescale Semiconductor - Initial API and implementation + *******************************************************************************/ + +package org.eclipse.cdt.debug.core.cdi.model.type; + + +/** + * + * Represents the value of a variable. + * + * @since Nov 18, 2008 + */ +public interface ICDIBigIntegerValue extends ICDIIntegralValue { + +} diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java index cc64112bb0e..89af55ad09d 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java @@ -35,6 +35,7 @@ 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.cdi.model.type.ICDIIntValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDILongLongValue; +import org.eclipse.cdt.debug.core.cdi.model.type.ICDIBigIntegerValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDILongValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue; @@ -230,6 +231,8 @@ public class CValue extends AbstractCValue { return getLongValueString( (ICDILongValue)cdiValue ); else if ( cdiValue instanceof ICDILongLongValue ) return getLongLongValueString( (ICDILongLongValue)cdiValue ); + else if ( cdiValue instanceof ICDIBigIntegerValue ) + return getBigIntegerValueString( (ICDIBigIntegerValue)cdiValue ); else if ( cdiValue instanceof ICDIFloatValue ) return getFloatValueString( (ICDIFloatValue)cdiValue ); else if ( cdiValue instanceof ICDIDoubleValue ) @@ -605,6 +608,35 @@ public class CValue extends AbstractCValue { return value.getValueString(); } + private String getBigIntegerValueString( ICDIBigIntegerValue value ) throws CDIException { + try { + CVariableFormat format = getParentVariable().getFormat(); + + if (CVariableFormat.NATURAL.equals(format)) { + format = getNaturalFormat(value, CVariableFormat.DECIMAL); + } + + if ( CVariableFormat.DECIMAL.equals( format ) ) { + BigInteger bigValue = value.bigIntegerValue(); + return bigValue.toString(10); + } + else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) { + StringBuffer sb = new StringBuffer("0x"); + BigInteger bigValue = value.bigIntegerValue(); + sb.append(bigValue.toString(16)); + return sb.toString(); + } + else if ( CVariableFormat.BINARY.equals( format ) ) { + StringBuffer sb = new StringBuffer("0b"); + BigInteger bigValue = value.bigIntegerValue(); + sb.append(bigValue.toString(2)); + return sb.toString(); + } + } + catch( NumberFormatException e ) { + } + return null; + } private boolean isUnsigned() { boolean result = false; try {