1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-08 18:26:01 +02:00

[240238] - fixed adding expressions which has "char *" type for example

This commit is contained in:
Alena Laskavaia 2008-07-09 21:21:30 +00:00
parent 2d3a12da43
commit 170bb6ea07

View file

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