Skip to main content
summaryrefslogtreecommitdiffstats
path: root/debug
diff options
context:
space:
mode:
authorMathias Kunter2012-03-05 16:08:53 -0500
committerMarc Khouzam2012-03-06 09:23:28 -0500
commitc61ae8a137725a03e7b8bb3a71f618aa2fa88b58 (patch)
tree72b9cc1e628a0677b1531122a9cd303c3f1af4b2 /debug
parentfdd2d8570dba6561f5de1d2325d21a2d935b9605 (diff)
downloadorg.eclipse.cdt-c61ae8a137725a03e7b8bb3a71f618aa2fa88b58.tar.gz
org.eclipse.cdt-c61ae8a137725a03e7b8bb3a71f618aa2fa88b58.tar.xz
org.eclipse.cdt-c61ae8a137725a03e7b8bb3a71f618aa2fa88b58.zip
Bug 370462: Improving the debug preferences - add support for different charsets and unify DSF and CDI debug preferences
Diffstat (limited to 'debug')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java7
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java22
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java11
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CIndexedValue.java9
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java117
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java112
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties19
7 files changed, 237 insertions, 60 deletions
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 b5795ec494..e3894da28d 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 QNX Software Systems and others.
+ * Copyright (c) 2000, 2012 QNX Software Systems 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
@@ -9,6 +9,7 @@
* QNX Software Systems - Initial API and implementation
* Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
* Patrick Chuong (Texas Instruments) - Update CDT ToggleBreakpointTargetFactory enablement (340177)
+ * Mathias Kunter - PREF_CHARSET has been renamed to PREF_WIDE_CHARSET (bug 370462)
*******************************************************************************/
package org.eclipse.cdt.debug.core;
@@ -502,7 +503,7 @@ public class CDebugUtils {
private static CharsetDecoder fDecoder;
public static CharsetDecoder getCharsetDecoder() {
- String charsetName = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_CHARSET);
+ String charsetName = CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_WIDE_CHARSET);
if (fDecoder == null || !fDecoder.charset().name().equals(charsetName)) {
Charset charset = Charset.forName(charsetName);
fDecoder = charset.newDecoder();
@@ -756,4 +757,4 @@ public class CDebugUtils {
String customModel = System.getProperty(ICDebugConstants.PREF_TOGGLE_BREAKPOINT_MODEL_IDENTIFIER, null);
return customModel != null && Boolean.valueOf(customModel);
}
-} \ No newline at end of file
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java
index c56fd788c1..386035ec33 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 QNX Software Systems and others.
+ * Copyright (c) 2000, 2012 QNX Software Systems 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
@@ -9,6 +9,7 @@
* QNX Software Systems - Initial API and implementation
* Ken Ryall (Nokia) - 207675
* Patrick Chuong (Texas Instruments) - Update CDT ToggleBreakpointTargetFactory enablement (340177)
+ * Mathias Kunter - Support for different charsets (bug 370462)
*******************************************************************************/
package org.eclipse.cdt.debug.core;
@@ -38,10 +39,17 @@ public interface ICDebugConstants {
public static final String PREF_DEFAULT_REGISTER_FORMAT = PLUGIN_ID + "cDebug.default_register_format"; //$NON-NLS-1$
/**
- * The identifier of the character set to use with unicode types
- * view
+ * The charset to use for decoding char type strings. We however can't use the ID
+ * "character_set" here because that would break backwards compatibility.
+ */
+ public static final String PREF_CHARSET = PLUGIN_ID + "cDebug.non_wide_character_set"; //$NON-NLS-1$
+
+ /**
+ * The charset to use for decoding wchar_t type strings. We have to use the ID
+ * "character_set" here so that we don't break backwards compatibility.
+ * @since 7.2
*/
- public static final String PREF_CHARSET = PLUGIN_ID + "cDebug.character_set"; //$NON-NLS-1$
+ public static final String PREF_WIDE_CHARSET = PLUGIN_ID + "cDebug.character_set"; //$NON-NLS-1$
/**
* The identifier of the default expression format to use in the expressions
@@ -105,10 +113,12 @@ public interface ICDebugConstants {
public static final String PREF_INSTRUCTION_STEP_MODE_ON = PLUGIN_ID + "cDebug.Disassembly.instructionStepOn"; //$NON-NLS-1$
/**
- * The default character set to use with unicode strings.
+ * The default character set to use.
+ * @deprecated Provided for compatibility reasons only. Use the default value
+ * from the Preferences object instead.
*/
public static final String DEF_CHARSET = "UTF-16"; //$NON-NLS-1$
-
+
/**
* Specifies the stepping mode (context/source/instruction)
*/
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java
index a5d67555f1..d857953ab9 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2007 QNX Software Systems and others.
+ * Copyright (c) 2004, 2012 QNX Software Systems 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
@@ -8,9 +8,12 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
* Ken Ryall (Nokia) - 207675
+ * Mathias Kunter - Using adequate default charsets (bug 370462)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core;
+import java.nio.charset.Charset;
+
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICDebugConstants;
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
@@ -37,7 +40,11 @@ public class CDebugCorePreferenceInitializer extends AbstractPreferenceInitializ
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL );
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL );
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, ICDIFormat.NATURAL );
- CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_CHARSET, ICDebugConstants.DEF_CHARSET );
+ CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_CHARSET, Charset.defaultCharset().name() );
+ if (System.getProperty("os.name").toLowerCase().startsWith("windows")) //$NON-NLS-1$ //$NON-NLS-2$
+ CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_WIDE_CHARSET, "UTF-16"); //$NON-NLS-1$
+ else
+ CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_WIDE_CHARSET, "UTF-32"); //$NON-NLS-1$
CDebugCorePlugin.getDefault().getPluginPreferences().setDefault( ICDebugConstants.PREF_INSTRUCTION_STEP_MODE_ON, false );
}
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CIndexedValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CIndexedValue.java
index 2c7483df20..e6ca489875 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CIndexedValue.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CIndexedValue.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * Copyright (c) 2004, 2012 QNX Software Systems 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Mathias Kunter - Support for octal number format (bug 370462)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
@@ -162,9 +163,11 @@ public class CIndexedValue extends AbstractCValue implements IIndexedValue {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.HEXADECIMAL.equals( format ) )
return address.toHexAddressString();
- if ( CVariableFormat.DECIMAL.equals( format ) )
+ else if ( CVariableFormat.DECIMAL.equals( format ) )
return address.toString();
- if ( CVariableFormat.BINARY.equals( format ) )
+ else if ( CVariableFormat.OCTAL.equals( format ) )
+ return address.toOctalAddressString();
+ else if ( CVariableFormat.BINARY.equals( format ) )
return address.toBinaryAddressString();
return null;
} catch (CDIException e) {
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 5614958f95..eca33a16f5 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 QNX Software Systems and others.
+ * Copyright (c) 2000, 2012 QNX Software Systems 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
@@ -10,6 +10,7 @@
* Mark Mitchell, CodeSourcery - Bug 136896: View variables in binary format
* Warren Paul (Nokia) - 150860, 150864, 150862, 150863, 217493
* Ken Ryall (Nokia) - 207675
+ * Mathias Kunter - Support for octal number format (bug 370462)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
@@ -277,6 +278,19 @@ public class CValue extends AbstractCValue {
sb.append( (stringValue.length() > 2) ? stringValue.substring( stringValue.length() - 2 ) : stringValue );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ String stringValue = (isUnsigned()) ? Integer.toOctalString( value.shortValue() ) : Integer.toOctalString( (byte)value.byteValue() );
+ stringValue = (stringValue.length() > 3) ? stringValue.substring( stringValue.length() - 3 ) : stringValue;
+ sb.append( (stringValue.length() == 3 && stringValue.charAt( 0 ) >= '4') ? (char)(stringValue.charAt( 0 ) - 4) + stringValue.substring( 1 ) : stringValue );
+ return sb.toString();
+ }
+ else if ( CVariableFormat.BINARY.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
+ String stringValue = (isUnsigned()) ? Integer.toBinaryString( value.shortValue() ) : Integer.toBinaryString( (byte)value.byteValue() );
+ sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
+ return sb.toString();
+ }
return null;
}
@@ -313,6 +327,13 @@ public class CValue extends AbstractCValue {
sb.append( (stringValue.length() > 2) ? stringValue.substring( stringValue.length() - 2 ) : stringValue );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ String stringValue = (isUnsigned()) ? Integer.toOctalString( value.shortValue() ) : Integer.toOctalString( (byte)value.byteValue() );
+ stringValue = (stringValue.length() > 3) ? stringValue.substring( stringValue.length() - 3 ) : stringValue;
+ sb.append( (stringValue.length() == 3 && stringValue.charAt( 0 ) >= '4') ? (char)(stringValue.charAt( 0 ) - 4) + stringValue.substring( 1 ) : stringValue );
+ return sb.toString();
+ }
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
String stringValue = (isUnsigned()) ? Integer.toBinaryString( value.shortValue() ) : Integer.toBinaryString( (byte)value.byteValue() );
@@ -338,6 +359,13 @@ public class CValue extends AbstractCValue {
sb.append( (stringValue.length() > 4) ? stringValue.substring( stringValue.length() - 4 ) : stringValue );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ String stringValue = Integer.toOctalString( (isUnsigned()) ? value.intValue() : value.shortValue() );
+ stringValue = (stringValue.length() > 6) ? stringValue.substring( stringValue.length() - 6 ) : stringValue;
+ sb.append( (stringValue.length() == 6 && stringValue.charAt( 0 ) >= '2') ? (char)((stringValue.charAt( 0 ) - '0') % 2 + '0') + stringValue.substring( 1 ) : stringValue );
+ return sb.toString();
+ }
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
String stringValue = Integer.toBinaryString( (isUnsigned()) ? value.intValue() : value.shortValue() );
@@ -363,6 +391,13 @@ public class CValue extends AbstractCValue {
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ String stringValue = (isUnsigned()) ? Long.toOctalString( value.longValue() ) : Integer.toOctalString( value.intValue() );
+ stringValue = (stringValue.length() > 11) ? stringValue.substring( stringValue.length() - 11 ) : stringValue;
+ sb.append( (stringValue.length() == 11 && stringValue.charAt( 0 ) >= '4') ? (char)(stringValue.charAt( 0 ) - 4) + stringValue.substring( 1 ) : stringValue );
+ return sb.toString();
+ }
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
String stringValue = (isUnsigned()) ? Long.toBinaryString( value.longValue() ) : Integer.toBinaryString( value.intValue() );
@@ -385,7 +420,7 @@ public class CValue extends AbstractCValue {
BigInteger bigValue = new BigInteger( value.getValueString() );
return bigValue.toString();
}
- return Long.toString( value.longValue() );
+ return Integer.toString( value.intValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
@@ -394,7 +429,17 @@ public class CValue extends AbstractCValue {
sb.append( bigValue.toString( 16 ) );
}
else
- sb.append( Long.toHexString( value.longValue() ) );
+ sb.append( Integer.toHexString( value.intValue() ) );
+ return sb.toString();
+ }
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ if ( isUnsigned() ) {
+ BigInteger bigValue = new BigInteger( value.getValueString() );
+ sb.append( bigValue.toString( 8 ) );
+ }
+ else
+ sb.append( Integer.toOctalString( value.intValue() ) );
return sb.toString();
}
else if ( CVariableFormat.BINARY.equals( format ) ) {
@@ -404,7 +449,7 @@ public class CValue extends AbstractCValue {
sb.append( bigValue.toString( 2 ) );
}
else
- sb.append( Long.toBinaryString( value.longValue() ) );
+ sb.append( Integer.toBinaryString( value.intValue() ) );
return sb.toString();
}
}
@@ -438,6 +483,16 @@ public class CValue extends AbstractCValue {
sb.append( Long.toHexString( value.longValue() ) );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ if ( isUnsigned() ) {
+ BigInteger bigValue = new BigInteger( value.getValueString() );
+ sb.append( bigValue.toString( 8 ) );
+ }
+ else
+ sb.append( Long.toOctalString( value.longValue() ) );
+ return sb.toString();
+ }
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
if ( isUnsigned() ) {
@@ -470,6 +525,13 @@ public class CValue extends AbstractCValue {
} else
sb.append(Long.toHexString(bigValue.longValue()));
return sb.toString();
+ } else if (CVariableFormat.OCTAL.equals(format)) {
+ StringBuffer sb = new StringBuffer("0"); //$NON-NLS-1$
+ if (isUnsigned()) {
+ sb.append(bigValue.toString(8));
+ } else
+ sb.append(Long.toOctalString(bigValue.longValue()));
+ return sb.toString();
} else if (CVariableFormat.BINARY.equals(format)) {
StringBuffer sb = new StringBuffer("0b"); //$NON-NLS-1$
if (isUnsigned()) {
@@ -504,6 +566,13 @@ public class CValue extends AbstractCValue {
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ String stringValue = Long.toOctalString( Float.floatToIntBits(floatValue) );
+ stringValue = (stringValue.length() > 11) ? stringValue.substring( stringValue.length() - 11 ) : stringValue;
+ sb.append( (stringValue.length() == 11 && stringValue.charAt( 0 ) >= '4') ? (char)(stringValue.charAt( 0 ) - 4) + stringValue.substring( 1 ) : stringValue );
+ return sb.toString();
+ }
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
String stringValue = Long.toBinaryString( Float.floatToIntBits(floatValue) );
@@ -533,6 +602,13 @@ public class CValue extends AbstractCValue {
sb.append( (stringValue.length() > 16) ? stringValue.substring( stringValue.length() - 16 ) : stringValue );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ String stringValue = Long.toOctalString( Double.doubleToLongBits(doubleValue) );
+ stringValue = (stringValue.length() > 22) ? stringValue.substring( stringValue.length() - 22 ) : stringValue;
+ sb.append( (stringValue.length() == 22 && stringValue.charAt( 0 ) >= '2') ? (char)((stringValue.charAt( 0 ) - '0') % 2 + '0') + stringValue.substring( 1 ) : stringValue );
+ return sb.toString();
+ }
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
String stringValue = Long.toBinaryString( Double.doubleToLongBits(doubleValue) );
@@ -554,9 +630,11 @@ public class CValue extends AbstractCValue {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.HEXADECIMAL.equals( format ) )
return address.toHexAddressString();
- if ( CVariableFormat.DECIMAL.equals( format ) )
+ else if ( CVariableFormat.DECIMAL.equals( format ) )
return address.toString();
- if ( CVariableFormat.BINARY.equals( format ) )
+ else if ( CVariableFormat.OCTAL.equals( format ) )
+ return address.toOctalAddressString();
+ else if ( CVariableFormat.BINARY.equals( format ) )
return address.toBinaryAddressString();
return null;
}
@@ -590,6 +668,13 @@ public class CValue extends AbstractCValue {
sb.append( (stringValue.length() > 4) ? stringValue.substring( stringValue.length() - 4 ) : stringValue );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ String stringValue = Integer.toOctalString( (isUnsigned()) ? value.intValue() : value.shortValue() );
+ stringValue = (stringValue.length() > 6) ? stringValue.substring( stringValue.length() - 6 ) : stringValue;
+ sb.append( (stringValue.length() == 6 && stringValue.charAt( 0 ) >= '2') ? (char)((stringValue.charAt( 0 ) - '0') % 2 + '0') + stringValue.substring( 1 ) : stringValue );
+ return sb.toString();
+ }
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
String stringValue = Integer.toBinaryString( (isUnsigned()) ? value.intValue() : value.shortValue() );
@@ -623,9 +708,16 @@ public class CValue extends AbstractCValue {
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer( "0" ); //$NON-NLS-1$
+ String stringValue = (isUnsigned()) ? Long.toOctalString( value.longValue() ) : Integer.toOctalString( value.intValue() );
+ stringValue = (stringValue.length() > 11) ? stringValue.substring( stringValue.length() - 11 ) : stringValue;
+ sb.append( (stringValue.length() == 11 && stringValue.charAt( 0 ) >= '4') ? (char)(stringValue.charAt( 0 ) - 4) + stringValue.substring( 1 ) : stringValue );
+ return sb.toString();
+ }
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0b" ); //$NON-NLS-1$
- String stringValue = (isUnsigned()) ? Long.toBinaryString( value.longValue() ) : Integer.toHexString( value.intValue() );
+ String stringValue = (isUnsigned()) ? Long.toBinaryString( value.longValue() ) : Integer.toBinaryString( value.intValue() );
sb.append( (stringValue.length() > 32) ? stringValue.substring( stringValue.length() - 32 ) : stringValue );
return sb.toString();
}
@@ -648,14 +740,17 @@ public class CValue extends AbstractCValue {
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer("0x"); //$NON-NLS-1$
- BigInteger bigValue = value.bigIntegerValue();
- sb.append(bigValue.toString(16));
+ sb.append(value.bigIntegerValue().toString(16));
+ return sb.toString();
+ }
+ else if ( CVariableFormat.OCTAL.equals( format ) ) {
+ StringBuffer sb = new StringBuffer("0"); //$NON-NLS-1$
+ sb.append(value.bigIntegerValue().toString(8));
return sb.toString();
}
else if ( CVariableFormat.BINARY.equals( format ) ) {
StringBuffer sb = new StringBuffer("0b"); //$NON-NLS-1$
- BigInteger bigValue = value.bigIntegerValue();
- sb.append(bigValue.toString(2));
+ sb.append(value.bigIntegerValue().toString(2));
return sb.toString();
}
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
index 8e0da95abd..1960ddd60a 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 QNX Software Systems and others.
+ * Copyright (c) 2004, 2012 QNX Software Systems 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
@@ -8,14 +8,10 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
* Ken Ryall (Nokia) - 207675
+ * Mathias Kunter - Support for different charsets (bug 370462)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.preferences;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.SortedMap;
-
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.CCorePreferenceConstants;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@@ -26,8 +22,10 @@ import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.utils.ui.controls.ControlFactory;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.debug.ui.IDebugView;
+import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.StructuredViewer;
@@ -46,6 +44,7 @@ import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.ide.dialogs.EncodingFieldEditor;
/**
* Preference page for debug preferences that apply specifically to C/C++ Debugging.
@@ -57,15 +56,29 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
private Combo fVariableFormatCombo;
private Combo fExpressionFormatCombo;
-
+
private Combo fRegisterFormatCombo;
- private Combo fCharsetCombo;
+ private EncodingFieldEditor fCharsetEditor;
+
+ private EncodingFieldEditor fWideCharsetEditor;
// Format constants
- private static int[] fFormatIds = new int[]{ ICDIFormat.NATURAL, ICDIFormat.HEXADECIMAL, ICDIFormat.DECIMAL, ICDIFormat.BINARY };
-
- private static String[] fFormatLabels = new String[]{ PreferenceMessages.getString( "CDebugPreferencePage.0" ), PreferenceMessages.getString( "CDebugPreferencePage.1" ), PreferenceMessages.getString( "CDebugPreferencePage.2" ), PreferenceMessages.getString( "CDebugPreferencePage.14" ) }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static int[] fFormatIds = new int[] {
+ ICDIFormat.NATURAL,
+ ICDIFormat.HEXADECIMAL,
+ ICDIFormat.DECIMAL,
+ ICDIFormat.OCTAL,
+ ICDIFormat.BINARY
+ };
+
+ private static String[] fFormatLabels = new String[] {
+ PreferenceMessages.getString( "CDebugPreferencePage.0" ), //$NON-NLS-1$
+ PreferenceMessages.getString( "CDebugPreferencePage.1" ), //$NON-NLS-1$
+ PreferenceMessages.getString( "CDebugPreferencePage.2" ), //$NON-NLS-1$
+ PreferenceMessages.getString( "CDebugPreferencePage.17" ), //$NON-NLS-1$
+ PreferenceMessages.getString( "CDebugPreferencePage.14" ) //$NON-NLS-1$
+ };
private PropertyChangeListener fPropertyChangeListener;
@@ -79,10 +92,21 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
public void propertyChange( PropertyChangeEvent event ) {
if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_SHOW_HEX_VALUES ) ) {
fHasStateChanged = true;
- }
- else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_SHOW_CHAR_VALUES ) ) {
+ } else if ( event.getProperty().equals( ICDebugPreferenceConstants.PREF_SHOW_CHAR_VALUES ) ) {
fHasStateChanged = true;
+ } else if (event.getProperty().equals(FieldEditor.VALUE)) {
+ fHasStateChanged = true;
+ } else if (event.getProperty().equals(FieldEditor.IS_VALID)) {
+ setValid(fCharsetEditor.isValid() && fWideCharsetEditor.isValid());
+ if (!fCharsetEditor.isValid()) {
+ setErrorMessage(PreferenceMessages.getString("CDebugPreferencePage.19")); //$NON-NLS-1$
+ } else if (!fWideCharsetEditor.isValid()) {
+ setErrorMessage(PreferenceMessages.getString("CDebugPreferencePage.20")); //$NON-NLS-1$
+ } else {
+ setErrorMessage(null);
+ }
}
+
}
protected boolean hasStateChanged() {
@@ -122,6 +146,8 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
createSpacer( composite, 1 );
createViewSettingPreferences( composite );
createSpacer( composite, 1 );
+ createCharsetSettingPreferences( composite );
+ createSpacer( composite, 1 );
createBinarySettings( composite );
setValues();
return composite;
@@ -146,10 +172,29 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
* Set the values of the component widgets based on the values in the preference store
*/
private void setValues() {
+ // Number format combos
fVariableFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT ) ) );
fExpressionFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) );
fRegisterFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
- fCharsetCombo.setText( CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_CHARSET ) );
+
+ // Charset editors
+ PreferenceStore ps = new PreferenceStore();
+
+ ps.setDefault(ICDebugConstants.PREF_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString(ICDebugConstants.PREF_CHARSET));
+ ps.setValue(ICDebugConstants.PREF_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_CHARSET));
+ fCharsetEditor.setPreferenceStore(ps);
+ fCharsetEditor.load();
+ if (CDebugCorePlugin.getDefault().getPluginPreferences().isDefault(ICDebugConstants.PREF_CHARSET))
+ fCharsetEditor.loadDefault();
+
+ ps.setDefault(ICDebugConstants.PREF_WIDE_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString(ICDebugConstants.PREF_WIDE_CHARSET));
+ ps.setValue(ICDebugConstants.PREF_WIDE_CHARSET, CDebugCorePlugin.getDefault().getPluginPreferences().getString(ICDebugConstants.PREF_WIDE_CHARSET));
+ fWideCharsetEditor.setPreferenceStore(ps);
+ fWideCharsetEditor.load();
+ if (CDebugCorePlugin.getDefault().getPluginPreferences().isDefault(ICDebugConstants.PREF_WIDE_CHARSET))
+ fWideCharsetEditor.loadDefault();
+
+ // Others
fShowBinarySourceFilesButton.setSelection( CCorePlugin.getDefault().getPluginPreferences().getBoolean( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES ) );
}
@@ -196,21 +241,25 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
fVariableFormatCombo = createComboBox( formatComposite, PreferenceMessages.getString( "CDebugPreferencePage.8" ), fFormatLabels, fFormatLabels[0] ); //$NON-NLS-1$
fExpressionFormatCombo = createComboBox( formatComposite, PreferenceMessages.getString( "CDebugPreferencePage.9" ), fFormatLabels, fFormatLabels[0] ); //$NON-NLS-1$
fRegisterFormatCombo = createComboBox( formatComposite, PreferenceMessages.getString( "CDebugPreferencePage.10" ), fFormatLabels, fFormatLabels[0] ); //$NON-NLS-1$
- String[] charsetNames = getCharsetNames();
- fCharsetCombo = createComboBox( formatComposite, PreferenceMessages.getString( "CDebugPreferencePage.16" ), charsetNames, charsetNames[0] ); //$NON-NLS-1$
}
-
- private String[] getCharsetNames() {
- ArrayList names = new ArrayList();
- SortedMap setmap = Charset.availableCharsets();
+
+ private void createCharsetSettingPreferences( Composite parent ) {
+ // Create containing composite
+ Composite formatComposite = ControlFactory.createComposite( parent, 2);
+ ((GridLayout)formatComposite.getLayout()).marginWidth = 0;
+ ((GridLayout)formatComposite.getLayout()).marginHeight = 0;
- for (Iterator iterator = setmap.keySet().iterator(); iterator.hasNext();) {
- String entry = (String) iterator.next();
- names.add(entry);
- }
- return (String[]) names.toArray(new String[names.size()]);
+ // Create charset editor
+ Composite charsetComposite = ControlFactory.createComposite(formatComposite, 1);
+ fCharsetEditor = new EncodingFieldEditor(ICDebugConstants.PREF_CHARSET, "", PreferenceMessages.getString( "CDebugPreferencePage.18" ), charsetComposite); //$NON-NLS-1$ //$NON-NLS-2$
+ fCharsetEditor.setPropertyChangeListener(getPropertyChangeListener());
+
+ // Create wide charset editor
+ Composite wideCharsetComposite = ControlFactory.createComposite(formatComposite, 1);
+ fWideCharsetEditor = new EncodingFieldEditor(ICDebugConstants.PREF_WIDE_CHARSET, "", PreferenceMessages.getString( "CDebugPreferencePage.16" ), wideCharsetComposite); //$NON-NLS-1$ //$NON-NLS-2$
+ fWideCharsetEditor.setPropertyChangeListener(getPropertyChangeListener());
}
-
+
private void createBinarySettings( Composite parent ) {
fShowBinarySourceFilesButton = createCheckButton( parent, PreferenceMessages.getString("CDebugPreferencePage.15") ); //$NON-NLS-1$
}
@@ -304,7 +353,13 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, getFormatId( fVariableFormatCombo.getSelectionIndex() ) );
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, getFormatId( fExpressionFormatCombo.getSelectionIndex() ) );
CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, getFormatId( fRegisterFormatCombo.getSelectionIndex() ) );
- CDebugCorePlugin.getDefault().getPluginPreferences().setValue( ICDebugConstants.PREF_CHARSET, fCharsetCombo.getItem( fCharsetCombo.getSelectionIndex()) );
+
+ fCharsetEditor.store();
+ CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_CHARSET, fCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_CHARSET));
+
+ fWideCharsetEditor.store();
+ CDebugCorePlugin.getDefault().getPluginPreferences().setValue(ICDebugConstants.PREF_WIDE_CHARSET, fWideCharsetEditor.getPreferenceStore().getString(ICDebugConstants.PREF_WIDE_CHARSET));
+
CCorePlugin.getDefault().getPluginPreferences().setValue( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, fShowBinarySourceFilesButton.getSelection() );
}
@@ -323,7 +378,8 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr
fVariableFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT ) ) );
fExpressionFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) );
fRegisterFormatCombo.select( getFormatIndex( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
- fCharsetCombo.setText( CDebugCorePlugin.getDefault().getPluginPreferences().getDefaultString( ICDebugConstants.PREF_CHARSET ) );
+ fCharsetEditor.loadDefault();
+ fWideCharsetEditor.loadDefault();
}
private static int getFormatId( int index ) {
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties
index f3fe088b32..7723772da2 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2003, 2010 QNX Software Systems and others.
+# Copyright (c) 2003, 2012 QNX Software Systems 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
@@ -8,23 +8,28 @@
# Contributors:
# QNX Software Systems - initial API and implementation
# IBM Corporation
+# Mathias Kunter - Support for different charsets (bug 370462)
###############################################################################
CDebugPreferencePage.Color_of_disassembly_source_lines_1=Color of source lines:
-CDebugPreferencePage.0=Natural
+CDebugPreferencePage.0=Default
CDebugPreferencePage.1=Hexadecimal
CDebugPreferencePage.2=Decimal
CDebugPreferencePage.3=General settings for C/C++ Debugging.
-CDebugPreferencePage.4=Opened view default settings
-CDebugPreferencePage.8=Default variable format:
-CDebugPreferencePage.9=Default expression format:
-CDebugPreferencePage.10=Default register format:
+CDebugPreferencePage.4=Default number format
+CDebugPreferencePage.8=Variables:
+CDebugPreferencePage.9=Expressions:
+CDebugPreferencePage.10=Registers:
CDebugPreferencePage.11=Disassembly options
CDebugPreferencePage.12=Maximum number of displayed instructions:
CDebugPreferencePage.13=Value must be an integer between {0} and {1}.
CDebugPreferencePage.14=Binary
CDebugPreferencePage.15=Show source files in binaries
-CDebugPreferencePage.16=Character encoding:
+CDebugPreferencePage.16=Wide character encoding
+CDebugPreferencePage.17=Octal
+CDebugPreferencePage.18=Character encoding
+CDebugPreferencePage.19=The selected character encoding is not supported.
+CDebugPreferencePage.20=The selected wide character encoding is not supported.
SourcePreferencePage.0=Default S&ource Lookup Path:
DebuggerTypesPage.0=Select All
DebuggerTypesPage.1=Deselect All

Back to the top