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/IMIExpressions.java (-2 / +2 lines)
Lines 12-18 Link Here
12
12
13
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
13
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
14
import org.eclipse.cdt.dsf.debug.service.IExpressions;
14
import org.eclipse.cdt.dsf.debug.service.IExpressions;
15
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
15
import org.eclipse.cdt.dsf.debug.service.IExpressions4;
16
16
17
/**
17
/**
18
 * An extension of {@link IExpressions} which became necessary because the MI
18
 * An extension of {@link IExpressions} which became necessary because the MI
Lines 32-38 Link Here
32
 * 
32
 * 
33
 * @since 4.0
33
 * @since 4.0
34
 */
34
 */
35
public interface IMIExpressions extends IExpressions3 {
35
public interface IMIExpressions extends IExpressions4 {
36
36
37
	/**
37
	/**
38
	 * A special constant that can be used in methods that expect a child count
38
	 * A special constant that can be used in methods that expect a child count
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java (-62 / +294 lines)
Lines 13-18 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;
Lines 70-75 Link Here
70
 * @since 2.0
71
 * @since 2.0
71
 */
72
 */
72
public class MIExpressions extends AbstractDsfService implements IMIExpressions, ICachingService {
73
public class MIExpressions extends AbstractDsfService implements IMIExpressions, ICachingService {
74
75
	private static final int PARTITION_LENGTH = 100;
73
76
74
    /**
77
    /**
75
     * A format that gives more details about an expression and supports pretty-printing
78
     * A format that gives more details about an expression and supports pretty-printing
Lines 314-320 Link Here
314
        /**
317
        /**
315
		 * @since 4.0
318
		 * @since 4.0
316
		 */
319
		 */
317
        private MIExpressionDMC(String sessionId, ExpressionInfo info, IDMContext parent) {
320
        MIExpressionDMC(String sessionId, ExpressionInfo info, IDMContext parent) {
318
            super(sessionId, new IDMContext[] { parent });
321
            super(sessionId, new IDMContext[] { parent });
319
            exprInfo = info;
322
            exprInfo = info;
320
        }
323
        }
Lines 381-387 Link Here
381
			this.exprInfo = info;
384
			this.exprInfo = info;
382
		}
385
		}
383
    }
386
    }
384
    
387
385
    protected static class InvalidContextExpressionDMC extends AbstractDMContext 
388
    protected static class InvalidContextExpressionDMC extends AbstractDMContext 
386
        implements IExpressionDMContext
389
        implements IExpressionDMContext
387
    {
390
    {
Lines 411-416 Link Here
411
    	@Override
414
    	@Override
412
        public String getExpression() {
415
        public String getExpression() {
413
            return expression;
416
            return expression;
417
        }
418
    }
419
420
    /**
421
	 * @since 4.1
422
	 */
423
    protected static class IndexedPartitionDMC extends MIExpressionDMC implements IIndexedPartitionDMContext {
424
425
    	final private ExpressionInfo fParentInfo;
426
		private final int fIndex;
427
    	private final int fLength;
428
    	
429
		public IndexedPartitionDMC(
430
				String sessionId, 
431
				ExpressionInfo parentInfo, 
432
				IFrameDMContext frameCtx, 
433
				int index, 
434
				int length) {
435
			this(sessionId, parentInfo, (IDMContext)frameCtx, index, length);
436
		}
437
438
    	private IndexedPartitionDMC(
439
    			String sessionId, 
440
    			ExpressionInfo parentInfo, 
441
    			IDMContext parent, 
442
    			int index, 
443
    			int length) {
444
			super(sessionId, createExpressionInfo(parentInfo, index, length), parent);
445
			fIndex = index;
446
			fLength = length;
447
			fParentInfo = parentInfo;
448
		}
449
450
    	public ExpressionInfo getParentInfo() {
451
    		return fParentInfo;
452
    	}
453
454
		/* (non-Javadoc)
455
		 * @see org.eclipse.cdt.dsf.debug.service.IExpressions4.IIndexedPartitionDMContext#getParentExpression()
456
		 */
457
		@Override
458
		public String getParentExpression() {
459
			return getParentInfo().getFullExpr();
460
		}
461
462
		@Override
463
		public int getIndex() {
464
			return fIndex;
465
		}
466
467
		@Override
468
		public int getLength() {
469
			return fLength;
470
		}
471
472
        @Override
473
        public boolean equals(Object other) {
474
            return super.baseEquals(other) && 
475
                    ((IndexedPartitionDMC) other).getIndex() == getIndex() &&
476
                    ((IndexedPartitionDMC) other).getLength() == getLength();                
477
        }
478
479
        @Override
480
        public int hashCode() {
481
            return super.baseHashCode() + 17*getIndex() + 31*getLength();
482
        }
483
484
        @Override
485
        public String toString() {
486
            return String.format( "%s[%d-%d]", baseToString(), Integer.valueOf( getIndex() ), Integer.valueOf( getIndex() + getLength() ) ); //$NON-NLS-1$
487
        }
488
489
        private static ExpressionInfo createExpressionInfo(ExpressionInfo parentInfo, int index, int length) {
490
        	String expression = String.format(
491
        			"*(%s+%d)@%d",  //$NON-NLS-1$
492
        			parentInfo.getRelExpr(), 
493
        			Integer.valueOf(index), 
494
        			Integer.valueOf(length));
495
        	return new ExpressionInfo(expression, expression);
414
        }
496
        }
415
    }
497
    }
