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 (-64 / +338 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).getIndex() == getIndex() &&
477
                    ((IndexedPartitionDMC) other).getLength() == getLength();                
478
        }
479
480
        @Override
481
        public int hashCode() {
482
            return super.baseHashCode() + 17*getIndex() + 31*getLength();
483
        }
484
485
        @Override
486
        public String toString() {
487
            return String.format( "%s[%d-%d]", baseToString(), Integer.valueOf( getIndex() ), Integer.valueOf( getIndex() + getLength() ) ); //$NON-NLS-1$
488
        }
489
490
        private static ExpressionInfo createExpressionInfo(ExpressionInfo parentInfo, int index, int length) {
491
        	String expression = String.format(
492
        			"*((%s)+%d)@%d",  //$NON-NLS-1$
493
        			parentInfo.getFullExpr(), 
494
        			Integer.valueOf(index), 
495
        			Integer.valueOf(length));
496
        	return new ExpressionInfo(expression, expression);
414
        }
497
        }
415
    }
498
    }
416
    
499
    
Lines 1064-1096 Link Here
1064
	 *            The data request monitor that will contain the requested data
1147
	 *            The data request monitor that will contain the requested data
1065
	 */
1148
	 */
1066
	@Override
1149
	@Override
1067
	public void getSubExpressions(final IExpressionDMContext dmc,
1150
	public void getSubExpressions(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMContext[]> rm) {
1068
			final DataRequestMonitor<IExpressionDMContext[]> rm) 
1151
		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
	}
1152
	}
1095
1153
1096
	/**
1154
	/**
Lines 1112-1148 Link Here
1112
	public void getSubExpressions(final IExpressionDMContext exprCtx, final int startIndex,
1170
	public void getSubExpressions(final IExpressionDMContext exprCtx, final int startIndex,
1113
			final int length, final DataRequestMonitor<IExpressionDMContext[]> rm) {
1171
			final int length, final DataRequestMonitor<IExpressionDMContext[]> rm) {
1114
1172
1115
		if (startIndex < 0 || length < 0) {
1173
		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$
1174
			getIndexedPartitionChildren((IndexedPartitionDMC)exprCtx, startIndex, length, rm);
1117
			rm.done();
1118
			return;
1119
		}
1175
		}
1120
		
1176
		else if (exprCtx instanceof MIExpressionDMC) {
1121
		if (exprCtx instanceof MIExpressionDMC) {
1177
			getRealSubExpressionCount(
1122
			fExpressionCache.execute(
1178
				exprCtx, 
1123
					new ExprMetaGetChildren(exprCtx, startIndex + length),				
1179
				IMIExpressions.CHILD_COUNT_LIMIT_UNSPECIFIED, 
1124
					new DataRequestMonitor<ExprMetaGetChildrenInfo>(getExecutor(), rm) {
1180
				new DataRequestMonitor<Integer>(getExecutor(), rm) {
1125
						@Override
1181
					/* (non-Javadoc)
1126
						protected void handleSuccess() {
1182
					 * @see org.eclipse.cdt.dsf.concurrent.RequestMonitor#handleSuccess()
1127
							ExpressionInfo[] childrenExpr = getData().getChildrenExpressions();
1183
					 */
1128
1184
					@Override
1129
							if (startIndex >= childrenExpr.length) {
1185
					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$
1186
						final int realNumChildren = getData().intValue();
1131
								rm.done();
1187
						if (realNumChildren <= getArrayPartitionLength()) {
1132
								return;
1188
							getRealSubExpressions(exprCtx, startIndex, length, rm);
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();
1144
						}
1189
						}
1145
					});
1190
						else {
1191
							getExpressionData(
1192
									exprCtx, 
1193
									new DataRequestMonitor<IExpressionDMData>(ImmediateExecutor.getInstance(), rm) {
1194
1195
										@Override
1196
										protected void handleSuccess() {
1197
											if (IExpressionDMData.BasicType.array.equals(getData().getBasicType())) {
1198
												rm.setData(getTopLevelIndexedPartitions((MIExpressionDMC)exprCtx, realNumChildren, startIndex, length ));
1199
												rm.done();
1200
											}
1201
											else {
1202
												getRealSubExpressions(exprCtx, startIndex, length, rm);
1203
											}
1204
										}
1205
									});
1206
						}
1207
					}
1208
				});
1146
		} else if (exprCtx instanceof InvalidContextExpressionDMC) {
1209
		} 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$
1210
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1148
			rm.done();
1211
			rm.done();
Lines 1183-1201 Link Here
1183
	 * @since 4.0
1246
	 * @since 4.0
1184
	 */
1247
	 */
1185
	@Override
1248
	@Override
1186
	public void getSubExpressionCount(IExpressionDMContext dmc,
1249
	public void getSubExpressionCount(final IExpressionDMContext dmc,
1187
			final int numChildLimit, final DataRequestMonitor<Integer> rm) {
1250
			final int numChildLimit, final DataRequestMonitor<Integer> rm) {
1188
1251
1189
		if (dmc instanceof MIExpressionDMC) {
1252
		if (dmc instanceof MIExpressionDMC) {
1190
			fExpressionCache.execute(
1253
			if (dmc instanceof IndexedPartitionDMC) {
1191
					new ExprMetaGetChildCount(dmc, numChildLimit),				
1254
				int length = ((IndexedPartitionDMC)dmc).getLength();
1192
					new DataRequestMonitor<ExprMetaGetChildCountInfo>(getExecutor(), rm) {
1255
				rm.setData(computeNumberOfChildren(length));
1256
				rm.done();
1257
			}
1258
			else {
1259
				getRealSubExpressionCount( 
1260
					dmc, 
1261
					numChildLimit, 
1262
					new DataRequestMonitor<Integer>(getExecutor(), rm) {
1263
1193
						@Override
1264
						@Override
1194
						protected void handleSuccess() {
1265
						protected void handleSuccess() {
1195
							rm.setData(getData().getChildNum());
1266
							final int realNum = getData().intValue();
1196
							rm.done();
1267
							if (realNum < getArrayPartitionLength()) {
1197
						}
1268
								rm.setData(Integer.valueOf(realNum));
1269
								rm.done();
1270
							}
1271
							else {
1272
								getExpressionData(
1273
									dmc, 
1274
									new DataRequestMonitor<IExpressionDMData>(ImmediateExecutor.getInstance(), rm) {
1275
1276
										@Override
1277
										protected void handleSuccess() {
1278
											if (IExpressionDMData.BasicType.array.equals(getData().getBasicType())) {
1279
												rm.setData(computeNumberOfChildren(realNum));
1280
											}
1281
											else {
1282
												rm.setData(Integer.valueOf(realNum));
1283
											}
1284
											rm.done();
1285
										}
1286
									});
1287
							}
1288
						}				
1198
					});
1289
					});
1290
			}
1199
		} else if (dmc instanceof InvalidContextExpressionDMC) {
1291
		} 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$
1292
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1201
			rm.done();
1293
			rm.done();
Lines 1442-1445 Link Here
1442
            }
1534
            }
1443
        }); 
1535
        }); 
1444
    }
1536
    }
1537
1538
	private IndexedPartitionDMC[] getTopLevelIndexedPartitions(
1539
			MIExpressionDMC exprCtx, 
1540
			int realNumChildren, 
1541
			int startIndex, 
1542
			int length) {
1543
1544
		int numChildren = computeNumberOfChildren(realNumChildren);
1545
		if (startIndex >= numChildren)
1546
			return new IndexedPartitionDMC[0];
1547
		int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1548
		int length1 = (length < 0) ? numChildren - startIndex1 : Math.min(length, numChildren - startIndex1);
1549
1550
		IndexedPartitionDMC[] children = new IndexedPartitionDMC[numChildren];
1551
		int index = 0;
1552
		for(int i = 0; i < children.length; ++i) {
1553
			int partLength = computePartitionLength(realNumChildren, i);
1554
			children[i] = createIndexedPartition(
1555
				exprCtx.getParents()[0], 
1556
				exprCtx.getExpressionInfo(), 
1557
				index, 
1558
				partLength);
1559
			index += partLength;
1560
		}
1561
		return Arrays.copyOfRange(children, startIndex1, startIndex1 + length1 );
1562
	}
