1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

VariableObjec takes the target as constructor argument

This commit is contained in:
Alain Magloire 2003-01-27 04:49:47 +00:00
parent a46e76ff43
commit 5bf0f9e81e
8 changed files with 56 additions and 29 deletions

View file

@ -7,14 +7,15 @@
package org.eclipse.cdt.debug.mi.core.cdi; package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDIArgumentObject; import org.eclipse.cdt.debug.core.cdi.ICDIArgumentObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame; import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame;
/** /**
*/ */
public class ArgumentObject extends VariableObject implements ICDIArgumentObject { public class ArgumentObject extends VariableObject implements ICDIArgumentObject {
public ArgumentObject(String name, StackFrame frame, int pos, int depth) { public ArgumentObject(ICDITarget target, String name, StackFrame frame, int pos, int depth) {
super(name, frame, pos, depth); super(target, name, frame, pos, depth);
} }
} }

View file

@ -51,8 +51,8 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
try { try {
Session session = (Session)getSession(); Session session = (Session)getSession();
ICDITarget currentTarget = session.getCurrentTarget(); ICDITarget currentTarget = session.getCurrentTarget();
ICDIThread currentThread = currentTarget.getCurrentThread(); //ICDIThread currentThread = currentTarget.getCurrentThread();
StackFrame currentFrame = (StackFrame)currentThread.getCurrentStackFrame(); //StackFrame currentFrame = (StackFrame)currentThread.getCurrentStackFrame();
MISession mi = session.getMISession(); MISession mi = session.getMISession();
CommandFactory factory = mi.getCommandFactory(); CommandFactory factory = mi.getCommandFactory();
MIVarCreate var = factory.createMIVarCreate(name); MIVarCreate var = factory.createMIVarCreate(name);
@ -61,7 +61,7 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
if (info == null) { if (info == null) {
throw new CDIException("No answer"); throw new CDIException("No answer");
} }
VariableObject varObj = new VariableObject(name, currentFrame, 0, 0); VariableObject varObj = new VariableObject(currentTarget, name, null, 0, 0);
expression = new Expression(varObj, info.getMIVar()); expression = new Expression(varObj, info.getMIVar());
addExpression(expression); addExpression(expression);
} catch (MIException e) { } catch (MIException e) {
@ -92,7 +92,8 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
if (info == null) { if (info == null) {
throw new CDIException("No answer"); throw new CDIException("No answer");
} }
VariableObject varObj = new VariableObject(name, (StackFrame)frame, 0, 0); ICDITarget target = frame.getThread().getTarget();
VariableObject varObj = new VariableObject(target, name, (StackFrame)frame, 0, 0);
expression = new Expression(varObj, info.getMIVar()); expression = new Expression(varObj, info.getMIVar());
addExpression(expression); addExpression(expression);
} catch (MIException e) { } catch (MIException e) {

View file

@ -56,7 +56,7 @@ public class RegisterManager extends SessionObject implements ICDIRegisterManage
String[] names = info.getRegisterNames(); String[] names = info.getRegisterNames();
RegisterObject[] regs = new RegisterObject[names.length]; RegisterObject[] regs = new RegisterObject[names.length];
for (int i = 0; i < names.length; i++) { for (int i = 0; i < names.length; i++) {
regs[i] = new RegisterObject(names[i], i); regs[i] = new RegisterObject(session.getCurrentTarget(), names[i], i);
} }
return regs; return regs;
} catch (MIException e) { } catch (MIException e) {

View file

@ -1,13 +1,14 @@
package org.eclipse.cdt.debug.mi.core.cdi; package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject; import org.eclipse.cdt.debug.core.cdi.ICDIRegisterObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
/** /**
*/ */
public class RegisterObject extends VariableObject implements ICDIRegisterObject { public class RegisterObject extends VariableObject implements ICDIRegisterObject {
public RegisterObject(String name, int i) { public RegisterObject(ICDITarget target, String name, int i) {
super(name, null, i, 0); super(target, name, null, i, 0);
} }
} }

View file

@ -77,12 +77,14 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
Variable[] vars = getVariables(); Variable[] vars = getVariables();
for (int i = 0; i < vars.length; i++) { for (int i = 0; i < vars.length; i++) {
if (vars[i].getName().equals(name)) { if (vars[i].getName().equals(name)) {
if (vars[i].getStackFrame().equals(stack)) { if (stack != null && vars[i].getStackFrame().equals(stack)) {
if (vars[i].getVariableObject().getPosition() == position) { if (vars[i].getVariableObject().getPosition() == position) {
if (vars[i].getVariableObject().getStackDepth() == depth) { if (vars[i].getVariableObject().getStackDepth() == depth) {
return vars[i]; return vars[i];
} }
} }
} else {
return vars[i];
} }
} }
} }
@ -159,13 +161,17 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
argument = (Argument)variable; argument = (Argument)variable;
} }
if (argument == null) { if (argument == null) {
StackFrame stack = argObj.getStackFrame();
String name = argObj.getName(); String name = argObj.getName();
StackFrame stack = argObj.getStackFrame();
Session session = (Session)getSession(); Session session = (Session)getSession();
ICDITarget currentTarget = session.getCurrentTarget(); Thread currentThread = null;
Thread currentThread = (Thread)currentTarget.getCurrentThread(); StackFrame currentFrame = null;
StackFrame currentFrame = (StackFrame)currentThread.getCurrentStackFrame(); if (stack != null) {
((Thread)stack.getThread()).setCurrentStackFrame(stack, false); ICDITarget currentTarget = session.getCurrentTarget();
currentThread = (Thread)currentTarget.getCurrentThread();
currentFrame = (StackFrame)currentThread.getCurrentStackFrame();
((Thread)stack.getThread()).setCurrentStackFrame(stack, false);
}
try { try {
MISession mi = session.getMISession(); MISession mi = session.getMISession();
CommandFactory factory = mi.getCommandFactory(); CommandFactory factory = mi.getCommandFactory();
@ -180,7 +186,9 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
currentThread.setCurrentStackFrame(currentFrame, false); if (currentThread != null) {
currentThread.setCurrentStackFrame(currentFrame, false);
}
} }
} }
return argument; return argument;
@ -233,8 +241,9 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
args = miFrames[0].getArgs(); args = miFrames[0].getArgs();
} }
if (args != null) { if (args != null) {
ICDITarget target = frame.getThread().getTarget();
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
ArgumentObject arg = new ArgumentObject(args[i].getName(), ArgumentObject arg = new ArgumentObject(target, args[i].getName(),
(StackFrame)frame, args.length - i, depth); (StackFrame)frame, args.length - i, depth);
argObjects.add(arg); argObjects.add(arg);
} }
@ -281,7 +290,8 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
buffer.append(function).append("::"); buffer.append(function).append("::");
} }
buffer.append(name); buffer.append(name);
return new VariableObject(buffer.toString(), null, 0, 0); ICDITarget target = getSession().getCurrentTarget();
return new VariableObject(target, buffer.toString(), null, 0, 0);
} }
/** /**
@ -310,8 +320,9 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
} }
args = info.getLocals(); args = info.getLocals();
if (args != null) { if (args != null) {
ICDITarget target = frame.getThread().getTarget();
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
VariableObject varObj = new VariableObject(args[i].getName(), VariableObject varObj = new VariableObject(target, args[i].getName(),
(StackFrame)frame, args.length - i, depth); (StackFrame)frame, args.length - i, depth);
varObjects.add(varObj); varObjects.add(varObj);
} }
@ -332,13 +343,17 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
VariableObject varObj = (VariableObject)v; VariableObject varObj = (VariableObject)v;
Variable variable = findVariable(varObj); Variable variable = findVariable(varObj);
if (variable == null) { if (variable == null) {
StackFrame stack = varObj.getStackFrame();
String name = varObj.getName(); String name = varObj.getName();
Session session = (Session)getSession(); Session session = (Session)getSession();
ICDITarget currentTarget = session.getCurrentTarget(); StackFrame stack = varObj.getStackFrame();
Thread currentThread = (Thread)currentTarget.getCurrentThread(); Thread currentThread = null;
StackFrame currentFrame = (StackFrame)currentThread.getCurrentStackFrame(); StackFrame currentFrame = null;
((Thread)stack.getThread()).setCurrentStackFrame(stack, false); if (stack != null) {
ICDITarget currentTarget = session.getCurrentTarget();
currentThread = (Thread)currentTarget.getCurrentThread();
currentFrame = (StackFrame)currentThread.getCurrentStackFrame();
((Thread)stack.getThread()).setCurrentStackFrame(stack, false);
}
try { try {
MISession mi = session.getMISession(); MISession mi = session.getMISession();
CommandFactory factory = mi.getCommandFactory(); CommandFactory factory = mi.getCommandFactory();
@ -353,7 +368,9 @@ public class VariableManager extends SessionObject implements ICDIVariableManage
} catch (MIException e) { } catch (MIException e) {
throw new MI2CDIException(e); throw new MI2CDIException(e);
} finally { } finally {
currentThread.setCurrentStackFrame(currentFrame, false); if (currentThread != null) {
currentThread.setCurrentStackFrame(currentFrame, false);
}
} }
} }
return variable; return variable;

View file

@ -6,6 +6,7 @@
package org.eclipse.cdt.debug.mi.core.cdi; package org.eclipse.cdt.debug.mi.core.cdi;
import org.eclipse.cdt.debug.core.cdi.ICDIVariableObject; import org.eclipse.cdt.debug.core.cdi.ICDIVariableObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame; import org.eclipse.cdt.debug.mi.core.cdi.model.StackFrame;
/** /**
@ -16,14 +17,19 @@ public class VariableObject implements ICDIVariableObject {
int position; int position;
StackFrame frame; StackFrame frame;
int stackdepth; int stackdepth;
ICDITarget target;
public VariableObject(String n, StackFrame stack, int pos, int depth) { public VariableObject(ICDITarget tgt, String n, StackFrame stack, int pos, int depth) {
target = tgt;
name = n; name = n;
frame = stack; frame = stack;
position = pos; position = pos;
stackdepth = depth; stackdepth = depth;
} }
public ICDITarget getTarget() {
return target;
}
public StackFrame getStackFrame() { public StackFrame getStackFrame() {
return frame; return frame;

View file

@ -112,8 +112,9 @@ public class Value extends CObject implements ICDIValue {
MIVar[] vars = info.getMIVars(); MIVar[] vars = info.getMIVars();
variables = new Variable[vars.length]; variables = new Variable[vars.length];
for (int i = 0; i < vars.length; i++) { for (int i = 0; i < vars.length; i++) {
VariableObject varObj = new VariableObject(vars[i].getExp(), VariableObject varObj = new VariableObject(getTarget(),
(StackFrame)variable.getStackFrame(), variable.getVariableObject().getPosition(), vars[i].getExp(), (StackFrame)variable.getStackFrame(),
variable.getVariableObject().getPosition(),
variable.getVariableObject().getStackDepth()); variable.getVariableObject().getStackDepth());
variables[i] = mgr.createVariable(varObj, vars[i]); variables[i] = mgr.createVariable(varObj, vars[i]);

View file

@ -33,7 +33,7 @@ public class Variable extends CObject implements ICDIVariable {
VariableObject varObj; VariableObject varObj;
public Variable(VariableObject obj, MIVar v) { public Variable(VariableObject obj, MIVar v) {
super(obj.getStackFrame().getTarget()); super(obj.getTarget());
miVar = v; miVar = v;
varObj = obj; varObj = obj;
} }