416
    
498
    
Lines 1064-1096 Link Here
1064
	 *            The data request monitor that will contain the requested data
1146
	 *            The data request monitor that will contain the requested data
1065
	 */
1147
	 */
1066
	@Override
1148
	@Override
1067
	public void getSubExpressions(final IExpressionDMContext dmc,
1149
	public void getSubExpressions(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMContext[]> rm) {
1068
			final DataRequestMonitor<IExpressionDMContext[]> rm) 
1150
		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
	}
1151
	}
1095
1152
1096
	/**
1153
	/**
Lines 1112-1148 Link Here
1112
	public void getSubExpressions(final IExpressionDMContext exprCtx, final int startIndex,
1169
	public void getSubExpressions(final IExpressionDMContext exprCtx, final int startIndex,
1113
			final int length, final DataRequestMonitor<IExpressionDMContext[]> rm) {
1170
			final int length, final DataRequestMonitor<IExpressionDMContext[]> rm) {
1114
1171
1115
		if (startIndex < 0 || length < 0) {
1172
		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$
1173
			getIndexedPartitionChildren((IndexedPartitionDMC)exprCtx, startIndex, length, rm);
1117
			rm.done();
1118
			return;
1119
		}
1174
		}
1120
		
1175
		else if (exprCtx instanceof MIExpressionDMC) {
1121
		if (exprCtx instanceof MIExpressionDMC) {
1176
			getRealSubExpressionCount(
1122
			fExpressionCache.execute(
1177
				exprCtx, 
1123
					new ExprMetaGetChildren(exprCtx, startIndex + length),				
1178
				IMIExpressions.CHILD_COUNT_LIMIT_UNSPECIFIED, 
1124
					new DataRequestMonitor<ExprMetaGetChildrenInfo>(getExecutor(), rm) {
1179
				new DataRequestMonitor<Integer>(getExecutor(), rm) {
1125
						@Override
1180
					/* (non-Javadoc)
1126
						protected void handleSuccess() {
1181
					 * @see org.eclipse.cdt.dsf.concurrent.RequestMonitor#handleSuccess()
1127
							ExpressionInfo[] childrenExpr = getData().getChildrenExpressions();
1182
					 */
1128
1183
					@Override
1129
							if (startIndex >= childrenExpr.length) {
1184
					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$
1185
						int realNumChildren = getData().intValue();
1131
								rm.done();
1186
						if (realNumChildren <= PARTITION_LENGTH) {
1132
								return;
1187
							getRealSubExpressions(exprCtx, startIndex, length, rm);
1133
							}
1188
						}
1134
1189
						else {
1135
							int numChildren = childrenExpr.length - startIndex;
1190
							rm.setData(getTopLevelIndexedPartitions((MIExpressionDMC)exprCtx, realNumChildren, startIndex, length ));
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();
1191
							rm.done();
1144
						}
1192
						}
1145
					});
1193
					}
1194
				});
