1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Fix for evaluation of expression to address in the Memory view.

This commit is contained in:
Mikhail Khodjaiants 2002-11-26 16:38:03 +00:00
parent 2d754bb7da
commit 3589bf402a
2 changed files with 18 additions and 44 deletions

View file

@ -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

View file

@ -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;
}
}