From 170bb6ea074b705d5ed868a6c4ce4fbe54610cce Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Wed, 9 Jul 2008 21:21:30 +0000 Subject: [PATCH] [240238] - fixed adding expressions which has "char *" type for example --- .../core/CMemoryBlockRetrievalExtension.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) 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 cb56447806a..46c1c301ebf 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 @@ -265,12 +265,25 @@ public class CMemoryBlockRetrievalExtension extends PlatformObject implements IM ICType type = ((ICValue)value).getType(); if ( type != null ) { // get the address for the expression, allow all types - address = frame.evaluateExpressionToString(exp.getExpressionString()); - 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 ); + String rawExpr = exp.getExpressionString(); + String voidExpr = "(void *)(" + rawExpr + ")"; + String attempts[] = { rawExpr, voidExpr }; + for (int i = 0; i < attempts.length; i++) { + String expr = attempts[i]; + address = frame.evaluateExpressionToString(expr); + if (address != null) { + try { + BigInteger a = (address.startsWith("0x")) ? new BigInteger(address.substring(2), 16) : new BigInteger(address); //$NON-NLS-1$ + return new CMemoryBlockExtension((CDebugTarget) target, expression, a); + } catch (NumberFormatException e) { + // not pointer? lets cast it to void* + if (i == 0) + continue; + throw e; + } + } } + } else { msg = MessageFormat.format( InternalDebugCoreMessages.getString( "CMemoryBlockRetrievalExtension.1" ), (Object[])new String[] { expression } ); //$NON-NLS-1$