1146
		} else if (exprCtx instanceof InvalidContextExpressionDMC) {
1195
		} 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$
1196
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1148
			rm.done();
1197
			rm.done();
Lines 1187-1201 Link Here
1187
			final int numChildLimit, final DataRequestMonitor<Integer> rm) {
1236
			final int numChildLimit, final DataRequestMonitor<Integer> rm) {
1188
1237
1189
		if (dmc instanceof MIExpressionDMC) {
1238
		if (dmc instanceof MIExpressionDMC) {
1190
			fExpressionCache.execute(
1239
			if (dmc instanceof IndexedPartitionDMC) {
1191
					new ExprMetaGetChildCount(dmc, numChildLimit),				
1240
				int length = ((IndexedPartitionDMC)dmc).getLength();
1192
					new DataRequestMonitor<ExprMetaGetChildCountInfo>(getExecutor(), rm) {
1241
				rm.setData(computeNumberOfChildren(length));
1242
				rm.done();
1243
			}
1244
			else {
1245
				getRealSubExpressionCount( 
1246
					dmc, 
1247
					numChildLimit, 
1248
					new DataRequestMonitor<Integer>(getExecutor(), rm) {
1249
1193
						@Override
1250
						@Override
1194
						protected void handleSuccess() {
1251
						protected void handleSuccess() {
1195
							rm.setData(getData().getChildNum());
1252
							rm.setData(computeNumberOfChildren(getData().intValue()));
1196
							rm.done();
1253
							rm.done();
1197
						}
1254
						}				
1198
					});
1255
					});
1256
			}
1199
		} else if (dmc instanceof InvalidContextExpressionDMC) {
1257
		} 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$
1258
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1201
			rm.done();
1259
			rm.done();
Lines 1442-1445 Link Here
1442
            }
1500
            }
1443
        }); 
1501
        }); 
1444
    }
1502
    }
1503
1504
	private IndexedPartitionDMC[] getTopLevelIndexedPartitions(
1505
			MIExpressionDMC exprCtx, 
1506
			int realNumChildren, 
1507
			int startIndex, 
1508
			int length) {
1509
1510
		int numChildren = computeNumberOfChildren(realNumChildren);
1511
		if (startIndex >= numChildren)
1512
			return new IndexedPartitionDMC[0];
1513
		int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1514
		int length1 = (length < 0) ? numChildren - startIndex1 : Math.min(length, numChildren - startIndex1);
1515
1516
		IndexedPartitionDMC[] children = new IndexedPartitionDMC[numChildren];
1517
		int index = 0;
1518
		for(int i = 0; i < children.length; ++i) {
1519
			int partLength = computePartitionLength(realNumChildren, i);
1520
			children[i] = createIndexedPartition(
1521
				exprCtx.getParents()[0], 
1522
				exprCtx.getExpressionInfo(), 
1523
				index, 
1524
				partLength);
1525
			index += partLength;
1526
		}
1527
		return Arrays.copyOfRange(children, startIndex1, startIndex1 + length1 );
1528
	}
1529
1530
	private void getIndexedPartitionChildren(
1531
			final IndexedPartitionDMC partDmc, 
1532
			final int startIndex,
1533
			final int length, 
1534
			final DataRequestMonitor<IExpressionDMContext[]> rm) {
1535
		
1536
		final int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1537
		final int length1 = (length < 0) ? Integer.MAX_VALUE : length;
1538
1539
		final int partStartIndex = partDmc.getIndex();
1540
		final int partLength = partDmc.getLength();
1541
		if (partLength > PARTITION_LENGTH) {
1542
			// create subpartitions
1543
			int numChildren = computeNumberOfChildren(partLength);
1544
			
1545
			if (startIndex1 >= numChildren) {
1546
				rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
1547
				rm.done();
1548
				return;
1549
			}
1550
1551
			int numPart = Math.min(numChildren, length1);
1552
			IndexedPartitionDMC[] children = new IndexedPartitionDMC[numPart];
1553
			int index = partStartIndex;
1554
			for (int i = 0; i < startIndex1; ++i)
1555
				index += computePartitionLength(partLength, i);
1556
			for (int i = 0; i < children.length; ++i) {
1557
				int childPartLength = computePartitionLength(partLength, i + startIndex1);
1558
				children[i] = createIndexedPartition(
1559
					partDmc, 
1560
					partDmc.getParentInfo(), 
1561
					index, 
1562
					childPartLength);
1563
				index += childPartLength;
1564
			}
1565
			rm.setData(children);
1566
			rm.done();
1567
		}
1568
		else {
1569
			// this is the last partition level, create "real" children
1570
			getRealSubExpressions(createExpression(partDmc.getParents()[0], partDmc.getParentInfo()), partDmc.getIndex() + startIndex, length, rm);
1571
		}
1572
	}
