mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
Variable manager in terms of MI Var Object.
This commit is contained in:
parent
c6df90506c
commit
4c8ccddf38
9 changed files with 85 additions and 198 deletions
|
@ -42,62 +42,17 @@ import org.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo;
|
||||||
*/
|
*/
|
||||||
public class CTarget implements ICDITarget {
|
public class CTarget implements ICDITarget {
|
||||||
|
|
||||||
List threadList;
|
|
||||||
CSession session;
|
CSession session;
|
||||||
CThread dummyThread; // Dummy for non multi-thread programs.
|
//CThread dummyThread = new CThread(this, 0); // Dummy for non multi-thread programs.
|
||||||
CThread currentThread;
|
|
||||||
|
|
||||||
public CTarget(CSession s) {
|
public CTarget(CSession s) {
|
||||||
session = s;
|
session = s;
|
||||||
threadList = new ArrayList(1);
|
|
||||||
dummyThread = new CThread(this, 1);
|
|
||||||
currentThread = dummyThread;
|
|
||||||
threadList.add(dummyThread);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSession getCSession() {
|
CSession getCSession() {
|
||||||
return session;
|
return session;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addCThread(CThread cthread) {
|
|
||||||
threadList.add(cthread);
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeCThread(CThread cthread) {
|
|
||||||
threadList.remove(cthread);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCurrentThread(int id) {
|
|
||||||
CThread cthread = null;
|
|
||||||
if (containsCThread(id)) {
|
|
||||||
for (int i = 0; i < threadList.size(); i++) {
|
|
||||||
CThread thread = (CThread)threadList.get(i);
|
|
||||||
if (thread.getId() == id) {
|
|
||||||
cthread = thread;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cthread = new CThread(this, id);
|
|
||||||
addCThread(cthread);
|
|
||||||
}
|
|
||||||
currentThread = cthread;
|
|
||||||
}
|
|
||||||
|
|
||||||
boolean containsCThread(int id) {
|
|
||||||
for (int i = 0; i < threadList.size(); i++) {
|
|
||||||
CThread cthread = (CThread)threadList.get(i);
|
|
||||||
if (cthread.getId() == id) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CThread[] getCThreads() {
|
|
||||||
return (CThread[])threadList.toArray(new CThread[threadList.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#disconnect()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#disconnect()
|
||||||
*/
|
*/
|
||||||
|
@ -170,18 +125,15 @@ public class CTarget implements ICDITarget {
|
||||||
return new ICDISharedLibrary[0];
|
return new ICDISharedLibrary[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public CThread getCurrentThread() throws CDIException {
|
|
||||||
return currentThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public void setCurrentThread(CThread cthread) throws CDIException {
|
public void setCurrentThread(CThread cthread) throws CDIException {
|
||||||
session.setCurrentTarget(this);
|
session.setCurrentTarget(this);
|
||||||
int id = cthread.getId();
|
int id = cthread.getId();
|
||||||
session.setCurrentTarget(this);
|
// No need to set thread id 0, it is a dummy thread.
|
||||||
|
if (id == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
MISession mi = session.getMISession();
|
MISession mi = session.getMISession();
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
MIThreadSelect select = factory.createMIThreadSelect(id);
|
MIThreadSelect select = factory.createMIThreadSelect(id);
|
||||||
|
@ -192,13 +144,13 @@ public class CTarget implements ICDITarget {
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
}
|
}
|
||||||
setCurrentThread(id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getThreads()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getThreads()
|
||||||
*/
|
*/
|
||||||
public ICDIThread[] getThreads() throws CDIException {
|
public ICDIThread[] getThreads() throws CDIException {
|
||||||
|
ICDIThread[] cdiThreads;
|
||||||
MISession mi = session.getMISession();
|
MISession mi = session.getMISession();
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
MIThreadListIds tids = factory.createMIThreadListIds();
|
MIThreadListIds tids = factory.createMIThreadListIds();
|
||||||
|
@ -207,18 +159,18 @@ public class CTarget implements ICDITarget {
|
||||||
MIThreadListIdsInfo info = tids.getMIThreadListIdsInfo();
|
MIThreadListIdsInfo info = tids.getMIThreadListIdsInfo();
|
||||||
int[] ids = info.getThreadIds();
|
int[] ids = info.getThreadIds();
|
||||||
if (ids != null && ids.length > 0) {
|
if (ids != null && ids.length > 0) {
|
||||||
|
cdiThreads = new ICDIThread[ids.length];
|
||||||
// Ok that means it is a multiThreaded, remove the dummy Thread
|
// Ok that means it is a multiThreaded, remove the dummy Thread
|
||||||
//removeCThread(dummyThread);
|
|
||||||
for (int i = 0; i < ids.length; i++) {
|
for (int i = 0; i < ids.length; i++) {
|
||||||
if (! containsCThread(ids[i])) {
|
cdiThreads[i] = new CThread(this, ids[i]);
|
||||||
addCThread(new CThread(this, ids[i]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cdiThreads = new ICDIThread[]{new CThread(this, 0)};
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
}
|
}
|
||||||
return (ICDIThread[])getCThreads();
|
return cdiThreads;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -437,9 +389,7 @@ public class CTarget implements ICDITarget {
|
||||||
*/
|
*/
|
||||||
public ICDIValue evaluateExpressionToValue(String expressionText)
|
public ICDIValue evaluateExpressionToValue(String expressionText)
|
||||||
throws CDIException {
|
throws CDIException {
|
||||||
VariableManager mgr = session.getVariableManager();
|
return null;
|
||||||
ICDIVariable var = mgr.createVariable(expressionText);
|
|
||||||
return var.getValue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.eclipse.cdt.debug.mi.core.output.MIStackListFramesInfo;
|
||||||
public class CThread extends CObject implements ICDIThread {
|
public class CThread extends CObject implements ICDIThread {
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
StackFrame currentStackFrame;
|
|
||||||
|
|
||||||
public CThread(CTarget target, int threadId) {
|
public CThread(CTarget target, int threadId) {
|
||||||
super(target);
|
super(target);
|
||||||
|
@ -56,9 +55,6 @@ public class CThread extends CObject implements ICDIThread {
|
||||||
StackFrame[] stack = new StackFrame[miFrames.length];
|
StackFrame[] stack = new StackFrame[miFrames.length];
|
||||||
for (int i = 0; i < stack.length; i++) {
|
for (int i = 0; i < stack.length; i++) {
|
||||||
stack[i] = new StackFrame(this, miFrames[i]);
|
stack[i] = new StackFrame(this, miFrames[i]);
|
||||||
if (i == 0) {
|
|
||||||
currentStackFrame = stack[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
|
@ -81,18 +77,11 @@ public class CThread extends CObject implements ICDIThread {
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
throw new CDIException("No answer");
|
throw new CDIException("No answer");
|
||||||
}
|
}
|
||||||
currentStackFrame = (StackFrame)stackframe;
|
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
public StackFrame getCurrentStackFrame() throws CDIException {
|
|
||||||
return currentStackFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#isSuspended()
|
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIThread#isSuspended()
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
|
import org.eclipse.cdt.debug.core.cdi.event.ICDIChangedEvent;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
* @author alain
|
||||||
|
@ -15,18 +14,18 @@ import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||||
public class ChangedEvent implements ICDIChangedEvent {
|
public class ChangedEvent implements ICDIChangedEvent {
|
||||||
|
|
||||||
CSession session;
|
CSession session;
|
||||||
MIEvent event;
|
ICDIObject source;
|
||||||
|
|
||||||
public ChangedEvent(CSession s, MIEvent e) {
|
public ChangedEvent(CSession s, ICDIObject src) {
|
||||||
session = s;
|
session = s;
|
||||||
event = e;
|
source = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
||||||
*/
|
*/
|
||||||
public ICDIObject getSource() {
|
public ICDIObject getSource() {
|
||||||
return null;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.event.ICDIDestroyedEvent;
|
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.ICDIObject;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIExitEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
* @author alain
|
||||||
|
@ -14,19 +13,19 @@ import org.eclipse.cdt.debug.mi.core.event.MIExitEvent;
|
||||||
*/
|
*/
|
||||||
public class DestroyedEvent implements ICDIDestroyedEvent {
|
public class DestroyedEvent implements ICDIDestroyedEvent {
|
||||||
|
|
||||||
MIExitEvent event;
|
|
||||||
CSession session;
|
CSession session;
|
||||||
|
ICDIObject source;
|
||||||
|
|
||||||
public DestroyedEvent(CSession s, MIExitEvent e) {
|
public DestroyedEvent(CSession s, ICDIObject src) {
|
||||||
session = s;
|
session = s;
|
||||||
event = e;
|
source = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource()
|
||||||
*/
|
*/
|
||||||
public ICDIObject getSource() {
|
public ICDIObject getSource() {
|
||||||
return null;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,40 +43,40 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
||||||
|
|
||||||
if (miEvent instanceof MIBreakpointEvent) {
|
if (miEvent instanceof MIBreakpointEvent) {
|
||||||
MIBreakpointEvent breakEvent = (MIBreakpointEvent)miEvent;
|
MIBreakpointEvent breakEvent = (MIBreakpointEvent)miEvent;
|
||||||
threadId = breakEvent.getThreadId();
|
//threadId = breakEvent.getThreadId();
|
||||||
session.getCTarget().setCurrentThread(threadId);
|
//session.getCTarget().setCurrentThreadId(threadId);
|
||||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||||
} else if (miEvent instanceof MIFunctionFinishedEvent) {
|
} else if (miEvent instanceof MIFunctionFinishedEvent) {
|
||||||
MIFunctionFinishedEvent funcEvent = (MIFunctionFinishedEvent)miEvent;
|
MIFunctionFinishedEvent funcEvent = (MIFunctionFinishedEvent)miEvent;
|
||||||
threadId = funcEvent.getThreadId();
|
//threadId = funcEvent.getThreadId();
|
||||||
session.getCTarget().setCurrentThread(threadId);
|
//session.getCTarget().setCurrentThreadId(threadId);
|
||||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||||
} else if (miEvent instanceof MILocationReachedEvent) {
|
} else if (miEvent instanceof MILocationReachedEvent) {
|
||||||
MILocationReachedEvent locEvent = (MILocationReachedEvent)miEvent;
|
MILocationReachedEvent locEvent = (MILocationReachedEvent)miEvent;
|
||||||
threadId = locEvent.getThreadId();
|
//threadId = locEvent.getThreadId();
|
||||||
session.getCTarget().setCurrentThread(threadId);
|
//session.getCTarget().setCurrentThreadId(threadId);
|
||||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||||
} else if (miEvent instanceof MISignalEvent) {
|
} else if (miEvent instanceof MISignalEvent) {
|
||||||
MISignalEvent sigEvent = (MISignalEvent)miEvent;
|
MISignalEvent sigEvent = (MISignalEvent)miEvent;
|
||||||
threadId = sigEvent.getThreadId();
|
//threadId = sigEvent.getThreadId();
|
||||||
session.getCTarget().setCurrentThread(threadId);
|
//session.getCTarget().setCurrentThreadId(threadId);
|
||||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||||
} else if (miEvent instanceof MISteppingRangeEvent) {
|
} else if (miEvent instanceof MISteppingRangeEvent) {
|
||||||
MISteppingRangeEvent rangeEvent = (MISteppingRangeEvent)miEvent;
|
MISteppingRangeEvent rangeEvent = (MISteppingRangeEvent)miEvent;
|
||||||
threadId = rangeEvent.getThreadId();
|
//threadId = rangeEvent.getThreadId();
|
||||||
session.getCTarget().setCurrentThread(threadId);
|
//session.getCTarget().setCurrentThreadId(threadId);
|
||||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||||
} else if (miEvent instanceof MIWatchpointEvent) {
|
} else if (miEvent instanceof MIWatchpointEvent) {
|
||||||
MIWatchpointEvent watchEvent = (MIWatchpointEvent)miEvent;
|
MIWatchpointEvent watchEvent = (MIWatchpointEvent)miEvent;
|
||||||
threadId = watchEvent.getThreadId();
|
//threadId = watchEvent.getThreadId();
|
||||||
session.getCTarget().setCurrentThread(threadId);
|
//session.getCTarget().setCurrentThreadId(threadId);
|
||||||
cdiEvent = new SuspendedEvent(session, miEvent);
|
cdiEvent = new SuspendedEvent(session, miEvent);
|
||||||
} else if (miEvent instanceof MIRunningEvent) {
|
} else if (miEvent instanceof MIRunningEvent) {
|
||||||
cdiEvent = new ResumedEvent(session, (MIRunningEvent)miEvent);
|
cdiEvent = new ResumedEvent(session, (MIRunningEvent)miEvent);
|
||||||
} else if (miEvent instanceof MIInferiorExitEvent) {
|
} else if (miEvent instanceof MIInferiorExitEvent) {
|
||||||
cdiEvent = new ExitedEvent(session, (MIInferiorExitEvent)miEvent);
|
cdiEvent = new ExitedEvent(session, (MIInferiorExitEvent)miEvent);
|
||||||
} else if (miEvent instanceof MIExitEvent) {
|
} else if (miEvent instanceof MIExitEvent) {
|
||||||
cdiEvent = new DestroyedEvent(session, (MIExitEvent)miEvent);
|
cdiEvent = new DestroyedEvent(session, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fire the event;
|
// Fire the event;
|
||||||
|
|
|
@ -6,12 +6,6 @@ import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author alain
|
|
||||||
*
|
|
||||||
* To change this generated comment edit the template variable "typecomment":
|
|
||||||
* Window>Preferences>Java>Templates.
|
|
||||||
* To enable and disable the creation of type comments go to
|
|
||||||
* Window>Preferences>Java>Code Generation.
|
|
||||||
*/
|
*/
|
||||||
public class ExpressionManager extends SessionObject implements ICDIExpressionManager {
|
public class ExpressionManager extends SessionObject implements ICDIExpressionManager {
|
||||||
|
|
||||||
|
@ -23,7 +17,7 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createCondition(int, String)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createCondition(int, String)
|
||||||
*/
|
*/
|
||||||
public ICDICondition createCondition(int ignoreCount, String expression) {
|
public ICDICondition createCondition(int ignoreCount, String expression) {
|
||||||
return null;
|
return new Condition(ignoreCount, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,21 +31,19 @@ public class ExpressionManager extends SessionObject implements ICDIExpressionMa
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getExpressions()
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getExpressions()
|
||||||
*/
|
*/
|
||||||
public ICDIExpression[] getExpressions() throws CDIException {
|
public ICDIExpression[] getExpressions() throws CDIException {
|
||||||
return null;
|
return new ICDIExpression[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpression(ICDIExpression)
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpression(ICDIExpression)
|
||||||
*/
|
*/
|
||||||
public void removeExpression(ICDIExpression expression)
|
public void removeExpression(ICDIExpression expression) throws CDIException {
|
||||||
throws CDIException {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpressions(ICDIExpression[])
|
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpressions(ICDIExpression[])
|
||||||
*/
|
*/
|
||||||
public void removeExpressions(ICDIExpression[] expressions)
|
public void removeExpressions(ICDIExpression[] expressions) throws CDIException {
|
||||||
throws CDIException {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
package org.eclipse.cdt.debug.mi.core.cdi;
|
package org.eclipse.cdt.debug.mi.core.cdi;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
import org.eclipse.cdt.debug.core.cdi.CDIException;
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager;
|
|
||||||
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
|
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
|
||||||
import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
|
import org.eclipse.cdt.debug.core.cdi.event.ICDISuspendedEvent;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||||
|
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIFunctionFinishedEvent;
|
||||||
|
@ -13,7 +12,6 @@ import org.eclipse.cdt.debug.mi.core.event.MILocationReachedEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MISignalEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MISteppingRangeEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
import org.eclipse.cdt.debug.mi.core.event.MIWatchpointEvent;
|
||||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -79,16 +77,17 @@ public class SuspendedEvent implements ICDISuspendedEvent {
|
||||||
threadId = funcEvent.getThreadId();
|
threadId = funcEvent.getThreadId();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it came from a thread return it as the source.
|
try {
|
||||||
CThread[] cthreads = target.getCThreads();
|
// If it came from a thread return it as the source.
|
||||||
for (int i = 0; i < cthreads.length; i++) {
|
ICDIThread[] cthreads = target.getThreads();
|
||||||
if (cthreads[i].getId() == threadId) {
|
for (int i = 0; i < cthreads.length; i++) {
|
||||||
return cthreads[i];
|
if (((CThread)cthreads[i]).getId() == threadId) {
|
||||||
|
return cthreads[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} catch (CDIException e) {
|
||||||
}
|
}
|
||||||
// Not found?? new thread created?
|
|
||||||
CThread cthread = new CThread(session.getCTarget(), threadId);
|
return null;
|
||||||
target.addCThread(cthread);
|
|
||||||
return cthread;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class Value extends CObject implements ICDIValue {
|
||||||
}
|
}
|
||||||
result = info.getValue();
|
result = info.getValue();
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
//throw new CDIException(e.toString());
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ public class Value extends CObject implements ICDIValue {
|
||||||
new Variable(variable.getStackFrame(), vars[i].getExp(), vars[i]);
|
new Variable(variable.getStackFrame(), vars[i].getExp(), vars[i]);
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
//throw new CDIException(e.toString());
|
||||||
}
|
}
|
||||||
return variables;
|
return variables;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,16 @@ public class VariableManager extends SessionObject {
|
||||||
elementList = new ArrayList();
|
elementList = new ArrayList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Element getElement(String varName) {
|
||||||
|
Element[] elements = getElements();
|
||||||
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
if (elements[i].miVar.getVarName().equals(varName)) {
|
||||||
|
return elements[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
Element getElement(StackFrame stack, String name) {
|
Element getElement(StackFrame stack, String name) {
|
||||||
Element[] elements = getElements();
|
Element[] elements = getElements();
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
@ -91,22 +101,27 @@ public class VariableManager extends SessionObject {
|
||||||
}
|
}
|
||||||
MIVarChange[]changes = info.getMIVarChanges();
|
MIVarChange[]changes = info.getMIVarChanges();
|
||||||
for (int i = 0 ; i < changes.length; i++) {
|
for (int i = 0 ; i < changes.length; i++) {
|
||||||
ICDIEvent cdiEvent;
|
ICDIEvent cdiEvent = null;
|
||||||
|
Element element = getElement(changes[i].getVarName());
|
||||||
if (!changes[i].isInScope()) {
|
if (!changes[i].isInScope()) {
|
||||||
//cdiEvent = DestroyEvent(getCSession(), );
|
if (element != null) {
|
||||||
|
cdiEvent = new DestroyedEvent(getCSession(), element.variable);
|
||||||
|
}
|
||||||
removeVariable(changes[i]);
|
removeVariable(changes[i]);
|
||||||
} else {
|
} else {
|
||||||
//cdiEvent = ChangedEvent(getCSession(), );
|
if (element != null) {
|
||||||
|
cdiEvent = new ChangedEvent(getCSession(), element.variable);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//EventManager mgr = (EventManager)getCSession().getEventManager();
|
EventManager mgr = (EventManager)getCSession().getEventManager();
|
||||||
//mgr.fireEvent(cdiEvent);
|
mgr.fireEvent(cdiEvent);
|
||||||
}
|
}
|
||||||
} catch (MIException e) {
|
} catch (MIException e) {
|
||||||
throw new CDIException(e.toString());
|
throw new CDIException(e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Element createElement(StackFrame stack, String name) throws CDIException {
|
Element createElement(StackFrame stack, String name) throws CDIException {
|
||||||
Element element = getElement(stack, name);
|
Element element = getElement(stack, name);
|
||||||
if (element == null) {
|
if (element == null) {
|
||||||
stack.getCThread().setCurrentStackFrame(stack);
|
stack.getCThread().setCurrentStackFrame(stack);
|
||||||
|
@ -130,31 +145,6 @@ public class VariableManager extends SessionObject {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getVariable(String)
|
|
||||||
*/
|
|
||||||
public ICDIVariable getVariable(String name) throws CDIException {
|
|
||||||
ICDIVariable[] variables = getVariables();
|
|
||||||
for (int i = 0; i < variables.length; i++) {
|
|
||||||
if (name.equals(variables[i].getName())) {
|
|
||||||
return variables[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getVariables()
|
|
||||||
*/
|
|
||||||
public ICDIVariable[] getVariables() throws CDIException {
|
|
||||||
Element[] elements = getElements();
|
|
||||||
ICDIVariable[] variables = new ICDIVariable[elements.length];
|
|
||||||
for (int i = 0; i < elements.length; i++) {
|
|
||||||
variables[i] = elements[i].variable;
|
|
||||||
}
|
|
||||||
return variables;
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeMIVar(MIVar miVar) throws CDIException {
|
void removeMIVar(MIVar miVar) throws CDIException {
|
||||||
MISession mi = getCSession().getMISession();
|
MISession mi = getCSession().getMISession();
|
||||||
CommandFactory factory = mi.getCommandFactory();
|
CommandFactory factory = mi.getCommandFactory();
|
||||||
|
@ -167,6 +157,11 @@ public class VariableManager extends SessionObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void removeVariable(MIVarChange changed) throws CDIException {
|
||||||
|
String varName = changed.getVarName();
|
||||||
|
removeVariable(varName);
|
||||||
|
}
|
||||||
|
|
||||||
void removeVariable(String varName) throws CDIException {
|
void removeVariable(String varName) throws CDIException {
|
||||||
Element[] elements = getElements();
|
Element[] elements = getElements();
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
@ -177,53 +172,23 @@ public class VariableManager extends SessionObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeVariable(MIVarChange changed) throws CDIException {
|
void removeVariable(Variable variable) throws CDIException {
|
||||||
String varName = changed.getVarName();
|
String varName = ((Variable)variable).getMIVar().getVarName();
|
||||||
removeVariable(varName);
|
removeVariable(varName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
void removeVariables(Variable[] variables) throws CDIException {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeVariable(ICDIVariable)
|
|
||||||
*/
|
|
||||||
public void removeVariable(ICDIVariable variable) throws CDIException {
|
|
||||||
if (variable instanceof Variable) {
|
|
||||||
String varName = ((Variable)variable).getMIVar().getVarName();
|
|
||||||
removeVariable(varName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeVariable(ICDIVariable[])
|
|
||||||
*/
|
|
||||||
public void removeVariables(ICDIVariable[] variables) throws CDIException {
|
|
||||||
for (int i = 0; i < variables.length; i++) {
|
for (int i = 0; i < variables.length; i++) {
|
||||||
removeVariable(variables[i]);
|
removeVariable(variables[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
ICDIVariable createVariable(StackFrame stack, String name) throws CDIException {
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createVariable(String)
|
Element element = createElement(stack, name);
|
||||||
*/
|
Variable var = new Variable(stack, name, element.miVar);
|
||||||
public ICDIVariable createVariable(String name) throws CDIException {
|
element.variable = var;
|
||||||
ICDITarget target = getCSession().getCurrentTarget();
|
addElement(element);
|
||||||
CThread thread = ((CTarget)target).getCurrentThread();
|
return (ICDIVariable)var;
|
||||||
StackFrame stack = thread.getCurrentStackFrame();
|
|
||||||
return createVariable(stack, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createVariable(ICDIStackFrame, String)
|
|
||||||
*/
|
|
||||||
public ICDIVariable createVariable(ICDIStackFrame frame, String name) throws CDIException {
|
|
||||||
if (frame instanceof StackFrame) {
|
|
||||||
StackFrame stack = (StackFrame)frame;
|
|
||||||
Element element = createElement(stack, name);
|
|
||||||
Variable var = new Variable(stack, name, element.miVar);
|
|
||||||
element.variable = var;
|
|
||||||
addElement(element);
|
|
||||||
return var;
|
|
||||||
}
|
|
||||||
throw new CDIException("Unknow stackframe");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,11 +215,5 @@ public class VariableManager extends SessionObject {
|
||||||
addElement(element);
|
addElement(element);
|
||||||
return (ICDIRegister)reg;
|
return (ICDIRegister)reg;
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createCondition(int, String)
|
|
||||||
*/
|
|
||||||
public ICDICondition createCondition(int ignoreCount, String expression) {
|
|
||||||
return new Condition(ignoreCount, expression);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue