Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 365541 | Differences between
and this patch

Collapse All | Expand All

(-)a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java (+2 lines)
Added Link Here
104
	public static final String IMG_OBJS_PATH_MAPPING = NAME_PREFIX + "mapping_obj.gif";	//$NON-NLS-1$
104
	public static final String IMG_OBJS_PATH_MAPPING = NAME_PREFIX + "mapping_obj.gif";	//$NON-NLS-1$
105
	public static final String IMG_OBJS_PATH_MAP_ENTRY = NAME_PREFIX + "mapentry_obj.gif";	//$NON-NLS-1$
105
	public static final String IMG_OBJS_PATH_MAP_ENTRY = NAME_PREFIX + "mapentry_obj.gif";	//$NON-NLS-1$
106
	public static final String IMG_OBJS_COMMON_TAB = NAME_PREFIX + "common_tab.gif"; //$NON-NLS-1$
106
	public static final String IMG_OBJS_COMMON_TAB = NAME_PREFIX + "common_tab.gif"; //$NON-NLS-1$
107
	public static final String IMG_OBJS_ARRAY_PARTITION = NAME_PREFIX + "arraypartition_obj.gif"; //$NON-NLS-1$
107
108
108
	public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif";	//$NON-NLS-1$
109
	public static final String IMG_LCL_TYPE_NAMES = NAME_PREFIX + "tnames_co.gif";	//$NON-NLS-1$
109
	public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif";	//$NON-NLS-1$
110
	public static final String IMG_LCL_CHANGE_REGISTER_VALUE = NAME_PREFIX + "change_reg_value_co.gif";	//$NON-NLS-1$
Added Link Here
188
	public static final ImageDescriptor DESC_OBJS_PATH_MAPPING = createManaged(T_OBJ, IMG_OBJS_PATH_MAPPING);
189
	public static final ImageDescriptor DESC_OBJS_PATH_MAPPING = createManaged(T_OBJ, IMG_OBJS_PATH_MAPPING);
189
    public static final ImageDescriptor DESC_OBJS_PATH_MAP_ENTRY = createManaged(T_OBJ, IMG_OBJS_PATH_MAP_ENTRY);
190
    public static final ImageDescriptor DESC_OBJS_PATH_MAP_ENTRY = createManaged(T_OBJ, IMG_OBJS_PATH_MAP_ENTRY);
190
    public static final ImageDescriptor DESC_OBJS_COMMON_TAB = createManaged(T_OBJ, IMG_OBJS_COMMON_TAB);
191
    public static final ImageDescriptor DESC_OBJS_COMMON_TAB = createManaged(T_OBJ, IMG_OBJS_COMMON_TAB);
192
    public static final ImageDescriptor DESC_OBJS_ARRAY_PARTITION = createManaged(T_OBJ, IMG_OBJS_ARRAY_PARTITION);
191
	public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE = createManaged(T_WIZBAN, IMG_WIZBAN_ADD_SOURCE);
193
	public static final ImageDescriptor DESC_WIZBAN_ADD_SOURCE = createManaged(T_WIZBAN, IMG_WIZBAN_ADD_SOURCE);
192
	public static final ImageDescriptor DESC_WIZBAN_PATH_MAPPING = createManaged(T_WIZBAN, IMG_WIZBAN_PATH_MAPPING);
194
	public static final ImageDescriptor DESC_WIZBAN_PATH_MAPPING = createManaged(T_WIZBAN, IMG_WIZBAN_PATH_MAPPING);
193
	public static final ImageDescriptor DESC_WIZBAN_PATH_MAP_ENTRY = createManaged(T_WIZBAN, IMG_WIZBAN_PATH_MAP_ENTRY);
195
	public static final ImageDescriptor DESC_WIZBAN_PATH_MAP_ENTRY = createManaged(T_WIZBAN, IMG_WIZBAN_PATH_MAP_ENTRY);
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java (-63 / +354 lines)
Lines 13-24 Link Here
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.cdt.dsf.mi.service;
14
package org.eclipse.cdt.dsf.mi.service;
15
15
16
import java.util.Arrays;
16
import java.util.HashMap;
17
import java.util.HashMap;
17
import java.util.Hashtable;
18
import java.util.Hashtable;
18
import java.util.Map;
19
import java.util.Map;
19
20
20
import org.eclipse.cdt.core.IAddress;
21
import org.eclipse.cdt.core.IAddress;
21
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
22
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
23
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
22
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
24
import org.eclipse.cdt.dsf.concurrent.ImmediateRequestMonitor;
23
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
25
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
24
import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
26
import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
Lines 70-75 Link Here
70
 * @since 2.0
72
 * @since 2.0
71
 */
73
 */