1563
1564
	private void getIndexedPartitionChildren(
1565
			final IndexedPartitionDMC partDmc, 
1566
			final int startIndex,
1567
			final int length, 
1568
			final DataRequestMonitor<IExpressionDMContext[]> rm) {
1569
		
1570
		final int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1571
		final int length1 = (length < 0) ? Integer.MAX_VALUE : length;
1572
1573
		final int partStartIndex = partDmc.getIndex();
1574
		final int partLength = partDmc.getLength();
1575
		if (partLength > getArrayPartitionLength()) {
1576
			// create subpartitions
1577
			int numChildren = computeNumberOfChildren(partLength);
1578
			
1579
			if (startIndex1 >= numChildren) {
1580
				rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
1581
				rm.done();
1582
				return;
1583
			}
1584
1585
			int numPart = Math.min(numChildren, length1);
1586
			IndexedPartitionDMC[] children = new IndexedPartitionDMC[numPart];
1587
			int index = partStartIndex;
1588
			for (int i = 0; i < startIndex1; ++i)
1589
				index += computePartitionLength(partLength, i);
1590
			for (int i = 0; i < children.length; ++i) {
1591
				int childPartLength = computePartitionLength(partLength, i + startIndex1);
1592
				children[i] = createIndexedPartition(
1593
					partDmc, 
1594
					partDmc.getParentInfo(), 
1595
					index, 
1596
					childPartLength);
1597
				index += childPartLength;
1598
			}
1599
			rm.setData(children);
1600
			rm.done();
1601
		}
1602
		else {
1603
			// this is the last partition level, create "real" children
1604
			getRealSubExpressions(createExpression(partDmc.getParents()[0], partDmc.getParentInfo()), partDmc.getIndex() + startIndex, length, rm);
1605
		}
1606
	}
1607
1608
	void getRealSubExpressions(
1609
			final IExpressionDMContext exprCtx, 
1610
			int startIndex,
1611
			int length, 
1612
			final DataRequestMonitor<IExpressionDMContext[]> rm) {
1613
		
1614
		ExprMetaGetChildren getChildren = (startIndex < 0 || length < 0) ? 
1615
				new ExprMetaGetChildren(exprCtx) : new ExprMetaGetChildren(exprCtx, startIndex + length);
1616
		final int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1617
		final int length1 = (length < 0) ? Integer.MAX_VALUE : length;
1618
		fExpressionCache.execute(
1619
				getChildren,				
1620
				new DataRequestMonitor<ExprMetaGetChildrenInfo>(getExecutor(), rm) {
1621
					@Override
1622
					protected void handleSuccess() {
1623
						ExpressionInfo[] childrenExpr = getData().getChildrenExpressions();
1624
1625
						if (startIndex1 >= childrenExpr.length) {
1626
							rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
1627
							rm.done();
1628
							return;
1629
						}
1630
1631
						int numChildren = childrenExpr.length - startIndex1;
1632
						numChildren = Math.min(length1, numChildren);
1633
						IExpressionDMContext[] childrenArray = new IExpressionDMContext[numChildren];
1634
						for (int i=0; i < numChildren; i++) {
1635
							childrenArray[i] = createExpression(exprCtx.getParents()[0], childrenExpr[startIndex1 + i]);
1636
						}
1637
						rm.setData(childrenArray);
1638
						rm.done();
1639
					}
1640
				});
1641
	}
1642
1643
	/**
1644
	 * Returns the number of "real" children if it is less or equal to the partition size, 
1645
	 * otherwise returns the number of partitions. 
1646
	 */
