From 98e5f3013180cb0caa04f960f887ab1bcc1a44df Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Wed, 15 Sep 2004 21:53:50 +0000 Subject: [PATCH] Set the correct stackframe --- .../cdt/debug/mi/core/cdi/SourceManager.java | 25 +++++++++++++++++-- .../mi/core/cdi/model/VariableObject.java | 7 +++--- .../mi/core/cdi/model/type/DerivedType.java | 4 ++- 3 files changed, 30 insertions(+), 6 deletions(-) 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 0a8e8489a53..40e8fa69bb3 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 @@ -16,6 +16,9 @@ import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISourceManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction; import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction; +import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; +import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.mi.core.GDBTypeParser; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; @@ -23,7 +26,9 @@ import org.eclipse.cdt.debug.mi.core.GDBTypeParser.GDBDerivedType; import org.eclipse.cdt.debug.mi.core.GDBTypeParser.GDBType; import org.eclipse.cdt.debug.mi.core.cdi.model.Instruction; import org.eclipse.cdt.debug.mi.core.cdi.model.MixedInstruction; +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.type.ArrayType; import org.eclipse.cdt.debug.mi.core.cdi.model.type.BoolType; import org.eclipse.cdt.debug.mi.core.cdi.model.type.CharType; @@ -452,7 +457,12 @@ public class SourceManager extends Manager implements ICDISourceManager { throw new CDIException(CdiResources.getString("cdi.SourceManager.Unknown_type")); //$NON-NLS-1$ } - public String getDetailTypeName(Target target, String typename) throws CDIException { + public String getDetailTypeName(ICDIStackFrame frame, String typename) throws CDIException { + Target target = (Target)frame.getTarget(); + ICDIThread currentThread = target.getCurrentThread(); + ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); + target.setCurrentThread(currentThread, false); + frame.getThread().setCurrentStackFrame(frame, false); try { MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); @@ -465,10 +475,18 @@ public class SourceManager extends Manager implements ICDISourceManager { return info.getType(); } catch (MIException e) { throw new MI2CDIException(e); + } finally { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); } } - public String getTypeName(Target target, String variable) throws CDIException { + public String getTypeName(ICDIStackFrame frame, String variable) throws CDIException { + Target target = (Target)frame.getTarget(); + ICDIThread currentThread = target.getCurrentThread(); + ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); + target.setCurrentThread(currentThread, false); + frame.getThread().setCurrentStackFrame(frame, false); try { MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); @@ -481,6 +499,9 @@ public class SourceManager extends Manager implements ICDISourceManager { return info.getType(); } catch (MIException e) { throw new MI2CDIException(e); + } finally { + target.setCurrentThread(currentThread, false); + currentThread.setCurrentStackFrame(currentFrame, false); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java index 712ca708657..d32f04f3a13 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java @@ -161,22 +161,23 @@ public class VariableObject extends CObject implements ICDIVariableObject { public ICDIType getType() throws CDIException { if (type == null) { Target target = (Target)getTarget(); + ICDIStackFrame frame = getStackFrame(); Session session = (Session) (target.getSession()); SourceManager sourceMgr = (SourceManager) session.getSourceManager(); - String nametype = sourceMgr.getTypeName(target, getQualifiedName()); + String nametype = sourceMgr.getTypeName(frame, getQualifiedName()); try { type = sourceMgr.getType(target, nametype); } catch (CDIException e) { // Try with ptype. try { - String ptype = sourceMgr.getDetailTypeName(target, nametype); + String ptype = sourceMgr.getDetailTypeName(frame, nametype); type = sourceMgr.getType(target, 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(target, getQualifiedName()); + String ptype = sourceMgr.getDetailTypeName(frame, getQualifiedName()); type = sourceMgr.getType(target, ptype); } catch (CDIException e2) { // give up. diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DerivedType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DerivedType.java index ce7b77a31c7..69f7acf0f49 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DerivedType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DerivedType.java @@ -41,7 +41,9 @@ public abstract class DerivedType extends Type implements ICDIDerivedType { } catch (CDIException e) { // Try after ptype. try { - String ptype = sourceMgr.getDetailTypeName(target, name); + //String ptype = sourceMgr.getDetailTypeName(target, name); + // TODO: this type should be created with frames not targets. + String ptype = sourceMgr.getDetailTypeName(target.getCurrentThread().getCurrentStackFrame(), name); derivedType = sourceMgr.getType(target, ptype); } catch (CDIException ex) { }