diff options
author | Alain Magloire | 2004-11-09 01:47:41 +0000 |
---|---|---|
committer | Alain Magloire | 2004-11-09 01:47:41 +0000 |
commit | db8bcbda608aa7e5381f8a093e90182138dd8317 (patch) | |
tree | 532d6cf46eac2107dc79d4a0a94a135bd20909bf | |
parent | 439665d7d0be00f16bf52b82b04cf3f7ed108c78 (diff) | |
download | org.eclipse.cdt-db8bcbda608aa7e5381f8a093e90182138dd8317.tar.gz org.eclipse.cdt-db8bcbda608aa7e5381f8a093e90182138dd8317.tar.xz org.eclipse.cdt-db8bcbda608aa7e5381f8a093e90182138dd8317.zip |
2004-11-08 Alain Magloire
Fix for 74496 ; we should destroy the global
variables if they are in the address range of a
shared library being unloaded.
* cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java
15 files changed, 149 insertions, 68 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index faf073e756c..369349987b9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,10 @@ +2004-11-08 Alain Magloire + Fix for 74496 ; we should destroy the global + variables if they are in the address range of a + shared library being unloaded. + + * cdi/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java + 2004-11-08 Mikhail Khodjaiants Added support for refresh preferences and properties. * IMIConstants.java diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java index c0f02661bb6..6c5425aa62e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java @@ -248,7 +248,6 @@ public class BreakpointManager extends Manager { numbers[i] = miBreakpoints[i].getNumber(); } - Session session = (Session)target.getSession(); boolean state = suspendInferior(target); MISession miSession = target.getMISession(); CommandFactory factory = miSession.getCommandFactory(); 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 f2decae7549..8342770aeef 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 @@ -23,7 +23,9 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; +import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; import org.eclipse.cdt.debug.mi.core.MIException; +import org.eclipse.cdt.debug.mi.core.MIFormat; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.event.ChangedEvent; import org.eclipse.cdt.debug.mi.core.cdi.event.CreatedEvent; @@ -34,9 +36,16 @@ import org.eclipse.cdt.debug.mi.core.cdi.event.MemoryChangedEvent; import org.eclipse.cdt.debug.mi.core.cdi.event.ResumedEvent; import org.eclipse.cdt.debug.mi.core.cdi.event.SuspendedEvent; import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint; +import org.eclipse.cdt.debug.mi.core.cdi.model.GlobalVariable; import org.eclipse.cdt.debug.mi.core.cdi.model.MemoryBlock; +import org.eclipse.cdt.debug.mi.core.cdi.model.SharedLibrary; +import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.cdi.model.Thread; +import org.eclipse.cdt.debug.mi.core.cdi.model.Variable; +import org.eclipse.cdt.debug.mi.core.cdi.model.type.FunctionValue; +import org.eclipse.cdt.debug.mi.core.cdi.model.type.PointerValue; +import org.eclipse.cdt.debug.mi.core.cdi.model.type.ReferenceValue; import org.eclipse.cdt.debug.mi.core.command.Command; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIExecContinue; @@ -47,7 +56,6 @@ import org.eclipse.cdt.debug.mi.core.command.MIThreadSelect; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointDeletedEvent; -import org.eclipse.cdt.debug.mi.core.event.MIBreakpointHitEvent; import org.eclipse.cdt.debug.mi.core.event.MIChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MICreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIDestroyedEvent; @@ -341,13 +349,60 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs Session session = (Session)getSession(); MISession miSession = unLoaded.getMISession(); Target target = session.getTarget(miSession); + + // We do not nee to do fancy checking we can jsut delete all + // the expression variable and let the recreate them by reevaluating. ExpressionManager expMgr = session.getExpressionManager(); - VariableManager varMgr = session.getVariableManager(); try { - expMgr.destroyAllExpressions(target); - varMgr.destroyAllVariables(target); + expMgr.deleteAllVariables(target); } catch (CDIException e) { } + + // Do this only for global variable for now. + // we nee to look at the address of the variable + // and see if they are in the range of the library if yes + // destroy them + SharedLibraryManager sharedMgr = session.getSharedLibraryManager(); + SharedLibrary lib = sharedMgr.getSharedLibrary(target, unLoaded.getName()); + if (lib != null) { + BigInteger startAddress = lib.getStartAddress(); + BigInteger endAddress = lib.getEndAddress(); + try { + Thread thread = (Thread)target.getCurrentThread(); + StackFrame frame = thread.getCurrentStackFrame(); + VariableManager varMgr = session.getVariableManager(); + Variable[] vars = varMgr.getVariables(target); + for (int i = 0; i < vars.length; i++) { + if (vars[i] instanceof GlobalVariable) { + try { + ICDIValue value = vars[i].getValue(); + String result = null; + if (value instanceof PointerValue || + value instanceof ReferenceValue || + value instanceof FunctionValue) { + result = target.evaluateExpressionToString(frame, vars[i].getFullName()); //$NON-NLS-1$ + } else { + result = target.evaluateExpressionToString(frame, "&" + vars[i].getFullName()); //$NON-NLS-1$ + } + if (result != null && result.length() > 0) { + BigInteger address = MIFormat.decodeAdress(result); + int op = address.compareTo(startAddress); + if (op == 0 || op == 1) { + op = address.compareTo(endAddress); + if (op == 0 || op == -1) { + varMgr.destroyVariable(vars[i]); + } + } + } + } catch (CDIException e) { + // + } + } + } + } catch (CDIException e) { + // ignore it. ??? + } + } return false; } @@ -526,12 +581,12 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs } boolean processBreakpointHitEvent(MIStoppedEvent stopped) { - Session session = (Session)getSession(); - if (stopped instanceof MIBreakpointHitEvent) { - MIBreakpointHitEvent bpEvent = (MIBreakpointHitEvent)stopped; - BreakpointManager bpMgr = session.getBreakpointManager(); - int bpNo = bpEvent.getNumber(); - } +// Session session = (Session)getSession(); +// if (stopped instanceof MIBreakpointHitEvent) { +// MIBreakpointHitEvent bpEvent = (MIBreakpointHitEvent)stopped; +// BreakpointManager bpMgr = session.getBreakpointManager(); +// int bpNo = bpEvent.getNumber(); +// } return false; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java index 0f525c778d0..e88f5b8f056 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java @@ -103,11 +103,11 @@ public class SharedLibraryManager extends Manager { MIShared[] miLibs = getMIShareds(miSession); ArrayList eventList = new ArrayList(miLibs.length); for (int i = 0; i < miLibs.length; i++) { - ICDISharedLibrary sharedlib = getSharedLibrary(target, miLibs[i].getName()); + SharedLibrary sharedlib = getSharedLibrary(target, miLibs[i].getName()); if (sharedlib != null) { if (hasSharedLibChanged(sharedlib, miLibs[i])) { // Fire ChangedEvent - ((SharedLibrary)sharedlib).setMIShared(miLibs[i]); + sharedlib.setMIShared(miLibs[i]); eventList.add(new MISharedLibChangedEvent(miSession, miLibs[i].getName())); } } else { @@ -120,7 +120,7 @@ public class SharedLibraryManager extends Manager { // Check if any libraries was unloaded. List sharedList = (List)sharedMap.get(target); if (sharedList != null) { - ICDISharedLibrary[] oldlibs = (ICDISharedLibrary[]) sharedList.toArray(new ICDISharedLibrary[sharedList.size()]); + SharedLibrary[] oldlibs = (SharedLibrary[]) sharedList.toArray(new SharedLibrary[sharedList.size()]); for (int i = 0; i < oldlibs.length; i++) { boolean found = false; for (int j = 0; j < miLibs.length; j++) { @@ -138,7 +138,7 @@ public class SharedLibraryManager extends Manager { return eventList; } - public boolean hasSharedLibChanged(ICDISharedLibrary lib, MIShared miLib) { + public boolean hasSharedLibChanged(SharedLibrary lib, MIShared miLib) { return !miLib.getName().equals(lib.getFileName()) || !MIFormat.getBigInteger(miLib.getFrom()).equals(lib.getStartAddress()) || !MIFormat.getBigInteger(miLib.getTo()).equals(lib.getEndAddress()) || @@ -148,7 +148,7 @@ public class SharedLibraryManager extends Manager { /* * this for the events */ - public void deleteSharedLibrary(MISession miSession, ICDISharedLibrary lib) { + public void deleteSharedLibrary(MISession miSession, SharedLibrary lib) { Target target = ((Session)getSession()).getTarget(miSession); List sharedList = (List)sharedMap.get(target); if (sharedList != null) { @@ -156,14 +156,14 @@ public class SharedLibraryManager extends Manager { } } - public ICDISharedLibrary getSharedLibrary(MISession miSession, String name) { + public SharedLibrary getSharedLibrary(MISession miSession, String name) { Target target = ((Session)getSession()).getTarget(miSession); return getSharedLibrary(target, name); } - public ICDISharedLibrary getSharedLibrary(Target target, String name) { + public SharedLibrary getSharedLibrary(Target target, String name) { List sharedList = (List)sharedMap.get(target); if (sharedList != null) { - ICDISharedLibrary[] libs = (ICDISharedLibrary[]) sharedList.toArray(new ICDISharedLibrary[sharedList.size()]); + SharedLibrary[] libs = (SharedLibrary[]) sharedList.toArray(new SharedLibrary[sharedList.size()]); for (int i = 0; i < libs.length; i++) { if (name.equals(libs[i].getFileName())) { return libs[i]; diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java index 70baa63d93c..de6e195c0df 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java @@ -70,7 +70,6 @@ public class SourceManager extends Manager { } public void addSourcePaths(Target target, String[] dirs) throws CDIException { - Session session = (Session)getSession(); MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIEnvironmentDirectory dir = factory.createMIEnvironmentDirectory(dirs); @@ -400,7 +399,6 @@ public class SourceManager extends Manager { } public String getDetailTypeName(StackFrame frame, String typename) throws CDIException { - Session session = (Session)getSession(); Target target = (Target)frame.getTarget(); Thread currentThread = (Thread)target.getCurrentThread(); StackFrame currentFrame = currentThread.getCurrentStackFrame(); @@ -425,7 +423,6 @@ public class SourceManager extends Manager { } public String getTypeName(StackFrame frame, String variable) throws CDIException { - Session session = (Session)getSession(); Target target = (Target)frame.getTarget(); Thread currentThread = null; StackFrame currentFrame = null; 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 602399884c9..540b1cbb838 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 @@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.event; 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; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager; import org.eclipse.cdt.debug.mi.core.cdi.ExpressionManager; @@ -21,6 +20,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager; import org.eclipse.cdt.debug.mi.core.cdi.VariableManager; import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint; import org.eclipse.cdt.debug.mi.core.cdi.model.CObject; +import org.eclipse.cdt.debug.mi.core.cdi.model.SharedLibrary; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.cdi.model.Thread; import org.eclipse.cdt.debug.mi.core.cdi.model.Variable; @@ -82,7 +82,7 @@ public class DestroyedEvent implements ICDIDestroyedEvent { SharedLibraryManager mgr = session.getSharedLibraryManager(); MISession miSession = slib.getMISession(); String name = slib.getName(); - ICDISharedLibrary lib = mgr.getSharedLibrary(miSession, name); + SharedLibrary lib = mgr.getSharedLibrary(miSession, name); if (lib != null) { mgr.deleteSharedLibrary(miSession, lib); source = lib; diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java index 4c8cb549d26..f88a97ec394 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java @@ -40,13 +40,13 @@ public class Register extends Variable implements ICDIRegister { * @see org.eclipse.cdt.debug.mi.core.cdi.model.VariableDescriptor#getFullName() */ public String getFullName() { - if (fullName == null) { + if (fFullName == null) { String n = getName(); if (!n.startsWith("$")) { //$NON-NLS-1$ - fullName = "$" + n; //$NON-NLS-1$ + fFullName = "$" + n; //$NON-NLS-1$ } } - return fullName; + return fFullName; } protected Variable createVariable(Target target, Thread thread, StackFrame frame, String name, String fullName, int pos, int depth, MIVar miVar) { diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterDescriptor.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterDescriptor.java index 48d006732b6..ab37be11144 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterDescriptor.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterDescriptor.java @@ -26,12 +26,12 @@ public class RegisterDescriptor extends VariableDescriptor implements ICDIRegist * @see org.eclipse.cdt.debug.mi.core.cdi.model.VariableDescriptor#getFullName() */ public String getFullName() { - if (fullName == null) { + if (fFullName == null) { String n = getName(); if (!n.startsWith("$")) { //$NON-NLS-1$ - fullName = "$" + n; //$NON-NLS-1$ + fFullName = "$" + n; //$NON-NLS-1$ } } - return fullName; + return fFullName; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RuntimeOptions.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RuntimeOptions.java index 7b790efddec..1b9a270e250 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RuntimeOptions.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RuntimeOptions.java @@ -27,8 +27,6 @@ import org.eclipse.cdt.debug.mi.core.output.MIInfo; /** */ public class RuntimeOptions extends CObject implements ICDIRuntimeOptions { - - Target target; public RuntimeOptions(Target t) { super(t); diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java index 360e5a74d8b..922089272fb 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java @@ -634,7 +634,6 @@ public class Target extends SessionObject implements ICDITarget { } public String evaluateExpressionToString(ICDIStackFrame frame, String expressionText) throws CDIException { - Session session = (Session)getSession(); Target target = (Target)frame.getTarget(); Thread currentThread = (Thread)target.getCurrentThread(); StackFrame currentFrame = currentThread.getCurrentStackFrame(); diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java index b7f07f13a86..54612b82bba 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java @@ -71,7 +71,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarShowAttributesInfo; */ public abstract class Variable extends VariableDescriptor implements ICDIVariable { - MIVar miVar; + MIVar fMiVar; Value value; ICDIVariable[] children = new ICDIVariable[0]; String editable = null; @@ -80,16 +80,16 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl public Variable(VariableDescriptor obj, MIVar v) { super(obj); - miVar = v; + fMiVar = v; } public Variable(Target target, Thread thread, StackFrame frame, String n, String q, int pos, int depth, MIVar v) { super(target, thread, frame, n, q, pos, depth); - miVar = v; + fMiVar = v; } public MIVar getMIVar() { - return miVar; + return fMiVar; } public Variable getChild(String name) { @@ -179,7 +179,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl if (subType instanceof ICDIStructType) { if (isCPPLanguage()) { if (!isFake() - || (isFake() && !(name.equals("private") || name.equals("public") || name.equals("protected")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + || (isFake() && !(fName.equals("private") || fName.equals("public") || fName.equals("protected")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ childFake = true; childType = t; } else { @@ -210,7 +210,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl // So we choose to ignore the first set of children // but carry over to those "fake" variables the typename and the qualified name if (!isFake() - || (isFake() && !(name.equals("private") || name.equals("public") || name.equals("protected")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + || (isFake() && !(fName.equals("private") || fName.equals("public") || fName.equals("protected")))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ childFake = true; childType = t; } else { @@ -224,7 +224,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl childName, fn, getPosition(), getStackDepth(), vars[i]); if (childType != null) { // Hack to reset the typename to a known value - v.type = childType; + v.fType = childType; } v.setIsFake(childFake); children[i] = v; @@ -239,7 +239,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl String name, String fullName, int pos, int depth, MIVar miVar); public int getChildrenNumber() throws CDIException { - return miVar.getNumChild(); + return fMiVar.getNumChild(); } /** @@ -299,7 +299,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl Target target = (Target)getTarget(); MISession miSession = target.getMISession(); CommandFactory factory = miSession.getCommandFactory(); - MIVarAssign var = factory.createMIVarAssign(miVar.getVarName(), expression); + MIVarAssign var = factory.createMIVarAssign(fMiVar.getVarName(), expression); try { miSession.postCommand(var); MIInfo info = var.getMIInfo(); @@ -312,7 +312,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl // If the assign was succesfull fire a MIVarChangedEvent() for the variable // Note GDB will not fire an event for the changed variable we have to do it manually. - MIVarChangedEvent change = new MIVarChangedEvent(miSession, var.getToken(), miVar.getVarName()); + MIVarChangedEvent change = new MIVarChangedEvent(miSession, var.getToken(), fMiVar.getVarName()); miSession.fireEvent(change); // Changing values may have side effects i.e. affecting other variables @@ -348,7 +348,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl if (editable == null) { MISession mi = ((Target) getTarget()).getMISession(); CommandFactory factory = mi.getCommandFactory(); - MIVarShowAttributes var = factory.createMIVarShowAttributes(miVar.getVarName()); + MIVarShowAttributes var = factory.createMIVarShowAttributes(fMiVar.getVarName()); try { mi.postCommand(var); MIVarShowAttributesInfo info = var.getMIVarShowAttributesInfo(); @@ -370,7 +370,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl int fmt = Format.toMIFormat(format); MISession mi = ((Target) getTarget()).getMISession(); CommandFactory factory = mi.getCommandFactory(); - MIVarSetFormat var = factory.createMIVarSetFormat(miVar.getVarName(), fmt); + MIVarSetFormat var = factory.createMIVarSetFormat(fMiVar.getVarName(), fmt); try { mi.postCommand(var); MIInfo info = var.getMIInfo(); @@ -388,7 +388,7 @@ public abstract class Variable extends VariableDescriptor implements ICDIVariabl public boolean equals(ICDIVariable var) { if (var instanceof Variable) { Variable variable = (Variable) var; - return miVar.getVarName().equals(variable.getMIVar().getVarName()); + return fMiVar.getVarName().equals(variable.getMIVar().getVarName()); } return super.equals(var); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableDescriptor.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableDescriptor.java index 94076c74599..21daf73415c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableDescriptor.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableDescriptor.java @@ -37,15 +37,15 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable int castingIndex; int castingLength; - String name; + String fName; int position; StackFrame fStackFrame; Thread fThread; int stackdepth; String qualifiedName = null; - String fullName = null; - ICDIType type = null; + String fFullName = null; + ICDIType fType = null; String typename = null; String sizeof = null; @@ -55,10 +55,10 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable */ public VariableDescriptor(VariableDescriptor desc) { super((Target)desc.getTarget()); - name = desc.getName(); - fullName = desc.fullName; + fName = desc.getName(); + fFullName = desc.fFullName; sizeof = desc.sizeof; - type = desc.type; + fType = desc.fType; try { fStackFrame = (StackFrame)desc.getStackFrame(); fThread = (Thread)desc.getThread(); @@ -73,8 +73,8 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable public VariableDescriptor(Target target, Thread thread, StackFrame stack, String n, String fn, int pos, int depth) { super(target); - name = n; - fullName = fn; + fName = n; + fFullName = fn; fStackFrame = stack; fThread = thread; position = pos; @@ -150,24 +150,24 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable } public String getFullName() { - if (fullName == null) { - fullName = getName(); + if (fFullName == null) { + fFullName = getName(); } - return fullName; + return fFullName; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIVariableDescriptor#getName() */ public String getName() { - return name; + return fName; } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getType() */ public ICDIType getType() throws CDIException { - if (type == null) { + if (fType == null) { Target target = (Target)getTarget(); Session session = (Session) (target.getSession()); StackFrame frame = (StackFrame)getStackFrame(); @@ -182,29 +182,29 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable SourceManager sourceMgr = session.getSourceManager(); String nametype = sourceMgr.getTypeName(frame, getQualifiedName()); try { - type = sourceMgr.getType(frame, nametype); + fType = sourceMgr.getType(frame, nametype); } catch (CDIException e) { // Try with ptype. try { String ptype = sourceMgr.getDetailTypeName(frame, nametype); - type = sourceMgr.getType(frame, ptype); + fType = sourceMgr.getType(frame, ptype); } catch (CDIException ex) { // Some version of gdb does not work woth the name of the class // ex: class data foo --> ptype data --> fails // ex: class data foo --> ptype foo --> succeed try { String ptype = sourceMgr.getDetailTypeName(frame, getQualifiedName()); - type = sourceMgr.getType(frame, ptype); + fType = sourceMgr.getType(frame, ptype); } catch (CDIException e2) { // give up. } } } - if (type == null) { - type = new IncompleteType(frame, nametype); + if (fType == null) { + fType = new IncompleteType(frame, nametype); } } - return type; + return fType; } /* (non-Javadoc) @@ -213,7 +213,6 @@ public abstract class VariableDescriptor extends CObject implements ICDIVariable public int sizeof() throws CDIException { if (sizeof == null) { Target target = (Target) getTarget(); - Session session = (Session) (target.getSession()); Thread currentThread = (Thread)target.getCurrentThread(); StackFrame currentFrame = currentThread.getCurrentStackFrame(); StackFrame frame = (StackFrame)getStackFrame(); diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIFormat.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIFormat.java index 6f07cbf19b9..ec3084d0138 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIFormat.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIFormat.java @@ -34,6 +34,35 @@ public final class MIFormat { private MIFormat() { } + /** + * We are assuming that GDB will print the address in hex format + * like: + * 0xbfffe5f0 "hello" + * (int *) 0xbfffe2b8 + * + * @param buffer + * @return + */ + public static BigInteger decodeAdress(String buffer) { + int radix = 10; + int cursor = 0; + int offset = 0; + int len = buffer.length(); + + if ((offset = buffer.indexOf("0x")) != -1 || //$NON-NLS-1$ + (offset = buffer.indexOf("0X")) != -1) { //$NON-NLS-1$ + radix = 16; + cursor = offset + 2; + } + + while (cursor < len && Character.digit(buffer.charAt(cursor), radix) != -1) { + cursor++; + } + + String s = buffer.substring(offset, cursor); + return getBigInteger(s); + } + public static BigInteger getBigInteger(String address) { int index = 0; int radix = 10; diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java index 3efc6b08dc1..d0fcab713f0 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIPlugin.java @@ -25,7 +25,6 @@ import org.eclipse.cdt.debug.mi.core.command.MITargetAttach; import org.eclipse.cdt.debug.mi.core.command.MITargetSelect; import org.eclipse.cdt.debug.mi.core.output.MIInfo; import org.eclipse.cdt.utils.pty.PTY; -import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Plugin; diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java index 20bd2d98dd0..5d4ebfe63ff 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java @@ -133,7 +133,6 @@ public class MIProcessAdapter implements MIProcess { if (fGDBProcess instanceof Spawner) { Spawner gdbSpawner = (Spawner) fGDBProcess; gdbSpawner.interrupt(); - int state; synchronized (inferior) { // Allow (5 secs) for the interrupt to propagate. for (int i = 0; inferior.isRunning() && i < 5; i++) { |