1573
1574
	void getRealSubExpressions(
1575
			final IExpressionDMContext exprCtx, 
1576
			int startIndex,
1577
			int length, 
1578
			final DataRequestMonitor<IExpressionDMContext[]> rm) {
1579
		
1580
		ExprMetaGetChildren getChildren = (startIndex < 0 || length < 0) ? 
1581
				new ExprMetaGetChildren(exprCtx) : new ExprMetaGetChildren(exprCtx, startIndex + length);
1582
		final int startIndex1 = (startIndex < 0) ? 0 : startIndex;
1583
		final int length1 = (length < 0) ? Integer.MAX_VALUE : length;
1584
		fExpressionCache.execute(
1585
				getChildren,				
1586
				new DataRequestMonitor<ExprMetaGetChildrenInfo>(getExecutor(), rm) {
1587
					@Override
1588
					protected void handleSuccess() {
1589
						ExpressionInfo[] childrenExpr = getData().getChildrenExpressions();
1590
1591
						if (startIndex1 >= childrenExpr.length) {
1592
							rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, "Invalid range for evaluating sub expressions.", null)); //$NON-NLS-1$
1593
							rm.done();
1594
							return;
1595
						}
1596
1597
						int numChildren = childrenExpr.length - startIndex1;
1598
						numChildren = Math.min(length1, numChildren);
1599
						IExpressionDMContext[] childrenArray = new IExpressionDMContext[numChildren];
1600
						for (int i=0; i < numChildren; i++) {
1601
							childrenArray[i] = createExpression(exprCtx.getParents()[0], childrenExpr[startIndex1 + i]);
1602
						}
1603
						rm.setData(childrenArray);
1604
						rm.done();
1605
					}
1606
				});
1607
	}
1608
1609
	/**
1610
	 * Returns the number of "real" children if it is less or equal to the partition size, 
1611
	 * otherwise returns the number of partitions. 
1612
	 */
1613
	private int computeNumberOfChildren(int realNumberOfChildren) {
1614
		int childNum = realNumberOfChildren;
1615
		int extra = (childNum > PARTITION_LENGTH && childNum % PARTITION_LENGTH > 0) ? 1 : 0;
1616
		while (childNum > PARTITION_LENGTH) {
1617
			childNum /= PARTITION_LENGTH;
1618
		}
1619
		childNum += extra;
1620
		return childNum;
1621
	}
1622
1623
	private int computePartitionLength(int realNumberOfChildren, int index) {
1624
		int childNum = realNumberOfChildren;
1625
		int depth = 0;
1626
		int length = PARTITION_LENGTH;
1627
		while (childNum > PARTITION_LENGTH) {
1628
			childNum /= PARTITION_LENGTH;
1629
			if (depth > 0)
1630
				length *= PARTITION_LENGTH;
1631
			++depth;
1632
		}
1633
		int diff = realNumberOfChildren - length*index;
1634
		return ( diff > length ) ? length : diff ;
1635
	}
1636
1637
	private IndexedPartitionDMC createIndexedPartition(IDMContext ctx, ExpressionInfo info, int index, int length) {
1638
	    IFrameDMContext frameDmc = DMContexts.getAncestorOfType(ctx, IFrameDMContext.class);
1639
	    if (frameDmc != null) {
1640
	        return new IndexedPartitionDMC(getSession().getId(), info, frameDmc, index, length);
1641
	    } 
1642
	    
1643
	    IMIExecutionDMContext execCtx = DMContexts.getAncestorOfType(ctx, IMIExecutionDMContext.class);
1644
	    if (execCtx != null) {
1645
	    	// If we have a thread context but not a frame context, we give the user
1646
	    	// the expression as per the top-most frame of the specified thread.
1647
	    	// To do this, we create our own frame context.
1648
	    	MIStack stackService = getServicesTracker().getService(MIStack.class);
1649
	    	if (stackService != null) {
1650
	    		frameDmc = stackService.createFrameDMContext(execCtx, 0);
1651
	            return new IndexedPartitionDMC(getSession().getId(), info, frameDmc, index, length);
1652
	    	}
1653
        } 
1654
1655
        return new IndexedPartitionDMC(getSession().getId(), info, ctx, index, length);
1656
	}
