From 3589bf402ab6a5ab7f994f56146a3dcb4a358067 Mon Sep 17 00:00:00 2001 From: Mikhail Khodjaiants Date: Tue, 26 Nov 2002 16:38:03 +0000 Subject: [PATCH] Fix for evaluation of expression to address in the Memory view. --- debug/org.eclipse.cdt.debug.ui/ChangeLog | 5 ++ .../ui/views/memory/MemoryControlArea.java | 57 +++++-------------- 2 files changed, 18 insertions(+), 44 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog index 630da680510..c03cd743374 100644 --- a/debug/org.eclipse.cdt.debug.ui/ChangeLog +++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog @@ -1,3 +1,8 @@ +2002-11-26 Mikhail Khodjaiants + Fix for evaluation of expression to address in the Memory view. + GDB evaluates the array of chars to a string not an address. + * MemoryControlArea.java + 2002-11-21 Mikhail Khodjaiants Added the 'Evaluate' button to the Memory view. * MemoryControlArea.java diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java index 85a8698dfaa..29f9a5ba6fd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/views/memory/MemoryControlArea.java @@ -7,9 +7,9 @@ package org.eclipse.cdt.debug.internal.ui.views.memory; import org.eclipse.cdt.debug.core.CDebugModel; -import org.eclipse.cdt.debug.core.ICExpressionEvaluator; import org.eclipse.cdt.debug.core.ICMemoryManager; import org.eclipse.cdt.debug.core.IFormattedMemoryBlock; +import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import org.eclipse.cdt.debug.internal.ui.preferences.ICDebugPreferenceConstants; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.debug.core.DebugException; @@ -474,58 +474,27 @@ public class MemoryControlArea extends Composite { if ( getMemoryManager() != null ) { - IDebugTarget target = (IDebugTarget)getMemoryManager().getAdapter( IDebugTarget.class ); - if ( target != null ) - { - ICExpressionEvaluator ee = (ICExpressionEvaluator)target.getAdapter( ICExpressionEvaluator.class ); - String newExpression = convertToHexString( evaluateExpression( ee, fAddressText.getText().trim() ) ); - if ( newExpression != null ) - { - fAddressText.setText( newExpression ); - handleAddressEnter(); - } - } - } - fAddressText.forceFocus(); - } - - private String evaluateExpression( ICExpressionEvaluator ee, String expression ) - { - String result = null; - if ( ee != null && ee.canEvaluate() ) - { - try - { - result = ee.evaluateExpressionToString( expression ); - } - catch( DebugException e ) - { - CDebugUIPlugin.errorDialog( "Unable to evaluate expression.", e.getStatus() ); - } - } - return result; - } - - private String convertToHexString( String value ) - { - String result = null; - if ( value != null ) - { - if ( !value.startsWith( "0x" ) ) + if ( getMemoryBlock() == null ) { + String expression = fAddressText.getText().trim(); try { - result = "0x" + Long.toHexString( Long.parseLong( value ) ); + removeBlock(); + if ( expression.length() > 0 ) + { + createBlock( expression ); + } } - catch( NumberFormatException e ) + catch( DebugException e ) { + CDebugUIPlugin.errorDialog( "Unable to get memory block.", e.getStatus() ); } } - else + if ( getMemoryBlock() != null ) { - result = value; + fAddressText.setText( CDebugUIUtils.toHexAddressString( getMemoryBlock().getStartAddress() ) ); + handleAddressEnter(); } } - return result; } }