1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Set the correct stackframe

This commit is contained in:
Alain Magloire 2004-09-15 21:53:50 +00:00
parent bc6ac94fde
commit 98e5f30131
3 changed files with 30 additions and 6 deletions

View file

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

View file

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

View file

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