1657
1658
	private void getRealSubExpressionCount(IExpressionDMContext dmc, int numChildLimit, final DataRequestMonitor<Integer> rm) {
1659
		if (dmc instanceof MIExpressionDMC) {
1660
			fExpressionCache.execute(
1661
					new ExprMetaGetChildCount(dmc, numChildLimit),				
1662
					new DataRequestMonitor<ExprMetaGetChildCountInfo>(getExecutor(), rm) {
1663
						@Override
1664
						protected void handleSuccess() {
1665
							rm.setData(getData().getChildNum());
1666
							rm.done();
1667
						}
1668
					});
1669
		} else if (dmc instanceof InvalidContextExpressionDMC) {
1670
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context for evaluating expressions.", null)); //$NON-NLS-1$
1671
			rm.done();
1672
		} else {
1673
			rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid expression context.", null)); //$NON-NLS-1$
1674
			rm.done();
1675
		}
1676
	}
1445
}
1677
}
(-)a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java (+4 lines)
Lines 32-37 Link Here
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.IExpressions2.ICastedExpressionDMContext;
34
import org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext;
35
import org.eclipse.cdt.dsf.debug.service.IExpressions4.IIndexedPartitionDMContext;
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;
37
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
38
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
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 28-33 Link Here
28
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
28
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
29
import org.eclipse.cdt.dsf.debug.service.IExpressions2.CastInfo;
29
import org.eclipse.cdt.dsf.debug.service.IExpressions2.CastInfo;
30
import org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext;
30
import org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext;
31
import org.eclipse.cdt.dsf.debug.service.IExpressions4.IIndexedPartitionDMContext;
31
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.MessagesForVariablesVM;
32
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.MessagesForVariablesVM;
32
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess;
33
import org.eclipse.cdt.dsf.debug.ui.viewmodel.variable.SyncVariableDataAccess;
33
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
34
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
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 / +53 lines)
Lines 40-45 Link Here
40
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
40
import org.eclipse.cdt.dsf.debug.service.IExpressions2;
41
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
41
import org.eclipse.cdt.dsf.debug.service.IExpressions3;
42
import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension;
42
import org.eclipse.cdt.dsf.debug.service.IExpressions3.IExpressionDMDataExtension;
43
import org.eclipse.cdt.dsf.debug.service.IExpressions4.IIndexedPartitionDMContext;
43
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
44
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
44
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
45
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
45
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
46
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
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);
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);
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
    String getExpressionDisplayName(IExpressionDMContext dmc) {
1382
    	String name = dmc.getExpression();
1383
    	if (dmc instanceof IIndexedPartitionDMContext) {
1384
    		IIndexedPartitionDMContext ipDmc = (IIndexedPartitionDMContext)dmc;
1385
    		name = String.format(
1386
    				"[%d...%d]",  //$NON-NLS-1$
1387
    				ipDmc.getIndex(), 
1388
    				ipDmc.getIndex() + 
1389
    				ipDmc.getLength() - 1);
1390
    	}
1391
    	return name;
1392
    }
1347
}
1393
}
(-)a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IExpressions4.java (+27 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2012 Mentor Graphics and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 * Mentor Graphics - Initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.cdt.dsf.debug.service;
13
14
/**
15
 * @since 2.3
16
 */
17
public interface IExpressions4 extends IExpressions3 {
18
19
	public interface IIndexedPartitionDMContext extends IExpressionDMContext {
20
21
		public String getParentExpression();
22
23
		public int getIndex();
24
		
25
		public int getLength();
26
	}
27
}

Return to bug 365541