mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 23:05:47 +02:00
Fix for evaluation of expression to address in the Memory view.
This commit is contained in:
parent
2d754bb7da
commit
3589bf402a
2 changed files with 18 additions and 44 deletions
|
@ -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
|
2002-11-21 Mikhail Khodjaiants
|
||||||
Added the 'Evaluate' button to the Memory view.
|
Added the 'Evaluate' button to the Memory view.
|
||||||
* MemoryControlArea.java
|
* MemoryControlArea.java
|
||||||
|
|
|
@ -7,9 +7,9 @@
|
||||||
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
package org.eclipse.cdt.debug.internal.ui.views.memory;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.CDebugModel;
|
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.ICMemoryManager;
|
||||||
import org.eclipse.cdt.debug.core.IFormattedMemoryBlock;
|
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.internal.ui.preferences.ICDebugPreferenceConstants;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
@ -474,58 +474,27 @@ public class MemoryControlArea extends Composite
|
||||||
{
|
{
|
||||||
if ( getMemoryManager() != null )
|
if ( getMemoryManager() != null )
|
||||||
{
|
{
|
||||||
IDebugTarget target = (IDebugTarget)getMemoryManager().getAdapter( IDebugTarget.class );
|
if ( getMemoryBlock() == null )
|
||||||
if ( target != null )
|
|
||||||
{
|
{
|
||||||
ICExpressionEvaluator ee = (ICExpressionEvaluator)target.getAdapter( ICExpressionEvaluator.class );
|
String expression = fAddressText.getText().trim();
|
||||||
String newExpression = convertToHexString( evaluateExpression( ee, fAddressText.getText().trim() ) );
|
try
|
||||||
if ( newExpression != null )
|
|
||||||
{
|
{
|
||||||
fAddressText.setText( newExpression );
|
removeBlock();
|
||||||
|
if ( expression.length() > 0 )
|
||||||
|
{
|
||||||
|
createBlock( expression );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( DebugException e )
|
||||||
|
{
|
||||||
|
CDebugUIPlugin.errorDialog( "Unable to get memory block.", e.getStatus() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( getMemoryBlock() != null )
|
||||||
|
{
|
||||||
|
fAddressText.setText( CDebugUIUtils.toHexAddressString( getMemoryBlock().getStartAddress() ) );
|
||||||
handleAddressEnter();
|
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" ) )
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
result = "0x" + Long.toHexString( Long.parseLong( value ) );
|
|
||||||
}
|
|
||||||
catch( NumberFormatException e )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue