1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-10 09:45:39 +02:00

2004-10-31 Alain Magloire

Tentative fix for PR 74496
This commit is contained in:
Alain Magloire 2004-11-01 00:27:29 +00:00
parent 8edc6b4de2
commit e37879d199
5 changed files with 73 additions and 77 deletions

View file

@ -1,3 +1,6 @@
2004-10-31 Alain Magloire
Tentative fix for PR 74496
2004-10-31 Alain Magloire
Refactor ICDIVariableObject --> ICDIVariableDescriptor
Refactor ICDIArgumentObject --> ICDIArgumentDescriptor

View file

@ -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));
@ -329,6 +330,27 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
return true;
}
/**
* 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
@ -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;
}

View file

@ -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 {

View file

@ -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));
}
}

View file

@ -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);