From 273a31b3651afcbab12d045fd6483126d043aab0 Mon Sep 17 00:00:00 2001 From: John Cortell Date: Thu, 18 Jan 2007 02:04:39 +0000 Subject: Opimization to getExtendedMemoryBlock(). Where the expression is an absolute address (decimal or hex value), we can sidestep a lot of processing--no need to get the backend to resolve the expression as there is really nothing to resolve. --- .../core/CMemoryBlockRetrievalExtension.java | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'debug') diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java index 35cb06ff0ce..e4b442dcc96 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CMemoryBlockRetrievalExtension.java @@ -146,6 +146,23 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM try { if (selected instanceof IDebugElement) { IDebugElement debugElement = (IDebugElement)selected; + IDebugTarget target = debugElement.getDebugTarget(); + if (!(target instanceof CDebugTarget)) { + throw new DebugException( new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, msg, null ) ); + } + + // See if the expression is a simple numeric value; if it is, we can avoid some costly + // processing (calling the backend to resolve the expression) + try { + if (expression.startsWith("0x") && expression.length() > 2) { + return new CMemoryBlockExtension((CDebugTarget)target, expression, new BigInteger(expression.substring(2), 16)); + } else if (Character.isDigit(expression.charAt(0))) { + return new CMemoryBlockExtension((CDebugTarget)target, expression, new BigInteger(expression)); + } + } catch (NumberFormatException nfexc) { + // OK, expression is not a simple, absolute numeric value; keep trucking and try to resolve as expression + } + CStackFrame frame = getStackFrame( debugElement ); if ( frame != null ) { // We need to provide a better way for retrieving the address of expression @@ -157,13 +174,10 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM if ( type != null && (type.isPointer() || type.isIntegralType()) ) { address = value.getValueString(); exp.dispose(); - IDebugTarget target = debugElement.getDebugTarget(); - if ( target instanceof CDebugTarget ) { - if ( address != null ) { - // ??? - BigInteger a = ( address.startsWith( "0x" ) ) ? new BigInteger( address.substring( 2 ), 16 ) : new BigInteger( address ); //$NON-NLS-1$ - return new CMemoryBlockExtension( (CDebugTarget)target, expression, a ); - } + if ( address != null ) { + // ??? + BigInteger a = ( address.startsWith( "0x" ) ) ? new BigInteger( address.substring( 2 ), 16 ) : new BigInteger( address ); //$NON-NLS-1$ + return new CMemoryBlockExtension( (CDebugTarget)target, expression, a ); } } else { @@ -291,4 +305,4 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM return new String[0]; } -} +} \ No newline at end of file -- cgit v1.2.3