72
public class MIExpressions extends AbstractDsfService implements IMIExpressions, ICachingService {
74
public class MIExpressions extends AbstractDsfService implements IMIExpressions, ICachingService {
75
76
	private static final int PARTITION_LENGTH = 100;
73
77
74
    /**
78
    /**
75
     * A format that gives more details about an expression and supports pretty-printing
79
     * A format that gives more details about an expression and supports pretty-printing
Lines 381-387 Link Here
381
			this.exprInfo = info;
385
			this.exprInfo = info;
382
		}
386
		}
383
    }
387
    }
384
    
388
385
    protected static class InvalidContextExpressionDMC extends AbstractDMContext 
389
    protected static class InvalidContextExpressionDMC extends AbstractDMContext 
386
        implements IExpressionDMContext
390
        implements IExpressionDMContext
387
    {
391
    {
Lines 411-416 Link Here
411
    	@Override
415
    	@Override
412
        public String getExpression() {
416
        public String getExpression() {
413
            return expression;
417
            return expression;
418
        }
419
    }
420
421
    /**
422
	 * @since 4.1
423
	 */
424
    protected static class IndexedPartitionDMC extends MIExpressionDMC implements IIndexedPartitionDMContext {
425
426
    	final private ExpressionInfo fParentInfo;
427
		private final int fIndex;
428
    	private final int fLength;
429
    	
430
		public IndexedPartitionDMC(
431
				String sessionId, 
432
				ExpressionInfo parentInfo, 
433
				IFrameDMContext frameCtx, 
434
				int index, 
435
				int length) {
436
			this(sessionId, parentInfo, (IDMContext)frameCtx, index, length);
437
		}
438
439
    	private IndexedPartitionDMC(
440
    			String sessionId, 
441
    			ExpressionInfo parentInfo, 
442
    			IDMContext parent, 
443
    			int index, 
444
    			int length) {
445
			super(sessionId, createExpressionInfo(parentInfo, index, length), parent);
446
			fIndex = index;
447
			fLength = length;
448
			fParentInfo = parentInfo;
449
		}
450
451
    	public ExpressionInfo getParentInfo() {
452
    		return fParentInfo;
453
    	}
454
455
		/* (non-Javadoc)
456
		 * @see org.eclipse.cdt.dsf.debug.service.IExpressions4.IIndexedPartitionDMContext#getParentExpression()
457
		 */
458
		@Override
459
		public String getParentExpression() {
460
			return getParentInfo().getFullExpr();
461
		}
462
463
		@Override
464
		public int getIndex() {
465
			return fIndex;
466
		}
467
468
		@Override
469
		public int getLength() {
470
			return fLength;
471
		}
472
473
        @Override
474
        public boolean equals(Object other) {
475
            return super.baseEquals(other) &&
476
                    ((IndexedPartitionDMC) other).getParentInfo().equals(getParentInfo()) &&
477
                    ((IndexedPartitionDMC) other).getIndex() == getIndex() &&
478
                    ((IndexedPartitionDMC) other).getLength() == getLength();                
479
        }
480
481
        @Override
482
        public int hashCode() {
483
            return super.baseHashCode() + 17*getIndex() + 31*getLength();
484
        }
485
486
        @Override
487
        public String toString() {
488
            return String.format( "%s[%d-%d]", baseToString(), Integer.valueOf( getIndex() ), Integer.valueOf( getIndex() + getLength() ) ); //$NON-NLS-1$
489
        }
490
491
        private static ExpressionInfo createExpressionInfo(ExpressionInfo parentInfo, int index, int length) {
492
        	String expression = String.format(
493
        			"*((%s)+%d)@%d",  //$NON-NLS-1$
494
        			parentInfo.getFullExpr(), 
495
        			Integer.valueOf(index), 
496
        			Integer.valueOf(length));
497
        	return new ExpressionInfo(expression, expression);
414
        }
498
        }
415
    }
499
    }
416
    
500
    
Lines 1064-1096 Link Here
1064
	 *            The data request monitor that will contain the requested data
1148
	 *            The data request monitor that will contain the requested data
1065
	 */
1149
	 */
1066
	@Override
1150
	@Override
1067
	public void getSubExpressions(final IExpressionDMContext dmc,
1151
	public void getSubExpressions(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMContext[]> rm) {
1068
			final DataRequestMonitor<IExpressionDMContext[]> rm) 
1152
		getSubExpressions(dmc, -1, -1, rm);
1069
	{		
1070
		if (dmc instanceof MIExpressionDMC) {
1071
			fExpressionCache.execute(
1072
					new ExprMetaGetChildren(dmc),				
1073
					new DataRequestMonitor<ExprMetaGetChildrenInfo>(getExecutor(), rm) {
1074
						@Override
1075
						protected void handleSuccess() {
1076
							ExpressionInfo[] childrenExpr = getData().getChildrenExpressions();
1077
							IExpressionDMContext[] childArray = new IExpressionDMContext[childrenExpr.length];
1078
							for (int i=0; i<childArray.length; i++) {
1079
								childArray[i] = createExpression(
1080
										dmc.getParents()[0], childrenExpr[i]);
1081
							}
1082
1083
							rm.setData(childArray);
1084
							rm.done();
1085
						}
1086
					});
1087
		} else if (dmc instanceof InvalidContextExpressionDMC) {
1088
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1089
			rm.done();
1090
		} else {
1091
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid expression context.", null)); //$NON-NLS-1$
1092
			rm.done();
1093
		}
1094
	}
1153
	}
1095
1154
1096
	/**
1155
	/**
Lines 1112-1148 Link Here
1112
	public void getSubExpressions(final IExpressionDMContext exprCtx, final int startIndex,
1171
	public void getSubExpressions(final IExpressionDMContext exprCtx, final int startIndex,
1113
			final int length, final DataRequestMonitor<IExpressionDMContext[]> rm) {
1172
			final int length, final DataRequestMonitor<IExpressionDMContext[]> rm) {
1114
1173
1115
		if (startIndex < 0 || length < 0) {
1174
		if (exprCtx instanceof IndexedPartitionDMC) {
1116
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
1175
			getIndexedPartitionChildren((IndexedPartitionDMC)exprCtx, startIndex, length, rm);
1117
			rm.done();
1118
			return;
1119
		}
1176
		}
1120
		
1177
		else if (exprCtx instanceof MIExpressionDMC) {
1121
		if (exprCtx instanceof MIExpressionDMC) {
1178
			getRealSubExpressionCount(
1122
			fExpressionCache.execute(
1179
				exprCtx, 
1123
					new ExprMetaGetChildren(exprCtx, startIndex + length),				
1180
				IMIExpressions.CHILD_COUNT_LIMIT_UNSPECIFIED, 
1124
					new DataRequestMonitor<ExprMetaGetChildrenInfo>(getExecutor(), rm) {
1181
				new DataRequestMonitor<Integer>(getExecutor(), rm) {
1125
						@Override
1182
					/* (non-Javadoc)
1126
						protected void handleSuccess() {
1183
					 * @see org.eclipse.cdt.dsf.concurrent.RequestMonitor#handleSuccess()
1127
							ExpressionInfo[] childrenExpr = getData().getChildrenExpressions();
1184
					 */
1128
1185
					@Override
