Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'debug/org.eclipse.cdt.debug.core')
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java15
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/ICDebugConstants.java12
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CDebugCorePreferenceInitializer.java6
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java41
4 files changed, 69 insertions, 5 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 0dfa2db699a..45239286eb6 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
@@ -12,6 +12,8 @@ package org.eclipse.cdt.debug.core;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
@@ -415,4 +417,17 @@ public class CDebugUtils {
private static boolean isEmpty( String string ) {
return ( string == null || string.trim().length() == 0 );
}
+
+ private static CharsetDecoder fDecoder;
+
+ public static CharsetDecoder getCharsetDecoder() {
+ String charsetName = CDebugCorePlugin.getDefault().getPluginPreferences().getString( ICDebugConstants.PREF_CHARSET );
+ if (fDecoder == null || !fDecoder.charset().name().equals(charsetName))
+ {
+ Charset charset = Charset.forName(charsetName);
+ fDecoder = charset.newDecoder();
+ }
+ return fDecoder;
+ }
+
}
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 9f6c630bc7c..5a2664d6657 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Ken Ryall (Nokia) - 207675
*******************************************************************************/
package org.eclipse.cdt.debug.core;
@@ -33,6 +34,12 @@ public interface ICDebugConstants {
* view
*/
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
+ */
+ public static final String PREF_CHARSET = PLUGIN_ID + "cDebug.character_set"; //$NON-NLS-1$
/**
* The identifier of the default expression format to use in the expressions
@@ -90,4 +97,9 @@ public interface ICDebugConstants {
* Temporary. See bugs 79872 and 80323.
*/
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.
+ */
+ public static final String DEF_CHARSET = "UTF-16";
}
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 4996aba13db..66757298b1a 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, 2005 QNX Software Systems and others.
+ * Copyright (c) 2004, 2007 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,7 +7,8 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
- *******************************************************************************/
+ * Ken Ryall (Nokia) - 207675
+*******************************************************************************/
package org.eclipse.cdt.debug.internal.core;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@@ -35,6 +36,7 @@ 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_INSTRUCTION_STEP_MODE_ON, false );
}
}
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 8a85adac557..45f4dd374ea 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
@@ -9,17 +9,22 @@
* QNX Software Systems - Initial API and implementation
* Mark Mitchell, CodeSourcery - Bug 136896: View variables in binary format
* Warren Paul (Nokia) - 150860, 150864, 150862, 150863
- *******************************************************************************/
+ * Ken Ryall (Nokia) - 207675
+*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
import java.math.BigInteger;
+import java.nio.ByteBuffer;
+import java.nio.charset.CharacterCodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
+import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
import org.eclipse.cdt.debug.core.cdi.ICDIFormattable;
@@ -500,7 +505,22 @@ public class CValue extends AbstractCValue {
int size = ((CVariable)getParentVariable()).sizeof();
if ( size == 2 ) {
CVariableFormat format = getParentVariable().getFormat();
- if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
+ if ( CVariableFormat.NATURAL.equals( format ) ) {
+ ByteBuffer buffer = ByteBuffer.allocate(4);
+ buffer.putInt(value.intValue());
+ buffer.position(2);
+ String stringValue;
+ try {
+ stringValue = new String(CDebugUtils.getCharsetDecoder().decode(buffer).array());
+ } catch (CharacterCodingException e) {
+ stringValue = e.toString();
+ }
+ StringBuffer sb = new StringBuffer("'");
+ sb.append(stringValue);
+ sb.append('\'');
+ return sb.toString();
+ }
+ else if ( CVariableFormat.DECIMAL.equals( format ) ) {
return (isUnsigned()) ? Integer.toString( value.intValue() ) : Short.toString( value.shortValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
@@ -518,7 +538,22 @@ public class CValue extends AbstractCValue {
}
if ( size == 4 ) {
CVariableFormat format = getParentVariable().getFormat();
- if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
+ if ( CVariableFormat.NATURAL.equals( format ) ) {
+ ByteBuffer buffer = ByteBuffer.allocate(8);
+ buffer.putLong(value.longValue());
+ buffer.position(4);
+ String stringValue;
+ try {
+ stringValue = new String(CDebugUtils.getCharsetDecoder().decode(buffer).array());
+ } catch (CharacterCodingException e) {
+ stringValue = e.toString();
+ }
+ StringBuffer sb = new StringBuffer("'");
+ sb.append(stringValue);
+ sb.append('\'');
+ return sb.toString();
+ }
+ else if ( CVariableFormat.DECIMAL.equals( format ) ) {
return (isUnsigned()) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {

Back to the top