Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2004-11-01 00:27:29 +0000
committerAlain Magloire2004-11-01 00:27:29 +0000
commite37879d19987c7ee1d50552ea03c46718436203b (patch)
treef818d2123c1f46f504dedd748a771cd63b6fc8ad /debug/org.eclipse.cdt.debug.mi.core
parent8edc6b4de242cb01ca4e28832b571416f7560074 (diff)
downloadorg.eclipse.cdt-e37879d19987c7ee1d50552ea03c46718436203b.tar.gz
org.eclipse.cdt-e37879d19987c7ee1d50552ea03c46718436203b.tar.xz
org.eclipse.cdt-e37879d19987c7ee1d50552ea03c46718436203b.zip
2004-10-31 Alain Magloire
Tentative fix for PR 74496
Diffstat (limited to 'debug/org.eclipse.cdt.debug.mi.core')
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/ChangeLog3
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java25
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java75
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java38
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DestroyedEvent.java9
5 files changed, 73 insertions, 77 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog
index 70ad1e27c39..967e03df9b6 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog
@@ -1,4 +1,7 @@
2004-10-31 Alain Magloire
+ Tentative fix for PR 74496
+
+2004-10-31 Alain Magloire
Refactor ICDIVariableObject --> ICDIVariableDescriptor
Refactor ICDIArgumentObject --> ICDIArgumentDescriptor
Refactor ICDIRegisterObject --> ICDIRegisterDescriptor
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
index 45c3a7d1c4d..f2decae7549 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
@@ -184,6 +184,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
}
}
} else if (miEvent instanceof MISharedLibUnloadedEvent) {
+ processSharedLibUnloadedEvent((MISharedLibUnloadedEvent)miEvent);
cdiList.add(new DestroyedEvent(session, (MISharedLibUnloadedEvent)miEvent));
} else if (miEvent instanceof MIVarDeletedEvent) {
cdiList.add(new DestroyedEvent(session, (MIVarDeletedEvent)miEvent));
@@ -330,6 +331,27 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
}
/**
+ * When a shared library is unloading we could possibly have stale libraries.
+ * GDB does no react well to this: see PR
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=74496
+ * @param unLoaded
+ * @return
+ */
+ boolean processSharedLibUnloadedEvent(MISharedLibUnloadedEvent unLoaded) {
+ Session session = (Session)getSession();
+ MISession miSession = unLoaded.getMISession();
+ Target target = session.getTarget(miSession);
+ ExpressionManager expMgr = session.getExpressionManager();
+ VariableManager varMgr = session.getVariableManager();
+ try {
+ expMgr.destroyAllExpressions(target);
+ varMgr.destroyAllVariables(target);
+ } catch (CDIException e) {
+ }
+ return false;
+ }
+
+ /**
* If the deferredBreakpoint processing is set
* catch the shared-lib-event go to the last known
* stackframe and try to finish.
@@ -509,9 +531,6 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
MIBreakpointHitEvent bpEvent = (MIBreakpointHitEvent)stopped;
BreakpointManager bpMgr = session.getBreakpointManager();
int bpNo = bpEvent.getNumber();
- //if (bpMgr.isExceptionBreakpoint(bpNo)) {
-
- //}
}
return false;
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java
index b421ed8f75c..2c50d59803c 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java
@@ -29,14 +29,9 @@ import org.eclipse.cdt.debug.mi.core.cdi.model.Variable;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIVarCreate;
import org.eclipse.cdt.debug.mi.core.command.MIVarDelete;
-import org.eclipse.cdt.debug.mi.core.command.MIVarUpdate;
-import org.eclipse.cdt.debug.mi.core.event.MIEvent;
-import org.eclipse.cdt.debug.mi.core.event.MIVarChangedEvent;
-import org.eclipse.cdt.debug.mi.core.event.MIVarDeletedEvent;
import org.eclipse.cdt.debug.mi.core.output.MIVar;
import org.eclipse.cdt.debug.mi.core.output.MIVarChange;
import org.eclipse.cdt.debug.mi.core.output.MIVarCreateInfo;
-import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo;
/**
*/
@@ -44,13 +39,13 @@ public class ExpressionManager extends Manager {
final static ICDIExpression[] EMPTY_EXPRESSIONS = {};
Map expMap;
- List variableList;
+ Map varMap;
MIVarChange[] noChanges = new MIVarChange[0];
public ExpressionManager(Session session) {
super(session, true);
expMap = new Hashtable();
- variableList = Collections.synchronizedList(new ArrayList());
+ varMap = new Hashtable();
}
synchronized List getExpressionList(Target target) {
@@ -62,6 +57,14 @@ public class ExpressionManager extends Manager {
return expList;
}
+ synchronized List getVariableList(Target target) {
+ List varList = (List)varMap.get(target);
+ if (varList == null) {
+ varList = Collections.synchronizedList(new ArrayList());
+ varMap.put(target, varList);
+ }
+ return varList;
+ }
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createExpression(String)
*/
@@ -86,9 +89,7 @@ public class ExpressionManager extends Manager {
public void destroyExpressions(Target target, ICDIExpression[] expressions) throws CDIException {
List expList = getExpressionList(target);
for (int i = 0; i < expressions.length; ++i) {
- if (expressions[i] instanceof Expression) {
- expList.remove(expressions[i]);
- }
+ expList.remove(expressions[i]);
}
}
@@ -101,37 +102,7 @@ public class ExpressionManager extends Manager {
}
public void update(Target target) throws CDIException {
- List eventList = new ArrayList();
- MISession mi = target.getMISession();
- CommandFactory factory = mi.getCommandFactory();
- Variable[] vars = (Variable[])variableList.toArray(new Variable[0]);
- for (int i = 0; i < vars.length; i++) {
- Variable variable = vars[i];
- if (variable != null) {
- String varName = variable.getMIVar().getVarName();
- MIVarChange[] changes = noChanges;
- MIVarUpdate update = factory.createMIVarUpdate(varName);
- try {
- mi.postCommand(update);
- MIVarUpdateInfo info = update.getMIVarUpdateInfo();
- if (info == null) {
- throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
- }
- changes = info.getMIVarChanges();
- } catch (MIException e) {
- //throw new MI2CDIException(e);
- eventList.add(new MIVarDeletedEvent(mi, varName));
- }
- for (int j = 0 ; j < changes.length; j++) {
- String n = changes[j].getVarName();
- if (changes[j].isInScope()) {
- eventList.add(new MIVarChangedEvent(mi, n));
- }
- }
- }
- }
- MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]);
- mi.fireEvents(events);
+ deleteAllVariables(target);
}
/**
@@ -142,7 +113,8 @@ public class ExpressionManager extends Manager {
public Variable getVariable(MISession miSession, String varName) {
Session session = (Session)getSession();
Target target = session.getTarget(miSession);
- Variable[] vars = (Variable[])variableList.toArray(new Variable[0]);
+ List varList = getVariableList(target);
+ Variable[] vars = (Variable[])varList.toArray(new Variable[0]);
for (int i = 0; i < vars.length; i++) {
if (vars[i].getMIVar().getVarName().equals(varName)) {
return vars[i];
@@ -167,7 +139,8 @@ public class ExpressionManager extends Manager {
throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$
}
Variable variable = new LocalVariable(target, null, frame, code, null, 0, 0, info.getMIVar());
- variableList.add(variable);
+ List varList = getVariableList(target);
+ varList.add(variable);
return variable;
} catch (MIException e) {
throw new MI2CDIException(e);
@@ -177,21 +150,21 @@ public class ExpressionManager extends Manager {
}
}
+ public void deleteAllVariables(Target target) throws CDIException {
+ List varList = getVariableList(target);
+ Variable[] variables = (Variable[]) varList.toArray(new Variable[varList.size()]);
+ for (int i = 0; i < variables.length; ++i) {
+ deleteVariable(variables[i]);
+ }
+ }
/**
* Get rid of the underlying variable.
- *
*/
public void deleteVariable(Variable variable) throws CDIException {
Target target = (Target)variable.getTarget();
MISession miSession = target.getMISession();
MIVar miVar = variable.getMIVar();
- removeMIVar(miSession, variable.getMIVar());
- }
-
- /**
- * Tell gdb to remove the underlying var-object also.
- */
- public void removeMIVar(MISession miSession, MIVar miVar) throws CDIException {
+ //remove the underlying var-object now.
CommandFactory factory = miSession.getCommandFactory();
MIVarDelete var = factory.createMIVarDelete(miVar.getVarName());
try {
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java
index 50066ce31b2..845083c25e6 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java
@@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.mi.core.cdi;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -205,26 +206,19 @@ public class VariableManager extends Manager {
}
}
- /**
- * When element are remove from the cache, they are put on the OutOfScope list, oos,
- * because they are still needed for the destroy events. The destroy event will
- * call removeOutOfScope.
- */
- public void removeVariable(MISession miSession, String varName) throws CDIException {
+ public Variable removeVariableFromList(MISession miSession, String varName) {
Target target = ((Session)getSession()).getTarget(miSession);
- removeVariable(target, varName);
- }
- public void removeVariable(Target target, String varName) throws CDIException {
- Variable[] vars = getVariables(target);
- for (int i = 0; i < vars.length; i++) {
- if (vars[i].getMIVar().getVarName().equals(varName)) {
- List variableList = (List)variablesMap.get(target);
- if (variableList != null) {
- variableList.remove(vars[i]);
+ List varList = getVariablesList(target);
+ synchronized (varList) {
+ for (Iterator iterator = varList.iterator(); iterator.hasNext();) {
+ Variable variable = (Variable)iterator.next();
+ if (variable.getMIVar().getVarName().equals(varName)) {
+ iterator.remove();
+ return variable;
}
- removeMIVar(target.getMISession(), vars[i].getMIVar());
}
}
+ return null;
}
public VariableDescriptor getVariableDescriptorAsArray(VariableDescriptor varDesc, int start, int length)
@@ -520,10 +514,21 @@ public class VariableManager extends Manager {
// Fire a destroyEvent ?
Target target = (Target)variable.getTarget();
MISession mi = target.getMISession();
+ removeMIVar(mi, variable.getMIVar());
MIVarDeletedEvent del = new MIVarDeletedEvent(mi, variable.getMIVar().getVarName());
mi.fireEvent(del);
}
+ public void destroyAllVariables(Target target) throws CDIException {
+ Variable[] variables = getVariables(target);
+ MISession mi = target.getMISession();
+ for (int i = 0; i < variables.length; ++i) {
+ removeMIVar(mi, variables[i].getMIVar());
+ MIVarDeletedEvent del = new MIVarDeletedEvent(mi, variables[i].getMIVar().getVarName());
+ mi.fireEvent(del);
+ }
+ }
+
/**
* Update the elements in the cache, from the response of the "-var-update"
* mi/command. Althought tempting we do not use the "-var-update *" command, since
@@ -580,6 +585,7 @@ public class VariableManager extends Manager {
if (changes[j].isInScope()) {
eventList.add(new MIVarChangedEvent(mi, n));
} else {
+ destroyVariable(variable);
eventList.add(new MIVarDeletedEvent(mi, n));
}
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DestroyedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DestroyedEvent.java
index a3576ca8293..602399884c9 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DestroyedEvent.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DestroyedEvent.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.event;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
@@ -48,13 +47,9 @@ public class DestroyedEvent implements ICDIDestroyedEvent {
VariableManager varMgr = session.getVariableManager();
MISession miSession = var.getMISession();
String varName = var.getVarName();
- Variable variable = varMgr.getVariable(miSession, varName);
- if (variable!= null) {
+ Variable variable = varMgr.removeVariableFromList(miSession, varName);
+ if (variable != null) {
source = variable;
- try {
- varMgr.removeVariable(miSession, variable.getMIVar().getVarName());
- } catch (CDIException e) {
- }
} else {
ExpressionManager expMgr = session.getExpressionManager();
variable = expMgr.getVariable(miSession, varName);

Back to the top