1129
							if (startIndex >= childrenExpr.length) {
1186
					protected void handleSuccess() {
1130
								rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
1187
						final int realNumChildren = getData().intValue();
1131
								rm.done();
1188
						if (realNumChildren == 0) {
1132
								return;
1189
							rm.setData(new IExpressionDMContext[0]);
1133
							}
1134
1135
							int numChildren = childrenExpr.length - startIndex;
1136
							numChildren = Math.min(length, numChildren);
1137
							IExpressionDMContext[] childrenArray = new IExpressionDMContext[numChildren];
1138
							for (int i=0; i < numChildren; i++) {
1139
								childrenArray[i] = createExpression(
1140
										exprCtx.getParents()[0], childrenExpr[startIndex + i]);
1141
							}
1142
							rm.setData(childrenArray);
1143
							rm.done();
1190
							rm.done();
1191
							return;
1144
						}
1192
						}
1145
					});
1193
1194
						if (realNumChildren <= getArrayPartitionLength()) {
1195
							getRealSubExpressions(exprCtx, startIndex, length, rm);
1196
						}
1197
						else {
1198
							getExpressionData(
1199
									exprCtx, 
1200
									new DataRequestMonitor<IExpressionDMData>(ImmediateExecutor.getInstance(), rm) {
1201
1202
										@Override
1203
										protected void handleSuccess() {
1204
											if (IExpressionDMData.BasicType.array.equals(getData().getBasicType())) {
1205
												rm.setData(getTopLevelIndexedPartitions((MIExpressionDMC)exprCtx, realNumChildren, startIndex, length ));
1206
												rm.done();
1207
											}
1208
											else {
1209
												getRealSubExpressions(exprCtx, startIndex, length, rm);
1210
											}
1211
										}
1212
									});
1213
						}
1214
					}
1215
				});
1146
		} else if (exprCtx instanceof InvalidContextExpressionDMC) {
1216
		} else if (exprCtx instanceof InvalidContextExpressionDMC) {
1147
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1217
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1148
			rm.done();
1218
			rm.done();
Lines 1183-1201 Link Here
1183
	 * @since 4.0
1253
	 * @since 4.0
1184
	 */
1254
	 */
1185
	@Override
1255
	@Override
1186
	public void getSubExpressionCount(IExpressionDMContext dmc,
1256
	public void getSubExpressionCount(final IExpressionDMContext dmc,
1187
			final int numChildLimit, final DataRequestMonitor<Integer> rm) {
1257
			final int numChildLimit, final DataRequestMonitor<Integer> rm) {
1188
1258
1189
		if (dmc instanceof MIExpressionDMC) {
1259
		if (dmc instanceof MIExpressionDMC) {
1190
			fExpressionCache.execute(
1260
			if (dmc instanceof IndexedPartitionDMC) {
1191
					new ExprMetaGetChildCount(dmc, numChildLimit),				
1261
				int length = ((IndexedPartitionDMC)dmc).getLength();
1192
					new DataRequestMonitor<ExprMetaGetChildCountInfo>(getExecutor(), rm) {
1262
				rm.setData(computeNumberOfChildren(length));
1263
				rm.done();
1264
			}
1265
			else {
1266
				getRealSubExpressionCount( 
1267
					dmc, 
1268
					numChildLimit, 
1269
					new DataRequestMonitor<Integer>(getExecutor(), rm) {
1270
1193
						@Override
1271
						@Override
1194
						protected void handleSuccess() {
1272
						protected void handleSuccess() {
1195
							rm.setData(getData().getChildNum());
1273
							final int realNum = getData().intValue();
1196
							rm.done();
1274
							if (realNum <= getArrayPartitionLength()) {
1197
						}
1275
								rm.setData(Integer.valueOf(realNum));
1276
								rm.done();
1277
							}
1278
							else {
1279
								getExpressionData(
1280
									dmc, 
1281
									new DataRequestMonitor<IExpressionDMData>(ImmediateExecutor.getInstance(), rm) {
1282
1283
										@Override
1284
										protected void handleSuccess() {
1285
											if (IExpressionDMData.BasicType.array.equals(getData().getBasicType())) {
1286
												rm.setData(computeNumberOfChildren(realNum));
1287
											}
1288
											else {
1289
												rm.setData(Integer.valueOf(realNum));
1290
											}
1291
											rm.done();
1292
										}
1293
									});
1294
							}
1295
						}				
1198
					});
1296
					});
1297
			}
1199
		} else if (dmc instanceof InvalidContextExpressionDMC) {
1298
		} else if (dmc instanceof InvalidContextExpressionDMC) {
1200
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1299
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1201
			rm.done();
1300
			rm.done();
Lines 1442-1445 Link Here
1442
            }
1541
            }
1443
        }); 
1542
        }); 
1444
    }
1543
    }
1544
1545
	private IndexedPartitionDMC[] getTopLevelIndexedPartitions(
1546
			MIExpressionDMC exprCtx, 
1547
			int realNumChildren, 
1548
			int startIndex, 
1549
			int length) {
1550
1551
		int numChildren = computeNumberOfChildren(realNumChildren);
1552
		if (startIndex >= numChildren)
1553
			return new IndexedPartitionDMC[0];
1554
		int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1555
		int length1 = (length < 0) ? numChildren - startIndex1 : Math.min(length, numChildren - startIndex1);
1556
1557
		IndexedPartitionDMC[] children = new IndexedPartitionDMC[numChildren];
1558
		int index = 0;
1559
		for(int i = 0; i < children.length; ++i) {
1560
			int partLength = computePartitionLength(realNumChildren, i);
1561
			children[i] = createIndexedPartition(
1562
				exprCtx.getParents()[0], 
1563
				exprCtx.getExpressionInfo(), 
1564
				index, 
1565
				partLength);
1566
			index += partLength;
1567
		}
1568
		return Arrays.copyOfRange(children, startIndex1, startIndex1 + length1 );
1569
	}