1647
	private int computeNumberOfChildren(int realNumberOfChildren) {
1648
		int childNum = realNumberOfChildren;
1649
		int partLength = getArrayPartitionLength();
1650
		while (childNum > partLength) {
1651
			childNum /= partLength;
1652
		}
1653
		if (childNum*partLength < realNumberOfChildren)
1654
			++childNum;
1655
		return childNum;
1656
	}
1657
1658
	private int computePartitionLength(int realNumberOfChildren, int index) {
1659
		int childNum = realNumberOfChildren;
1660
		int depth = 0;
1661
		int partLength = getArrayPartitionLength();
1662
		int length = partLength;
1663
		while (childNum > partLength) {
1664
			childNum /= partLength;
1665
			if (depth > 0)
1666
				length *= partLength;
1667
			++depth;
1668
		}
1669
		int diff = realNumberOfChildren - length*index;
1670
		return ( diff > length ) ? length : diff ;
1671
	}
1672
1673
	private IndexedPartitionDMC createIndexedPartition(IDMContext ctx, ExpressionInfo info, int index, int length) {
1674
	    IFrameDMContext frameDmc = DMContexts.getAncestorOfType(ctx, IFrameDMContext.class);
1675
	    if (frameDmc != null) {
1676
	        return new IndexedPartitionDMC(getSession().getId(), info, frameDmc, index, length);
1677
	    } 
1678
	    
1679
	    IMIExecutionDMContext execCtx = DMContexts.getAncestorOfType(ctx, IMIExecutionDMContext.class);
1680
	    if (execCtx != null) {
1681
	    	// If we have a thread context but not a frame context, we give the user
1682
	    	// the expression as per the top-most frame of the specified thread.
1683
	    	// To do this, we create our own frame context.
1684
	    	MIStack stackService = getServicesTracker().getService(MIStack.class);
1685
	    	if (stackService != null) {
1686
	    		frameDmc = stackService.createFrameDMContext(execCtx, 0);
1687
	            return new IndexedPartitionDMC(getSession().getId(), info, frameDmc, index, length);
1688
	    	}
1689
        } 
1690
1691
        return new IndexedPartitionDMC(getSession().getId(), info, ctx, index, length);
1692
	}
1693
1694
	private void getRealSubExpressionCount(IExpressionDMContext dmc, int numChildLimit, final DataRequestMonitor<Integer> rm) {
1695
		if (dmc instanceof MIExpressionDMC) {
1696
			fExpressionCache.execute(
1697
					new ExprMetaGetChildCount(dmc, numChildLimit),				
1698
					new DataRequestMonitor<ExprMetaGetChildCountInfo>(getExecutor(), rm) {
1699
						@Override
1700
						protected void handleSuccess() {
1701
							rm.setData(getData().getChildNum());
1702
							rm.done();
1703
						}
1704
					});
1705
		} else if (dmc instanceof InvalidContextExpressionDMC) {
1706
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1707
			rm.done();
1708
		} else {
1709
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid expression context.", null)); //$NON-NLS-1$
1710
			rm.done();
1711
		}
1712
	}
1713
1714
	private int getArrayPartitionLength() {
1715
		// Replace this in case we or the platform decide to add a user preference.
1716
		// See org.eclipse.debug.internal.ui.model.elements.VariableContentProvider.
1717
		return PARTITION_LENGTH;
1718
	}
1445
}
1719
}
(-)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/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 / +55 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, getData());
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 && dmc.getExpression() != null) {
841
        	displayName = getExpressionDisplayName(dmc, data);
842
            update.setProperty(PROP_NAME, displayName);
843
        }
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, IExpressionDMData data) {
1385
    	String name = data.getName();
1386
    	if (dmc instanceof IIndexedPartitionDMContext) {
1387
    		IIndexedPartitionDMContext ipDmc = (IIndexedPartitionDMContext)dmc;
1388
    		name = String.format(
1389
    				"[%d...%d]",  //$NON-NLS-1$
1390
    				ipDmc.getIndex(), 
1391
    				ipDmc.getIndex() + ipDmc.getLength() - 1);
1392
    	}
1393
    	return name;
1394
    }
1347
}
1395
}
(-)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