|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2008 Monta Vista and others. |
2 |
* Copyright (c) 2010 Monta Vista and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 697-703
Link Here
|
| 697 |
} |
697 |
} |
| 698 |
|
698 |
|
| 699 |
if (childVar == null) { |
699 |
if (childVar == null) { |
| 700 |
childVar = new MIVariableObject(childId, MIVariableObject.this); |
700 |
childVar = createVariableObject(childId, MIVariableObject.this); |
| 701 |
childVar.setGdbName(child.getVarName()); |
701 |
childVar.setGdbName(child.getVarName()); |
| 702 |
childVar.setExpressionData( |
702 |
childVar.setExpressionData( |
| 703 |
childFullExpression, |
703 |
childFullExpression, |
|
Lines 914-920
Link Here
|
| 914 |
} |
914 |
} |
| 915 |
} |
915 |
} |
| 916 |
|
916 |
|
| 917 |
private class MIRootVariableObject extends MIVariableObject { |
917 |
/** |
|
|
918 |
* Method to allow to override the MIVariableObject creation |
| 919 |
* |
| 920 |
* @since 2.1 |
| 921 |
*/ |
| 922 |
protected MIVariableObject createVariableObject(VariableObjectId id, MIVariableObject parentObj) { |
| 923 |
return new MIVariableObject(id, parentObj); |
| 924 |
} |
| 925 |
|
| 926 |
/** |
| 927 |
* @since 2.1 |
| 928 |
*/ |
| 929 |
public class MIRootVariableObject extends MIVariableObject { |
| 918 |
|
930 |
|
| 919 |
// Only root variables go through the GDB creation process |
931 |
// Only root variables go through the GDB creation process |
| 920 |
protected static final int STATE_NOT_CREATED = 10; |
932 |
protected static final int STATE_NOT_CREATED = 10; |
|
Lines 925-931
Link Here
|
| 925 |
// will have the same control context |
937 |
// will have the same control context |
| 926 |
private ICommandControlDMContext fControlContext = null; |
938 |
private ICommandControlDMContext fControlContext = null; |
| 927 |
|
939 |
|
| 928 |
private boolean outOfDate = false; |
940 |
private boolean fOutOfDate = false; |
| 929 |
|
941 |
|
| 930 |
// Modifiable descendants are any variable object that is a descendant or itself for |
942 |
// Modifiable descendants are any variable object that is a descendant or itself for |
| 931 |
// which the value can change. |
943 |
// which the value can change. |
|
Lines 940-947
Link Here
|
| 940 |
public ICommandControlDMContext getControlDMContext() { return fControlContext; } |
952 |
public ICommandControlDMContext getControlDMContext() { return fControlContext; } |
| 941 |
|
953 |
|
| 942 |
public boolean isUpdating() { return currentState == STATE_UPDATING; } |
954 |
public boolean isUpdating() { return currentState == STATE_UPDATING; } |
| 943 |
|
955 |
|
| 944 |
public void markAsOutOfDate() { outOfDate = true; } |
956 |
public void setOutOfDate(boolean outOfDate) { fOutOfDate = outOfDate; } |
|
|
957 |
|
| 958 |
public boolean getOutOfDate() { return fOutOfDate; } |
| 945 |
|
959 |
|
| 946 |
// Remember that we must add ourself as a modifiable descendant if our value can change |
960 |
// Remember that we must add ourself as a modifiable descendant if our value can change |
| 947 |
public void addModifiableDescendant(String gdbName, MIVariableObject descendant) { |
961 |
public void addModifiableDescendant(String gdbName, MIVariableObject descendant) { |
|
Lines 1033-1039
Link Here
|
| 1033 |
// Object is not fully created or is being updated |
1047 |
// Object is not fully created or is being updated |
| 1034 |
// so add RequestMonitor to pending queue |
1048 |
// so add RequestMonitor to pending queue |
| 1035 |
updatesPending.add(rm); |
1049 |
updatesPending.add(rm); |
| 1036 |
} else if (outOfDate == false) { |
1050 |
} else if (getOutOfDate() == false) { |
| 1037 |
rm.setData(false); |
1051 |
rm.setData(false); |
| 1038 |
rm.done(); |
1052 |
rm.done(); |
| 1039 |
} else { |
1053 |
} else { |
|
Lines 1063-1069
Link Here
|
| 1063 |
currentState = STATE_READY; |
1077 |
currentState = STATE_READY; |
| 1064 |
|
1078 |
|
| 1065 |
if (isSuccess()) { |
1079 |
if (isSuccess()) { |
| 1066 |
outOfDate = false; |
1080 |
setOutOfDate(false); |
| 1067 |
|
1081 |
|
| 1068 |
MIVarChange[] changes = getData().getMIVarChanges(); |
1082 |
MIVarChange[] changes = getData().getMIVarChanges(); |
| 1069 |
if (changes.length > 0 && changes[0].isInScope() == false) { |
1083 |
if (changes.length > 0 && changes[0].isInScope() == false) { |
|
Lines 1088-1094
Link Here
|
| 1088 |
// We only mark this root as updated in our list if it is in-scope. |
1102 |
// We only mark this root as updated in our list if it is in-scope. |
| 1089 |
// For out-of-scope object, we don't ever need to re-update them so |
1103 |
// For out-of-scope object, we don't ever need to re-update them so |
| 1090 |
// we don't need to add them to this list. |
1104 |
// we don't need to add them to this list. |
| 1091 |
updatedRootList.add(MIRootVariableObject.this); |
1105 |
rootVariableUpdated(MIRootVariableObject.this); |
| 1092 |
|
1106 |
|
| 1093 |
rm.setData(false); |
1107 |
rm.setData(false); |
| 1094 |
rm.done(); |
1108 |
rm.done(); |
|
Lines 1138-1146
Link Here
|
| 1138 |
} else { |
1152 |
} else { |
| 1139 |
// Variable was never created or was already deleted, no need to do anything. |
1153 |
// Variable was never created or was already deleted, no need to do anything. |
| 1140 |
} |
1154 |
} |
| 1141 |
} |
1155 |
} |
| 1142 |
|
1156 |
} |
| 1143 |
|
1157 |
|
|
|
1158 |
/** |
| 1159 |
* Method to allow to override the MIRootVariableObject creation. |
| 1160 |
* |
| 1161 |
* @since 2.1 |
| 1162 |
*/ |
| 1163 |
protected MIRootVariableObject createRootVariableObject(VariableObjectId id) { |
| 1164 |
return new MIRootVariableObject(id); |
| 1144 |
} |
1165 |
} |
| 1145 |
|
1166 |
|
| 1146 |
/** |
1167 |
/** |
|
Lines 1153-1160
Link Here
|
| 1153 |
* |
1174 |
* |
| 1154 |
* Note that if no frameContext is specified (only Execution, or even only Container), which can |
1175 |
* Note that if no frameContext is specified (only Execution, or even only Container), which can |
| 1155 |
* characterize a global variable for example, we will only use the available information. |
1176 |
* characterize a global variable for example, we will only use the available information. |
|
|
1177 |
* |
| 1178 |
* @since 2.1 |
| 1156 |
*/ |
1179 |
*/ |
| 1157 |
private class VariableObjectId { |
1180 |
public class VariableObjectId { |
| 1158 |
// We don't use the expression context because it is not safe to compare them |
1181 |
// We don't use the expression context because it is not safe to compare them |
| 1159 |
// See bug 187718. So we store the expression itself, and it's parent execution context. |
1182 |
// See bug 187718. So we store the expression itself, and it's parent execution context. |
| 1160 |
String fExpression = null; |
1183 |
String fExpression = null; |
|
Lines 1163-1168
Link Here
|
| 1163 |
// the same frame will have a different level based on the current depth of the stack |
1186 |
// the same frame will have a different level based on the current depth of the stack |
| 1164 |
Integer fFrameId = null; |
1187 |
Integer fFrameId = null; |
| 1165 |
|
1188 |
|
|
|
1189 |
public VariableObjectId() { |
| 1190 |
} |
| 1191 |
|
| 1166 |
@Override |
1192 |
@Override |
| 1167 |
public boolean equals(Object other) { |
1193 |
public boolean equals(Object other) { |
| 1168 |
if (other instanceof VariableObjectId) { |
1194 |
if (other instanceof VariableObjectId) { |
|
Lines 1220-1225
Link Here
|
| 1220 |
} |
1246 |
} |
| 1221 |
} |
1247 |
} |
| 1222 |
|
1248 |
|
|
|
1249 |
/** |
| 1250 |
* Method to allow to override the VariableObjectId creation. |
| 1251 |
* |
| 1252 |
* @since 2.1 |
| 1253 |
*/ |
| 1254 |
protected VariableObjectId createVariableObjectId() { |
| 1255 |
return new VariableObjectId(); |
| 1256 |
} |
| 1257 |
|
| 1258 |
|
| 1223 |
/** |
1259 |
/** |
| 1224 |
* This is the real work horse of managing our objects. Not only must every |
1260 |
* This is the real work horse of managing our objects. Not only must every |
| 1225 |
* value be unique to get inserted, this also creates an LRU (least recently |
1261 |
* value be unique to get inserted, this also creates an LRU (least recently |
|
Lines 1338-1343
Link Here
|
| 1338 |
fSession.removeServiceEventListener(this); |
1374 |
fSession.removeServiceEventListener(this); |
| 1339 |
} |
1375 |
} |
| 1340 |
|
1376 |
|
|
|
1377 |
/** |
| 1378 |
* @since 2.1 |
| 1379 |
*/ |
| 1380 |
protected DsfSession getSession() { |
| 1381 |
return fSession; |
| 1382 |
} |
| 1383 |
|
| 1384 |
/** |
| 1385 |
* @since 2.1 |
| 1386 |
*/ |
| 1387 |
protected ICommandControl getCommandControl() { |
| 1388 |
return fCommandControl; |
| 1389 |
} |
| 1390 |
|
| 1391 |
/** |
| 1392 |
* @since 2.1 |
| 1393 |
*/ |
| 1394 |
protected void rootVariableUpdated(MIRootVariableObject rootObj) { |
| 1395 |
updatedRootList.add(rootObj); |
| 1396 |
} |
| 1397 |
|
| 1398 |
/** |
| 1399 |
* @since 2.1 |
| 1400 |
*/ |
| 1401 |
protected Map<VariableObjectId, MIVariableObject> getLRUCache() { |
| 1402 |
return lruVariableList; |
| 1403 |
} |
| 1404 |
|
| 1341 |
/** |
1405 |
/** |
| 1342 |
* This method returns a variable object based on the specified |
1406 |
* This method returns a variable object based on the specified |
| 1343 |
* ExpressionDMC, creating it in GDB if it was not created already. |
1407 |
* ExpressionDMC, creating it in GDB if it was not created already. |
|
Lines 1354-1360
Link Here
|
| 1354 |
final DataRequestMonitor<MIVariableObject> rm) { |
1418 |
final DataRequestMonitor<MIVariableObject> rm) { |
| 1355 |
// Generate an id for this expression so that we can determine if we already |
1419 |
// Generate an id for this expression so that we can determine if we already |
| 1356 |
// have a variable object tracking it. If we don't we'll need to create one. |
1420 |
// have a variable object tracking it. If we don't we'll need to create one. |
| 1357 |
final VariableObjectId id = new VariableObjectId(); |
1421 |
final VariableObjectId id = createVariableObjectId(); |
| 1358 |
id.generateId( |
1422 |
id.generateId( |
| 1359 |
exprCtx, |
1423 |
exprCtx, |
| 1360 |
new RequestMonitor(fSession.getExecutor(), rm) { |
1424 |
new RequestMonitor(fSession.getExecutor(), rm) { |
|
Lines 1431-1437
Link Here
|
| 1431 |
|
1495 |
|
| 1432 |
// Variable objects that are created directly like this, are considered ROOT variable objects |
1496 |
// Variable objects that are created directly like this, are considered ROOT variable objects |
| 1433 |
// in comparison to variable objects that are children of other variable objects. |
1497 |
// in comparison to variable objects that are children of other variable objects. |
| 1434 |
final MIRootVariableObject newVarObj = new MIRootVariableObject(id); |
1498 |
final MIRootVariableObject newVarObj = createRootVariableObject(id); |
| 1435 |
|
1499 |
|
| 1436 |
// We must put this object in our map right away, in case it is |
1500 |
// We must put this object in our map right away, in case it is |
| 1437 |
// requested again, before it completes its creation. |
1501 |
// requested again, before it completes its creation. |
|
Lines 1443-1449
Link Here
|
| 1443 |
protected void handleCompleted() { |
1507 |
protected void handleCompleted() { |
| 1444 |
if (isSuccess()) { |
1508 |
if (isSuccess()) { |
| 1445 |
// Also store the object as a varObj that is up-to-date |
1509 |
// Also store the object as a varObj that is up-to-date |
| 1446 |
updatedRootList.add(newVarObj); |
1510 |
rootVariableUpdated(newVarObj); |
| 1447 |
// VarObj can now be used by others |
1511 |
// VarObj can now be used by others |
| 1448 |
newVarObj.creationCompleted(true); |
1512 |
newVarObj.creationCompleted(true); |
| 1449 |
|
1513 |
|
|
Lines 1625-1631
Link Here
|
| 1625 |
} |
1689 |
} |
| 1626 |
}); |
1690 |
}); |
| 1627 |
|
1691 |
|
| 1628 |
} else if (command instanceof MIDataEvaluateExpression) { |
1692 |
} else if (command instanceof MIDataEvaluateExpression<?>) { |
| 1629 |
// This does not use the variable objects but sends the command directly to the back-end |
1693 |
// This does not use the variable objects but sends the command directly to the back-end |
| 1630 |
fCommandControl.queueCommand(command, rm); |
1694 |
fCommandControl.queueCommand(command, rm); |
| 1631 |
} else { |
1695 |
} else { |
|
Lines 1684-1690
Link Here
|
| 1684 |
public void markAllOutOfDate() { |
1748 |
public void markAllOutOfDate() { |
| 1685 |
MIRootVariableObject root; |
1749 |
MIRootVariableObject root; |
| 1686 |
while ((root = updatedRootList.poll()) != null) { |
1750 |
while ((root = updatedRootList.poll()) != null) { |
| 1687 |
root.markAsOutOfDate(); |
1751 |
root.setOutOfDate(true); |
| 1688 |
} |
1752 |
} |
| 1689 |
} |
1753 |
} |
| 1690 |
|
1754 |
|