1570
1571
	private void getIndexedPartitionChildren(
1572
			final IndexedPartitionDMC partDmc, 
1573
			final int startIndex,
1574
			final int length, 
1575
			final DataRequestMonitor<IExpressionDMContext[]> rm) {
1576
		
1577
		final int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1578
		final int length1 = (length < 0) ? Integer.MAX_VALUE : length;
1579
1580
		final int partStartIndex = partDmc.getIndex();
1581
		final int partLength = partDmc.getLength();
1582
		if (partLength > getArrayPartitionLength()) {
1583
			// create subpartitions
1584
			int numChildren = computeNumberOfChildren(partLength);
1585
			
1586
			if (startIndex1 >= numChildren) {
1587
				rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
1588
				rm.done();
1589
				return;
1590
			}
1591
1592
			int numPart = Math.min(numChildren, length1);
1593
			IndexedPartitionDMC[] children = new IndexedPartitionDMC[numPart];
1594
			int index = partStartIndex;
1595
			for (int i = 0; i < startIndex1; ++i)
1596
				index += computePartitionLength(partLength, i);
1597
			for (int i = 0; i < children.length; ++i) {
1598
				int childPartLength = computePartitionLength(partLength, i + startIndex1);
1599
				children[i] = createIndexedPartition(
1600
					partDmc, 
1601
					partDmc.getParentInfo(), 
1602
					index, 
1603
					childPartLength);
1604
				index += childPartLength;
1605
			}
1606
			rm.setData(children);
1607
			rm.done();
1608
		}
1609
		else {
1610
			// this is the last partition level, create "real" children
1611
			if (startIndex1 > partLength) {
1612
				rm.setData(new IExpressionDMContext[0]);
1613
				rm.done();
1614
			}
1615
			else {
1616
				getRealSubExpressions(
1617
						createExpression(partDmc.getParents()[0], partDmc.getParentInfo()), 
1618
						partStartIndex + startIndex1, 
1619
						Math.min(length1, partLength - startIndex1), 
1620
						rm);
1621
			}
1622
		}
1623
	}
1624
1625
	void getRealSubExpressions(
1626
			final IExpressionDMContext exprCtx, 
1627
			int startIndex,
1628
			int length, 
1629
			final DataRequestMonitor<IExpressionDMContext[]> rm) {
1630
		
1631
		ExprMetaGetChildren getChildren = (startIndex < 0 || length < 0) ? 
1632
				new ExprMetaGetChildren(exprCtx) : new ExprMetaGetChildren(exprCtx, startIndex + length);
1633
		final int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1634
		final int length1 = (length < 0) ? Integer.MAX_VALUE : length;
1635
		fExpressionCache.execute(
1636
				getChildren,				
1637
				new DataRequestMonitor<ExprMetaGetChildrenInfo>(getExecutor(), rm) {
1638
					@Override
1639
					protected void handleSuccess() {
1640
						ExpressionInfo[] childrenExpr = getData().getChildrenExpressions();
1641
1642
						if (startIndex1 >= childrenExpr.length) {
1643
							rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
1644
							rm.done();
1645
							return;
1646
						}
1647
1648
						int numChildren = childrenExpr.length - startIndex1;
1649
						numChildren = Math.min(length1, numChildren);
1650
						IExpressionDMContext[] childrenArray = new IExpressionDMContext[numChildren];
1651
						for (int i=0; i < numChildren; i++) {
1652
							childrenArray[i] = createExpression(exprCtx.getParents()[0], childrenExpr[startIndex1 + i]);
1653
						}
1654
						rm.setData(childrenArray);
1655
						rm.done();
1656
					}
1657
				});
1658
	}
1659
1660
	/**
1661
	 * Returns the number of "real" children if it is less or equal to the partition size, 
1662
	 * otherwise returns the number of partitions. 
1663
	 */
1664
	private int computeNumberOfChildren(int realNumberOfChildren) {
1665
		int childNum = realNumberOfChildren;
1666
		int partLength = getArrayPartitionLength();
1667
		while (childNum > partLength) {
1668
			childNum /= partLength;
1669
		}
1670
		if (childNum*partLength < realNumberOfChildren)
1671
			++childNum;
1672
		return childNum;
1673
	}
1674
1675
	private int computePartitionLength(int realNumberOfChildren, int index) {
1676
		int childNum = realNumberOfChildren;
1677
		int depth = 0;
1678
		int partLength = getArrayPartitionLength();
1679
		int length = partLength;
1680
		while (childNum > partLength) {
1681
			childNum /= partLength;
1682
			if (depth > 0)
1683
				length *= partLength;
1684
			++depth;
1685
		}
1686
		int diff = realNumberOfChildren - length*index;
1687
		return ( diff > length ) ? length : diff ;
1688
	}
1689
1690
	private IndexedPartitionDMC createIndexedPartition(IDMContext ctx, ExpressionInfo info, int index, int length) {
1691
	    IFrameDMContext frameDmc = DMContexts.getAncestorOfType(ctx, IFrameDMContext.class);
1692
	    if (frameDmc != null) {
1693
	        return new IndexedPartitionDMC(getSession().getId(), info, frameDmc, index, length);
1694
	    } 
1695
	    
1696
	    IMIExecutionDMContext execCtx = DMContexts.getAncestorOfType(ctx, IMIExecutionDMContext.class);
1697
	    if (execCtx != null) {
1698
	    	// If we have a thread context but not a frame context, we give the user
1699
	    	// the expression as per the top-most frame of the specified thread.
1700
	    	// To do this, we create our own frame context.
1701
	    	MIStack stackService = getServicesTracker().getService(MIStack.class);
1702
	    	if (stackService != null) {
1703
	    		frameDmc = stackService.createFrameDMContext(execCtx, 0);
1704
	            return new IndexedPartitionDMC(getSession().getId(), info, frameDmc, index, length);
1705
	    	}
1706
        } 
1707
1708
        return new IndexedPartitionDMC(getSession().getId(), info, ctx, index, length);
1709
	}
1710
1711
	private void getRealSubExpressionCount(IExpressionDMContext dmc, int numChildLimit, final DataRequestMonitor<Integer> rm) {
1712
		if (dmc instanceof MIExpressionDMC) {
1713
			fExpressionCache.execute(
1714
					new ExprMetaGetChildCount(dmc, numChildLimit),				
1715
					new DataRequestMonitor<ExprMetaGetChildCountInfo>(getExecutor(), rm) {
1716
						@Override
1717
						protected void handleSuccess() {
1718
							rm.setData(getData().getChildNum());
1719
							rm.done();
1720
						}
1721
					});
1722
		} else if (dmc instanceof InvalidContextExpressionDMC) {
1723
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1724
			rm.done();
1725
		} else {
1726
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid expression context.", null)); //$NON-NLS-1$
1727
			rm.done();
1728
		}
1729
	}
1730
1731
	private int getArrayPartitionLength() {
1732
		// Replace this in case we or the platform decide to add a user preference.
1733
		// See org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.
1734
		return PARTITION_LENGTH;
1735
	}
1445
}
1736
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java (+4 lines)
Lines 31-36 Link Here
31
import org.eclipse.cdt.dsf.datamodel.DMContexts;
31
import org.eclipse.cdt.dsf.datamodel.DMContexts;
32
import org.eclipse.cdt.dsf.debug.service.IExpressions;
32
import org.eclipse.cdt.dsf.debug.service.IExpressions;
33
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
33
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
34
import org.eclipse.cdt.dsf.debug.service.IExpressions.IIndexedPartitionDMContext;
34
import org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext;
35
import org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext;
35
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
36
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
36
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
37
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
Lines 1274-1279 Link Here
1274
	        		exprName = '(' + exprName + ')';
1275
	        		exprName = '(' + exprName + ')';
1275
	        		castingIndex = ((ICastedExpressionDMContext)exprDmc).getCastInfo().getArrayStartIndex();
1276
	        		castingIndex = ((ICastedExpressionDMContext)exprDmc).getCastInfo().getArrayStartIndex();
1276
	        	}
1277
	        	}
1278
	        	if (exprDmc instanceof IIndexedPartitionDMContext) {
1279
	        		castingIndex = ((IIndexedPartitionDMContext)exprDmc).getIndex();
1280
	        	}
1277
	        	for (int i= 0; i < childrenOfArray.length; i++) {
1281
	        	for (int i= 0; i < childrenOfArray.length; i++) {
1278
	        		String fullExpr = exprName + "[" + i + "]";//$NON-NLS-1$//$NON-NLS-2$
1282
	        		String fullExpr = exprName + "[" + i + "]";//$NON-NLS-1$//$NON-NLS-2$
1279
	        		String relExpr = exprDmc.getRelativeExpression() + "[" + (castingIndex + i) + "]";//$NON-NLS-1$//$NON-NLS-2$
1283
	        		String relExpr = exprDmc.getRelativeExpression() + "[" + (castingIndex + i) + "]";//$NON-NLS-1$//$NON-NLS-2$
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/ExpressionTestApp.cc (+9 lines)
Lines 293-298 Link Here
293
	return 1;
293
	return 1;
294
}
294
}
295
295
296
int testArrays() {
297
	int array_simple[10];
298
	int array_int[24321];
299
	foo array_foo[1200];
300
301
	return 1;
302
}
303
296
int main() {
304
int main() {
297
    printf("Running ExpressionTest App\n");
305
    printf("Running ExpressionTest App\n");
298
306
Lines 317-322 Link Here
317
    testConcurrentUpdateOutOfScopeChildThenParent();
325
    testConcurrentUpdateOutOfScopeChildThenParent();
318
    testUpdateOfPointer();
326
    testUpdateOfPointer();
319
    testCanWrite();
327
    testCanWrite();
328
    testArrays();
320
    
329
    
321
    // For bug 320277
330
    // For bug 320277
322
    BaseTest b; b.test();
331
    BaseTest b; b.test();
(-)a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/MIExpressionsTest.java (-30 / +139 lines)
Lines 26-31 Link Here
26
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
26
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
27
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
27
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
28
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
28
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
29
import org.eclipse.cdt.dsf.debug.service.IExpressions.IIndexedPartitionDMContext;
29
import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension;
30
import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension;
30
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
31
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
31
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
32
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
Lines 320-356 Link Here
320
321
321
        final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
322
        final IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
322
323
323
        final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
324
        
325
    	// First we get the expected value of the array pointer.
324
    	// First we get the expected value of the array pointer.
326
        final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "f");
325
        final IExpressionDMContext exprDmc = SyncUtil.createExpression(frameDmc, "f");
327
326
328
        fExpService.getExecutor().submit(new Runnable() {
327
        getChildrenCount(exprDmc, 5);
329
            @Override
330
			public void run() {
331
                fExpService.getSubExpressionCount(
332
                		exprDmc, 
333
                		new DataRequestMonitor<Integer>(fExpService.getExecutor(), null) {
334
                			@Override
335
                			protected void handleCompleted() {
336
                				if (!isSuccess()) {
337
                					wait.waitFinished(getStatus());
338
                				} else {
339
                					int count = getData();
340
                					if (count != 5) {
341
                						wait.waitFinished(new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID,
342
                								"Failed getting count for children.  Got " + count + " instead of 5", null));
343
                					} else {
344
                						wait.waitFinished();
345
                					}
346
                				}
347
                			}
348
                		});
349
            }
350
        });
351
352
        wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
353
        assertTrue(wait.getMessage(), wait.isOK());
354
    }
328
    }
355
329
356
    /**
330
    /**
Lines 3263-3270 Link Here
3263
	        getExprChangedCount() == 0);
3237
	        getExprChangedCount() == 0);
3264
	}
3238
	}
3265
3239
3240
	private IExpressionDMContext[] getChildren(IExpressionDMContext parentDmc, String[] expectedValues) throws Throwable {
3241
    	return getChildren(parentDmc, -1, -1, expectedValues );
3242
    }
3243
3266
    private IExpressionDMContext[] getChildren(
3244
    private IExpressionDMContext[] getChildren(
3267
    		final IExpressionDMContext parentDmc, 
3245
    		final IExpressionDMContext parentDmc,
3246
    		final int startIndex,
3247
    		final int length,
3268
    		String[] expectedValues) throws Throwable {
3248
    		String[] expectedValues) throws Throwable {
3269
3249
3270
        final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
3250
        final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
Lines 3273-3279 Link Here
3273
            @Override
3253
            @Override
3274
			public void run() {
3254
			public void run() {
3275
3255
3276
                fExpService.getSubExpressions(parentDmc,
3256
                fExpService.getSubExpressions(
3257
                	parentDmc,
3258
                	startIndex,
3259
                	length,
3277
                    new DataRequestMonitor<IExpressionDMContext[]>(fExpService.getExecutor(), null) {
3260
                    new DataRequestMonitor<IExpressionDMContext[]>(fExpService.getExecutor(), null) {
3278
                        @Override
3261
                        @Override
3279
                        protected void handleCompleted() {
3262
                        protected void handleCompleted() {
Lines 3311-3314 Link Here
3311
        
3294
        
3312
        return childDmcs;
3295
        return childDmcs;
3313
    }
3296
    }
3297
3298
    /**
3299
     * This test verifies that large arrays are properly partitioned and 
3300
     * the handling of "small" arrays is not affected.
3301
     */
3302
    @Test
3303
    public void testArrays() throws Throwable {
3304
    	MIStoppedEvent stoppedEvent = SyncUtil.runToLocation("testArrays");
3305
3306
        IFrameDMContext frameDmc = SyncUtil.getStackFrame(stoppedEvent.getDMContext(), 0);
3307
	    
3308
        // int array_simple[10];
3309
	    IExpressionDMContext arraySimpleExprDMC = SyncUtil.createExpression(frameDmc, "array_simple");
3310
	    
3311
	    getChildrenCount(arraySimpleExprDMC, 10);
3312
3313
	    // get all children
3314
	    String[] expectedValues = new String[10];
3315
	    for (int i = 0; i < expectedValues.length; ++i) {
3316
	    	expectedValues[i] = String.format("array_simple[%d]", i);
3317
	    }
3318
	    IExpressionDMContext[] arraySimpleChildren = getChildren(arraySimpleExprDMC, expectedValues);
3319
	    for (IExpressionDMContext ctx : arraySimpleChildren)
3320
	    	getChildren(ctx, new String[0]);
3321
	    
3322
	    // get some parts of the children array
3323
	    getChildren(arraySimpleExprDMC, 3, 2, new String[] { "array_simple[3]", "array_simple[4]" });
3324
	    getChildren(arraySimpleExprDMC, 9, 3, new String[] { "array_simple[9]" });
3325
3326
	    // int array_int[24321];
3327
	    IExpressionDMContext arrayIntExprDMC = SyncUtil.createExpression(frameDmc, "array_int");
3328
	    getChildrenCount(arrayIntExprDMC, 3);
3329
	    
3330
	    // get top level partitions: [0-9999], [10000-19999], [20000-24321]
3331
	    IExpressionDMContext[] arrayIntPartitions =
3332
		    	getChildren(arrayIntExprDMC, new String[] {"*((array_int)+0)@10000", "*((array_int)+10000)@10000", "*((array_int)+20000)@4321"});
3333
	    assertTrue(String.format("Invalid number of partition: expected 3 got %d", arrayIntPartitions.length), arrayIntPartitions.length == 3);
3334
3335
	    // get children of the last partition: [20000-24321] 
3336
	    expectedValues = new String[44];
3337
	    for(int i = 0; i < expectedValues.length - 1; ++i) {
3338
	    	expectedValues[i] = String.format("*((array_int)+%d)@100", 20000 + i*100);
3339
	    }
3340
	    expectedValues[expectedValues.length - 1] = "*((array_int)+24300)@21";
3341
	    IExpressionDMContext[] arrayIntPartitions1 = getChildren(arrayIntPartitions[2], expectedValues);
3342
	    expectedValues = new String[21];
3343
	    for(int i = 0; i < expectedValues.length; ++i) {
3344
	    	expectedValues[i] = String.format("array_int[%d]", 24300 + i);
3345
	    }
3346
	    getChildren(arrayIntPartitions1[arrayIntPartitions1.length - 1], expectedValues);
3347
3348
	    // foo array_foo[1200];
3349
	    IExpressionDMContext arrayFooExprDMC = SyncUtil.createExpression(frameDmc, "array_foo");	    
3350
	    getChildrenCount(arrayFooExprDMC, 12);
3351
	    expectedValues = new String[12];
3352
	    for (int i = 0; i < expectedValues.length; ++i) {
3353
	    	expectedValues[i] = String.format("*((array_foo)+%d)@%d", i*100, 100);
3354
	    }
3355
	    IExpressionDMContext[] arrayFooPartitions =	getChildren(arrayFooExprDMC, expectedValues);
3356
	    for (int i = 0; i < arrayFooPartitions.length; ++i) {
3357
	    	IExpressionDMContext ctx = arrayFooPartitions[i];
3358
	    	assertTrue(String.format("Invalid DM context type: expected '%s' got '%s'", 
3359
	    			IIndexedPartitionDMContext.class.getName(), ctx.getClass().getName()), 
3360
	    			ctx instanceof IIndexedPartitionDMContext);
3361
		    expectedValues = new String[100];
3362
		    for (int j = 0; j < expectedValues.length; ++j) {
3363
		    	expectedValues[j] = String.format("array_foo[%d]", i*100 + j);
3364
		    }
3365
		    IExpressionDMContext[] arrayFooChildren = getChildren(ctx, expectedValues);
3366
		    for (IExpressionDMContext fooCtx : arrayFooChildren) {
3367
		    	getChildren(fooCtx, new String[] {"bar", "bar2", "a", "b", "c"});
3368
		    }
3369
		    
3370
		    // get parts of the children array
3371
		    expectedValues = new String[] { String.format("array_foo[%d]", i*100 + 3), String.format("array_foo[%d]", i*100 + 4) };
3372
		    getChildren(ctx, 3, 2, expectedValues);
3373
		    getChildren(ctx, 99, 3, new String[] { String.format("array_foo[%d]", i*100 + 99) });
3374
	    }
3375
    }
3376
3377
    private int getChildrenCount(final IExpressionDMContext parentDmc, final int expectedCount) throws Throwable {
3378
3379
        final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
3380
3381
        fExpService.getExecutor().submit(new Runnable() {
3382
            @Override
3383
			public void run() {
3384
3385
                fExpService.getSubExpressionCount(
3386
                	parentDmc,
3387
                    new DataRequestMonitor<Integer>(fExpService.getExecutor(), null) {
3388
                        @Override
3389
                        protected void handleCompleted() {
3390
                            if (isSuccess()) {
3391
                            	wait.setReturnInfo(getData());
3392
                            	if (getData() != expectedCount) {
3393
	        						wait.waitFinished(
3394
	        							new Status(
3395
		        							IStatus.ERROR, 
3396
		        							TestsPlugin.PLUGIN_ID,
3397
		        							String.format(
3398
		        									"Failed getting count for children.  Got %d instead of %d.", 
3399
		        									getData(), 
3400
		        									expectedCount)));
3401
                            	}
3402
                            	else {
3403
                            		wait.waitFinished(getStatus());
3404
                            	}
3405
                            }
3406
                            else {
3407
                        		wait.waitFinished(getStatus());
3408
                            }
3409
                        }
3410
                    });
3411
            }
3412
        });
3413
3414
        wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
3415
        assertTrue(wait.getMessage(), wait.isOK());
3416
3417
        int count = ((Integer)wait.getReturnInfo()).intValue();
3418
3419
		assertTrue(String.format("Expected %d but got %d", expectedCount, count), count == expectedCount);
3420
        
3421
        return count;
3422
    }
3314
}
3423
}
(-)a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/viewmodel/DsfCastToTypeSupport.java (+4 lines)
Lines 25-30 Link Here
25
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent;
25
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent;
26
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
26
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
27
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
27
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
28
import org.eclipse.cdt.dsf.debug.service.IExpressions.IIndexedPartitionDMContext;
28
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
29
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
29
import org.eclipse.cdt.dsf.debug.service.IExpressions2.CastInfo;
30
import org.eclipse.cdt.dsf.debug.service.IExpressions2.CastInfo;
30
import org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext;
31
import org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext;
Lines 90-95 Link Here
90
	    }
91
	    }
91
92
92
		private boolean isValid() {
93
		private boolean isValid() {
94
			if (exprDMC instanceof IIndexedPartitionDMContext)
95
				return false;
96
93
	        TestExpressions2Query query = new TestExpressions2Query();
97
	        TestExpressions2Query query = new TestExpressions2Query();
94
	        dmvmProvider.getSession().getExecutor().execute(query);
98
	        dmvmProvider.getSession().getExecutor().execute(query);
95
99
(-)a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMNode.java (-7 / +54 lines)
Lines 37-42 Link Here
37
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
37
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
38
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
38
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
39
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation;
39
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMLocation;
40
import org.eclipse.cdt.dsf.debug.service.IExpressions.IIndexedPartitionDMContext;
40
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
41
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
41
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
42
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
42
import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension;
43
import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension;
Lines 135-140 Link Here
135
     */    
136
     */    
136
    public static final String PROP_VARIABLE_ADDRESS_CHANGED = ICachingVMProvider.PROP_IS_CHANGED_PREFIX + PROP_VARIABLE_ADDRESS;
137
    public static final String PROP_VARIABLE_ADDRESS_CHANGED = ICachingVMProvider.PROP_IS_CHANGED_PREFIX + PROP_VARIABLE_ADDRESS;
137
138
139
    /**
140
     * 'PROP_VARIABLE_BASIC_TYPE' property value for indexed partitions
141
     */
142
    private static final String INDEXED_PARTITION_TYPE = "indexed_partition_type"; //$NON-NLS-1$
143
    
138
    private final SyncVariableDataAccess fSyncVariableDataAccess;
144
    private final SyncVariableDataAccess fSyncVariableDataAccess;
139
    
145
    
140
    /**
146
    /**
Lines 330-335 Link Here
330
        };
336
        };
331
    };
337
    };
332
    
338
    
339
    public final static  LabelImage PARTITION_LABEL_IMAGE = new LabelImage(CDebugImages.DESC_OBJS_ARRAY_PARTITION) {
340
        { setPropertyNames(new String[] { PROP_VARIABLE_BASIC_TYPE }); }
341
        
342
        @Override
343
        public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
344
            String type = (String)properties.get(PROP_VARIABLE_BASIC_TYPE);
345
            return INDEXED_PARTITION_TYPE.equals(type);
346
        };
347
    };
348
    
333
    protected IElementLabelProvider createLabelProvider() {
349
    protected IElementLabelProvider createLabelProvider() {
334
    	
350
    	
335
    	//
351
    	//
Lines 407-412 Link Here
407
                    new String[] { PROP_NAME }),
423
                    new String[] { PROP_NAME }),
408
                POINTER_LABEL_IMAGE,
424
                POINTER_LABEL_IMAGE,
409
                AGGREGATE_LABEL_IMAGE, 
425
                AGGREGATE_LABEL_IMAGE, 
426
                PARTITION_LABEL_IMAGE,
410
                SIMPLE_LABEL_IMAGE,
427
                SIMPLE_LABEL_IMAGE,
411
                new StaleDataLabelForeground(),
428
                new StaleDataLabelForeground(),
412
                new VariableLabelFont(),
429
                new VariableLabelFont(),
Lines 422-427 Link Here
422
                    new String[] { PROP_ELEMENT_EXPRESSION }),
439
                    new String[] { PROP_ELEMENT_EXPRESSION }),
423
                POINTER_LABEL_IMAGE,
440
                POINTER_LABEL_IMAGE,
424
                AGGREGATE_LABEL_IMAGE, 
441
                AGGREGATE_LABEL_IMAGE, 
442
                PARTITION_LABEL_IMAGE,
425
                SIMPLE_LABEL_IMAGE,
443
                SIMPLE_LABEL_IMAGE,
426
                new StaleDataLabelForeground(),
444
                new StaleDataLabelForeground(),
427
                new VariableLabelFont(),
445
                new VariableLabelFont(),
Lines 770-779 Link Here
770
                                // In case of an error fill in the expression text in the name column and expressions columns.
788
                                // In case of an error fill in the expression text in the name column and expressions columns.
771
                                IExpressionDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressions.IExpressionDMContext.class);
789
                                IExpressionDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressions.IExpressionDMContext.class);
772
                                if (dmc != null && dmc.getExpression() != null) {
790
                                if (dmc != null && dmc.getExpression() != null) {
773
                                    update.setProperty(PROP_NAME, dmc.getExpression());
791
                                	String displayName = getExpressionDisplayName(dmc, dmc.getExpression());
792
                                    update.setProperty(PROP_NAME, displayName);
774
                                    if (expression == null) {
793
                                    if (expression == null) {
775
                                        update.setProperty(PROP_ELEMENT_EXPRESSION, dmc.getExpression());
794
                                        update.setProperty(PROP_ELEMENT_EXPRESSION, displayName);
776
                                    }
795
                                    }
796
                                    if (dmc instanceof IIndexedPartitionDMContext)
797
                                    	update.setProperty(PROP_VARIABLE_BASIC_TYPE, INDEXED_PARTITION_TYPE);
777
                                }
798
                                }
778
                                update.setStatus(getStatus());
799
                                update.setStatus(getStatus());
779
                            }
800
                            }
Lines 814-824 Link Here
814
    @ConfinedToDsfExecutor("getSession().getExecutor()")
835
    @ConfinedToDsfExecutor("getSession().getExecutor()")
815
    protected void fillExpressionDataProperties(IPropertiesUpdate update, IExpressionDMData data) 
836
    protected void fillExpressionDataProperties(IPropertiesUpdate update, IExpressionDMData data) 
816
    {
837
    {
817
        update.setProperty(PROP_NAME, data.getName());
838
        IExpressionDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressions.IExpressionDMContext.class);
839
        String displayName = data.getName();
840
        if (dmc != null) {
841
        	displayName = getExpressionDisplayName(dmc, displayName);
842
        }
843
        update.setProperty(PROP_NAME, displayName);
818
        update.setProperty(PROP_VARIABLE_TYPE_NAME, data.getTypeName());
844
        update.setProperty(PROP_VARIABLE_TYPE_NAME, data.getTypeName());
819
        IExpressionDMData.BasicType type = data.getBasicType();
845
        String typeValue = null;
820
        if (type != null) {
846
        if (dmc instanceof IIndexedPartitionDMContext)
821
            update.setProperty(PROP_VARIABLE_BASIC_TYPE, type.name());
847
        	typeValue = INDEXED_PARTITION_TYPE;
848
        else {
849
            IExpressionDMData.BasicType type = data.getBasicType();
850
            if (type != null)
851
            	typeValue = type.name();
852
        }
853
        if (typeValue != null) {
854
            update.setProperty(PROP_VARIABLE_BASIC_TYPE, typeValue);
822
        }
855
        }
823
        
856
        
824
        //
857
        //
Lines 828-834 Link Here
828
        //
861
        //
829
        IExpression expression = (IExpression)DebugPlugin.getAdapter(update.getElement(), IExpression.class);
862
        IExpression expression = (IExpression)DebugPlugin.getAdapter(update.getElement(), IExpression.class);
830
        if (expression == null) {
863
        if (expression == null) {
831
            update.setProperty(AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION, data.getName());
864
            update.setProperty(AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION, displayName);
832
        }
865
        }
833
    }
866
    }
834
867
Lines 1344-1347 Link Here
1344
            request.done();
1377
            request.done();
1345
        }
1378
        }
1346
    }
1379
    }
1380
1381
    /**
1382
     * Returns the label for the element with the given context.
1383
     */
1384
    protected String getExpressionDisplayName(IExpressionDMContext dmc, String name) {
1385
    	if (dmc instanceof IIndexedPartitionDMContext) {
1386
    		IIndexedPartitionDMContext ipDmc = (IIndexedPartitionDMContext)dmc;
1387
    		name = String.format(
1388
    				"[%d...%d]",  //$NON-NLS-1$
1389
    				ipDmc.getIndex(), 
1390
    				ipDmc.getIndex() + ipDmc.getLength() - 1);
1391
    	}
1392
    	return name;
1393
    }
1347
}
1394
}
(-)a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IExpressions.java (+24 lines)
Lines 44-49 Link Here
44
    }
44
    }
45
45
46
    /**
46
    /**
47
     * To avoid SWT performance issues large arrays are divided into partitions. 
48
     * This interface represents the context of such a partition.
49
     * 
50
     * @since 2.3
51
     */
52
    public interface IIndexedPartitionDMContext extends IExpressionDMContext {
53
54
		/**
55
		 * Returns the expression string of the parent array.
56
		 */
57
		public String getParentExpression();
58
59
		/**
60
		 * Returns the index of the partition's first element in the parent array. 
61
		 */
62
		public int getIndex();
63
		
64
		/**
65
		 * Returns the number of array's elements in the partition.
66
		 */
67
		public int getLength();
68
	}
69
70
    /**
47
     * The address and size of an expression.
71
     * The address and size of an expression.
48
     */
72
     */
49
    public interface IExpressionDMAddress {
73
    public interface IExpressionDMAddress {

Return to bug 365541