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 c905ce02376..55b31c5df4d 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 @@ -11,20 +11,17 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDICatchEvent; import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; -import org.eclipse.cdt.debug.core.cdi.model.ICDICatchpoint; +import org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint; @@ -361,13 +358,6 @@ public class BreakpointManager extends Manager { } } - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteAllBreakpoints() - */ - public void deleteAllBreakpoints() throws CDIException { - deleteBreakpoints(getBreakpoints()); - } - public void deleteAllBreakpoints(Target target) throws CDIException { List bList = (List)breakMap.get(target); if (bList != null) { @@ -383,15 +373,6 @@ public class BreakpointManager extends Manager { deleteBreakpoints((Target)breakpoint.getTarget(), new ICDIBreakpoint[] { breakpoint }); } - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteBreakpoints(ICDIBreakpoint[]) - */ - public void deleteBreakpoints(ICDIBreakpoint[] breakpoints) throws CDIException { - for (int i = 0; i < breakpoints.length; ++i) { - deleteBreakpoint(breakpoints[i]); - } - } - public void deleteBreakpoints(Target target, ICDIBreakpoint[] breakpoints) throws CDIException { int[] numbers = new int[breakpoints.length]; List bList = (List)breakMap.get(target); @@ -444,17 +425,6 @@ public class BreakpointManager extends Manager { return EMPTY_BREAKPOINTS; } - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#getBreakpoints() - */ - public ICDIBreakpoint[] getBreakpoints() throws CDIException { - Collection col = breakMap.values(); - Iterator itr = breakMap.values().iterator(); - ICDIBreakpoint[] bps = new ICDIBreakpoint[col.size()]; - col.toArray(bps); - return bps; - } - public ICDIBreakpoint[] getDeferredBreakpoints(Target target) throws CDIException { List dlist = (List)deferredMap.get(target); if (dlist != null) { @@ -465,33 +435,6 @@ public class BreakpointManager extends Manager { return EMPTY_BREAKPOINTS; } - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setCatchpoint(int, ICDICatchEvent, String, ICDICondition, boolean) - */ - public ICDICatchpoint setCatchpoint( int type, ICDICatchEvent event, String expression, - ICDICondition condition) throws CDIException { - throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_Supported")); //$NON-NLS-1$ - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setLocationBreakpoint(int, ICDILocation, ICDICondition, boolean, String) - */ - public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, - ICDICondition condition, String threadId) throws CDIException { - return setLocationBreakpoint(type, location, condition, threadId, false); - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setLocationBreakpoint(int, ICDILocation, ICDICondition, boolean, String) - */ - public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, - ICDICondition condition, String threadId, boolean deferred) throws CDIException { - - Session session = (Session)getSession(); - Target target = (Target)session.getCurrentTarget(); - return setLocationBreakpoint(target, type, location, condition, threadId, deferred); - } - public ICDILocationBreakpoint setLocationBreakpoint(Target target, int type, ICDILocation location, ICDICondition condition, String threadId, boolean deferred) throws CDIException { @@ -598,14 +541,6 @@ public class BreakpointManager extends Manager { bkpt.setMIBreakpoint(points[0]); } - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setWatchpoint(int, int, String, ICDICondition, boolean) - */ - public ICDIWatchpoint setWatchpoint(int type, int watchType, String expression, - ICDICondition condition) throws CDIException { - Target target = (Target)getSession().getCurrentTarget(); - return setWatchpoint(target, type, watchType, expression, condition); - } public ICDIWatchpoint setWatchpoint(Target target, int type, int watchType, String expression, ICDICondition condition) throws CDIException { @@ -644,6 +579,11 @@ public class BreakpointManager extends Manager { return bkpt; } + public ICDIExceptionpoint setExceptionpoint(Target target, String clazz, boolean stopOnThrow, + boolean stopOnCatch) throws CDIException { + return null; + } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#createCondition(int, String) */ 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 ed1e84ee197..143c03f982c 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 @@ -54,6 +54,7 @@ import org.eclipse.cdt.debug.mi.core.event.MIDestroyedEvent; import org.eclipse.cdt.debug.mi.core.event.MIDetachedEvent; import org.eclipse.cdt.debug.mi.core.event.MIEvent; import org.eclipse.cdt.debug.mi.core.event.MIGDBExitEvent; +import org.eclipse.cdt.debug.mi.core.event.MIInferiorCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIInferiorSignalExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIMemoryChangedEvent; @@ -163,7 +164,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs } else if (miEvent instanceof MIGDBExitEvent) { cdiList.add(new DestroyedEvent(session)); } else if (miEvent instanceof MIDetachedEvent) { - cdiList.add(new DisconnectedEvent(session)); + cdiList.add(new DisconnectedEvent(session, (MIDetachedEvent)miEvent)); } else if (miEvent instanceof MIBreakpointDeletedEvent) { MIBreakpointDeletedEvent bpoint = (MIBreakpointDeletedEvent)miEvent; if (bpoint.getNumber() > 0) { @@ -204,6 +205,8 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs cdiList.add(new CreatedEvent(session, (MIMemoryCreatedEvent)miEvent)); } else if (miEvent instanceof MISharedLibCreatedEvent) { cdiList.add(new CreatedEvent(session, (MISharedLibCreatedEvent)miEvent)); + } else if (miEvent instanceof MIInferiorCreatedEvent) { + cdiList.add(new CreatedEvent(session, (MIInferiorCreatedEvent)miEvent)); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java index e60c5f7e26a..045285230de 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java @@ -131,12 +131,11 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ public ICDIExpression createExpression(ICDIStackFrame frame, String name) throws CDIException { Expression expression = null; Session session = (Session)getSession(); - ICDITarget currentTarget = session.getCurrentTarget(); - ICDIThread currentThread = currentTarget.getCurrentThread(); + Target target = (Target)frame.getTarget(); + ICDIThread currentThread = target.getCurrentThread(); ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); frame.getThread().setCurrentStackFrame(frame, false); try { - Target target = (Target)frame.getThread().getTarget(); MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarCreate var = factory.createMIVarCreate(name); diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ProcessManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ProcessManager.java index e1cc0a4a3e5..b9152729b2b 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ProcessManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ProcessManager.java @@ -5,51 +5,104 @@ */ package org.eclipse.cdt.debug.mi.core.cdi; -import java.util.HashMap; +import java.util.Vector; import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; +import org.eclipse.cdt.debug.mi.core.event.MIInferiorCreatedEvent; +import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent; /** */ public class ProcessManager extends Manager { - static final Target[] noProcess = new Target[0]; - - HashMap processMap; - - class ProcessSet { - Target[] currentProcs; - int currentProcessId; - ProcessSet(Target[] procs, int id) { - currentProcs = procs; - currentProcessId = id; - } - } + static final Target[] EMPTY_TARGETS = new Target[0]; + Vector debugTargetList; + Target currentTarget; public ProcessManager(Session session) { super(session, true); - processMap = new HashMap(); + debugTargetList = new Vector(1); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIProcessManager#getProcesses() */ - public Target[] getProcesses(Session session) throws CDIException { - ProcessSet set = (ProcessSet)processMap.get(session); - if (set == null) { - set = getProcessSet(session); - processMap.put(session, set); - } - return set.currentProcs; + public Target[] getTargets() { + return (Target[]) debugTargetList.toArray(new Target[debugTargetList.size()]); } - protected ProcessSet getProcessSet(Session session) throws CDIException { - //Target[] cprocs = new Target[] {new Target((Session)session)}; - //return new ProcessSet(cprocs, 0); + public ICDITarget[] getCDITargets() { + return (ICDITarget[]) debugTargetList.toArray(new ICDITarget[debugTargetList.size()]); + } + + public void addTargets(Target[] targets, Target current) { + EventManager eventManager = (EventManager)getSession().getEventManager(); + for (int i = 0; i < targets.length; ++i) { + Target target = targets[i]; + MISession miSession = target.getMISession(); + if (miSession != null) { + miSession.addObserver(eventManager); + miSession.fireEvent(new MIInferiorCreatedEvent(miSession, 0)); + if (!debugTargetList.contains(target)) { + debugTargetList.add(target); + } + } + } + if (current != null && debugTargetList.contains(current)) { + currentTarget = current; + } + debugTargetList.trimToSize(); + } + + public void removeTargets(Target[] targets) { + EventManager eventManager = (EventManager)getSession().getEventManager(); + for (int i = 0; i < targets.length; ++i) { + Target target = targets[i]; + MISession miSession = target.getMISession(); + if (miSession != null) { + miSession.notifyObservers(new MIInferiorExitEvent(miSession, 0)); + miSession.deleteObserver(eventManager); + } + if (currentTarget != null && currentTarget.equals(target)) { + currentTarget = null; + } + debugTargetList.remove(target); + } + debugTargetList.trimToSize(); + } + + public Target getTarget(MISession miSession) { + synchronized(debugTargetList) { + for (int i = 0; i < debugTargetList.size(); ++i) { + Target target = (Target)debugTargetList.get(i); + MISession mi = target.getMISession(); + if (mi.equals(miSession)) { + return target; + } + } + } + // ASSERT: it should not happen. return null; } + /** + * @deprecated + * @return + */ + public Target getCurrentTarget() { + return currentTarget; + } + + /** + * @deprecated + * @param current + */ + public void setCurrentTarget(Target current) { + currentTarget = current; + } /** * @deprecated * @see org.eclipse.cdt.derug.core.cdi.ICDIManager#update() diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Session.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Session.java index b8aaf571267..6f8ffb489e7 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Session.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/Session.java @@ -11,8 +11,6 @@ package org.eclipse.cdt.debug.mi.core.cdi; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Properties; import org.eclipse.cdt.debug.core.cdi.CDIException; @@ -42,6 +40,7 @@ public class Session implements ICDISession, ICDISessionObject { public final static Target[] EMPTY_TARGETS = {}; Properties props; + ProcessManager processManager; EventManager eventManager; BreakpointManager breakpointManager; ExpressionManager expressionManager; @@ -52,8 +51,6 @@ public class Session implements ICDISession, ICDISessionObject { SignalManager signalManager; SourceManager sourceManager; ICDIConfiguration configuration; - Target[] debugTargets = EMPTY_TARGETS; - Target currentTarget; public Session(MISession miSession, boolean attach) { commonSetup(); @@ -79,6 +76,7 @@ public class Session implements ICDISession, ICDISessionObject { private void commonSetup() { props = new Properties(); + processManager = new ProcessManager(this); breakpointManager = new BreakpointManager(this); eventManager = new EventManager(this); expressionManager = new ExpressionManager(this); @@ -91,44 +89,27 @@ public class Session implements ICDISession, ICDISessionObject { } public void addTargets(Target[] targets, Target current) { - Target[] newTargets = new Target[debugTargets.length + targets.length]; - System.arraycopy(debugTargets, 0, newTargets, 0, debugTargets.length); - System.arraycopy(targets, 0, newTargets, debugTargets.length, targets.length); - if (current != null) { - currentTarget = current; - } - for (int i = 0; i < targets.length; ++i) { - MISession miSession = targets[i].getMISession(); - if (miSession != null) { - miSession.addObserver((EventManager)getEventManager()); - } - } + ProcessManager pMgr = getProcessManager(); + pMgr.addTargets(targets, current); } public void removeTargets(Target[] targets) { - ArrayList list = new ArrayList(Arrays.asList(debugTargets)); - for (int i = 0; i < targets.length; ++i) { - MISession miSession = targets[i].getMISession(); - if (miSession != null) { - miSession.deleteObserver((EventManager)getEventManager()); - } - if (currentTarget != null && currentTarget.equals(targets[i])) { - currentTarget = null; - } - list.remove(targets[i]); - } - debugTargets = (Target[]) list.toArray(new Target[list.size()]); + ProcessManager pMgr = getProcessManager(); + pMgr.removeTargets(targets); } public Target getTarget(MISession miSession) { - for (int i = 0; i < debugTargets.length; ++i) { - MISession mi = debugTargets[i].getMISession(); - if (mi.equals(miSession)) { - return debugTargets[i]; - } - } - // ASSERT: it should not happen. - return null; + ProcessManager pMgr = getProcessManager(); + return pMgr.getTarget(miSession); + } + + /** + * @deprecated + * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getCurrentTarget() + */ + public ICDITarget getCurrentTarget() { + ProcessManager pMgr = getProcessManager(); + return pMgr.getCurrentTarget(); } /** @@ -138,6 +119,10 @@ public class Session implements ICDISession, ICDISessionObject { return props.getProperty(key); } + public ProcessManager getProcessManager() { + return processManager; + } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getBreakpointManager() */ @@ -205,22 +190,17 @@ public class Session implements ICDISession, ICDISessionObject { * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getTargets() */ public ICDITarget[] getTargets() { - return debugTargets; - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getCurrentTarget() - */ - public ICDITarget getCurrentTarget() { - return currentTarget; + ProcessManager pMgr = getProcessManager(); + return pMgr.getCDITargets(); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDISession#setCurrentTarget() */ public void setCurrentTarget(ICDITarget target) throws CDIException { + ProcessManager pMgr = getProcessManager(); if (target instanceof Target) { - currentTarget = (Target)target; + pMgr.setCurrentTarget((Target)target); } else { throw new CDIException(CdiResources.getString("cdi.Session.Unknown_target")); //$NON-NLS-1$ } @@ -262,8 +242,10 @@ public class Session implements ICDISession, ICDISessionObject { * @see org.eclipse.cdt.debug.core.cdi.ICDISession#terminate(ICDITarget) */ public void terminate() throws CDIException { - for (int i = 0; i < debugTargets.length; ++i) { - debugTargets[i].terminate(); + ProcessManager pMgr = getProcessManager(); + Target[] targets = pMgr.getTargets(); + for (int i = 0; i < targets.length; ++i) { + targets[i].terminate(); } //TODO: the ExitEvent is sent by MISession.terminate() // We nee move it here. @@ -281,7 +263,7 @@ public class Session implements ICDISession, ICDISessionObject { * @see org.eclipse.cdt.debug.core.cdi.ICDISession#addSearchPaths(String[]) */ public void addSearchPaths(String[] dirs) throws CDIException { - addSearchPaths(currentTarget, dirs); + addSearchPaths(getCurrentTarget(), dirs); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDISession#addSearchPaths(String[]) @@ -303,7 +285,7 @@ public class Session implements ICDISession, ICDISessionObject { * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getSessionProcess() */ public Process getSessionProcess() throws CDIException { - return getSessionProcess(currentTarget); + return getSessionProcess(getCurrentTarget()); } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java index 74837ade7bd..4faf74ae691 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/VariableManager.java @@ -21,7 +21,6 @@ import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIArgument; import org.eclipse.cdt.debug.core.cdi.model.ICDIArgumentObject; 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.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; @@ -29,6 +28,7 @@ import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.model.Argument; import org.eclipse.cdt.debug.mi.core.cdi.model.ArgumentObject; +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.Variable; import org.eclipse.cdt.debug.mi.core.cdi.model.VariableObject; @@ -148,9 +148,14 @@ public class VariableManager extends Manager implements ICDIVariableManager { /** * Check the type */ - public void checkType(MISession miSession, String type) throws CDIException { + public void checkType(StackFrame frame, String type) throws CDIException { if (type != null && type.length() > 0) { + Target target = (Target)frame.getTarget(); + ICDIThread currentThread = target.getCurrentThread(); + ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); + frame.getThread().setCurrentStackFrame(frame, false); try { + MISession miSession = target.getMISession(); CommandFactory factory = miSession.getCommandFactory(); MIPType ptype = factory.createMIPType(type); miSession.postCommand(ptype); @@ -160,6 +165,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { } } catch (MIException e) { throw new MI2CDIException(e); + } finally { + currentThread.setCurrentStackFrame(currentFrame, false); } } else { throw new CDIException(CdiResources.getString("cdi.VariableManager.Unknown_type")); //$NON-NLS-1$ @@ -222,14 +229,13 @@ public class VariableManager extends Manager implements ICDIVariableManager { Session session = (Session) getSession(); ICDIThread currentThread = null; ICDIStackFrame currentFrame = null; + Target target = (Target)argObj.getTarget(); if (stack != null) { - ICDITarget currentTarget = session.getCurrentTarget(); - currentThread = currentTarget.getCurrentThread(); + currentThread = target.getCurrentThread(); currentFrame = currentThread.getCurrentStackFrame(); stack.getThread().setCurrentStackFrame(stack, false); } try { - Target target = (Target)argObj.getTarget(); MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarCreate var = factory.createMIVarCreate(name); @@ -260,12 +266,11 @@ public class VariableManager extends Manager implements ICDIVariableManager { public ICDIArgumentObject[] getArgumentObjects(ICDIStackFrame frame) throws CDIException { List argObjects = new ArrayList(); Session session = (Session) getSession(); - ICDITarget currentTarget = session.getCurrentTarget(); - ICDIThread currentThread = currentTarget.getCurrentThread(); + Target target = (Target)frame.getTarget(); + ICDIThread currentThread = target.getCurrentThread(); ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); frame.getThread().setCurrentStackFrame(frame, false); try { - Target target = (Target)frame.getTarget(); MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); int depth = frame.getThread().getStackFrameCount(); @@ -361,7 +366,7 @@ public class VariableManager extends Manager implements ICDIVariableManager { if (obj != null) { // throw an exception if not a good type. Target target = (Target)obj.getTarget(); - checkType(target.getMISession(), type); + checkType((StackFrame)obj.getStackFrame(), type); VariableObject vo = new VariableObject( target, @@ -386,12 +391,11 @@ public class VariableManager extends Manager implements ICDIVariableManager { public ICDIVariableObject[] getLocalVariableObjects(ICDIStackFrame frame) throws CDIException { List varObjects = new ArrayList(); Session session = (Session) getSession(); - ICDITarget currentTarget = session.getCurrentTarget(); - ICDIThread currentThread = currentTarget.getCurrentThread(); + Target target = (Target)frame.getTarget(); + ICDIThread currentThread = target.getCurrentThread(); ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); frame.getThread().setCurrentStackFrame(frame, false); try { - Target target = (Target)frame.getTarget(); MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); int level = frame.getLevel(); @@ -445,14 +449,13 @@ public class VariableManager extends Manager implements ICDIVariableManager { ICDIStackFrame stack = varObj.getStackFrame(); ICDIThread currentThread = null; ICDIStackFrame currentFrame = null; + Target target = (Target)varObj.getTarget(); if (stack != null) { - ICDITarget currentTarget = session.getCurrentTarget(); - currentThread = currentTarget.getCurrentThread(); + currentThread = target.getCurrentThread(); currentFrame = currentThread.getCurrentStackFrame(); stack.getThread().setCurrentStackFrame(stack, false); } try { - Target target = (Target)varObj.getTarget(); MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarCreate var = factory.createMIVarCreate(name); diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ChangedEvent.java index d88a0a51030..1c93eae0ea9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ChangedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ChangedEvent.java @@ -15,6 +15,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary; import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; +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; import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager; @@ -43,69 +44,79 @@ public class ChangedEvent implements ICDIChangedEvent { // Try the Variable manager. VariableManager mgr = (VariableManager)session.getVariableManager(); String varName = var.getVarName(); - source = mgr.getVariable(var.getMISession(), varName); + MISession miSession = var.getMISession(); + source = mgr.getVariable(miSession, varName); // Try the Expression manager if (source == null) { ExpressionManager expMgr = (ExpressionManager)session.getExpressionManager(); - source = expMgr.getExpression(var.getMISession(), varName); + source = expMgr.getExpression(miSession, varName); } // Try the Register manager if (source == null) { RegisterManager regMgr = (RegisterManager)session.getRegisterManager(); - source = regMgr.getRegister(var.getMISession(), varName); + source = regMgr.getRegister(miSession, varName); } // Fall back if (source == null) { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } - public ChangedEvent(Session s, MIRegisterChangedEvent var) { + public ChangedEvent(Session s, MIRegisterChangedEvent reg) { session = s; RegisterManager mgr = (RegisterManager)session.getRegisterManager(); - int regno = var.getNumber(); - source = mgr.getRegister(var.getMISession(), regno); + MISession miSession = reg.getMISession(); + int regno = reg.getNumber(); + source = mgr.getRegister(miSession, regno); if (source == null) { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } public ChangedEvent(Session s, MIBreakpointChangedEvent bpoint) { session = s; - BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager(); + BreakpointManager mgr = session.getBreakpointManager(); + MISession miSession = bpoint.getMISession(); int number = bpoint.getNumber(); - ICDIBreakpoint breakpoint = mgr.getBreakpoint(bpoint.getMISession(), number); + ICDIBreakpoint breakpoint = mgr.getBreakpoint(miSession, number); if (breakpoint != null) { source = breakpoint; } else { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } public ChangedEvent(Session s, MISharedLibChangedEvent slib) { session = s; SharedLibraryManager mgr = (SharedLibraryManager)session.getSharedLibraryManager(); + MISession miSession = slib.getMISession(); String name = slib.getName(); - ICDISharedLibrary lib = mgr.getSharedLibrary(slib.getMISession(), name); + ICDISharedLibrary lib = mgr.getSharedLibrary(miSession, name); if (lib != null) { source = lib; } else { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } public ChangedEvent(Session s, MISignalChangedEvent sig) { session = s; SignalManager mgr = (SignalManager)session.getSignalManager(); + MISession miSession = sig.getMISession(); String name = sig.getName(); - ICDISignal signal = mgr.getSignal(sig.getMISession(), name); + ICDISignal signal = mgr.getSignal(miSession, name); if (signal != null) { source = signal; } else { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/CreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/CreatedEvent.java index 3190a66a4a1..94e855d61c4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/CreatedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/CreatedEvent.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.mi.core.cdi.event; import org.eclipse.cdt.debug.core.cdi.event.ICDICreatedEvent; import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; +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.MemoryManager; import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager; @@ -22,6 +23,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.VariableManager; import org.eclipse.cdt.debug.mi.core.cdi.model.CObject; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent; +import org.eclipse.cdt.debug.mi.core.event.MIInferiorCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIMemoryCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MIRegisterCreatedEvent; import org.eclipse.cdt.debug.mi.core.event.MISharedLibCreatedEvent; @@ -37,47 +39,61 @@ public class CreatedEvent implements ICDICreatedEvent { public CreatedEvent(Session s, MIBreakpointCreatedEvent bpoint) { session = s; - BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager(); + BreakpointManager mgr = session.getBreakpointManager(); + MISession miSession = bpoint.getMISession(); int number = bpoint.getNumber(); - source = mgr.getBreakpoint(bpoint.getMISession(), number); + source = mgr.getBreakpoint(miSession, number); if (source == null) { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } public CreatedEvent(Session s, MIVarCreatedEvent var) { session = s; VariableManager mgr = (VariableManager)session.getVariableManager(); + MISession miSession = var.getMISession(); String varName = var.getVarName(); - source = mgr.getVariable(var.getMISession(), varName); + source = mgr.getVariable(miSession, varName); if (source == null) { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } - public CreatedEvent(Session s, MIRegisterCreatedEvent var) { + public CreatedEvent(Session s, MIRegisterCreatedEvent reg) { session = s; RegisterManager mgr = (RegisterManager)session.getRegisterManager(); - int regno = var.getNumber(); - source = mgr.getRegister(var.getMISession(), regno); + MISession miSession = reg.getMISession(); + int regno = reg.getNumber(); + source = mgr.getRegister(miSession, regno); if (source == null) { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } - public CreatedEvent(Session s, MIThreadCreatedEvent ethread) { + public CreatedEvent(Session s, MIThreadCreatedEvent cthread) { session = s; - Target target = (Target)session.getCurrentTarget(); - source = target.getThread(ethread.getId()); + MISession miSession = cthread.getMISession(); + Target target = session.getTarget(miSession); + source = target.getThread(cthread.getId()); if (source == null) { - source = new CObject((Target)session.getCurrentTarget()); + source = new CObject(target); } } + public CreatedEvent(Session s, MIInferiorCreatedEvent inferior) { + session = s; + MISession miSession = inferior.getMISession(); + source = session.getTarget(miSession); + } + public CreatedEvent(Session s, MIMemoryCreatedEvent mblock) { session = s; MemoryManager mgr = (MemoryManager)session.getMemoryManager(); - ICDIMemoryBlock[] blocks = mgr.getMemoryBlocks(mblock.getMISession()); + MISession miSession = mblock.getMISession(); + ICDIMemoryBlock[] blocks = mgr.getMemoryBlocks(miSession); for (int i = 0; i < blocks.length; i++) { if (blocks[i].getStartAddress() == mblock.getAddress() && blocks[i].getLength() == mblock.getLength()) { @@ -86,17 +102,20 @@ public class CreatedEvent implements ICDICreatedEvent { } } if (source == null) { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } public CreatedEvent(Session s, MISharedLibCreatedEvent slib) { session = s; SharedLibraryManager mgr = (SharedLibraryManager)session.getSharedLibraryManager(); + MISession miSession = slib.getMISession(); String name = slib.getName(); - source = mgr.getSharedLibrary(slib.getMISession(), name); + source = mgr.getSharedLibrary(miSession, name); if (source == null) { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } 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 4884c800940..77bd1a8b0f4 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 @@ -14,6 +14,7 @@ import org.eclipse.cdt.debug.core.cdi.CDIException; 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; import org.eclipse.cdt.debug.mi.core.cdi.Session; @@ -36,60 +37,67 @@ public class DestroyedEvent implements ICDIDestroyedEvent { Session session; ICDIObject source; - public DestroyedEvent(Session s, MIThreadExitEvent ethread) { + public DestroyedEvent(Session s, MIThreadExitEvent cthread) { session = s; - source = new Thread((Target)session.getCurrentTarget(), ethread.getId()); + Target target = session.getTarget(cthread.getMISession()); + source = new Thread(target, cthread.getId()); } public DestroyedEvent(Session s, MIVarDeletedEvent var) { session = s; VariableManager varMgr = (VariableManager)session.getVariableManager(); + MISession miSession = var.getMISession(); String varName = var.getVarName(); - Variable variable = varMgr.getVariable(var.getMISession(), varName); + Variable variable = varMgr.getVariable(miSession, varName); if (variable!= null) { source = variable; try { - varMgr.removeVariable(var.getMISession(), variable.getMIVar().getVarName()); + varMgr.removeVariable(miSession, variable.getMIVar().getVarName()); } catch (CDIException e) { } } else { ExpressionManager expMgr = (ExpressionManager)session.getExpressionManager(); - variable = expMgr.getExpression(var.getMISession(), varName); + variable = expMgr.getExpression(miSession, varName); if (variable != null) { source = variable; try { - expMgr.removeExpression(var.getMISession(), variable.getMIVar().getVarName()); + expMgr.removeExpression(miSession, variable.getMIVar().getVarName()); } catch (CDIException e) { } } else { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } } public DestroyedEvent(Session s, MIBreakpointDeletedEvent bpoint) { session = s; - BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager(); + BreakpointManager mgr = session.getBreakpointManager(); + MISession miSession = bpoint.getMISession(); int number = bpoint.getNumber(); - Breakpoint breakpoint = mgr.getBreakpoint(bpoint.getMISession(), number); + Breakpoint breakpoint = mgr.getBreakpoint(miSession, number); if (breakpoint != null) { source = breakpoint; - mgr.deleteBreakpoint(bpoint.getMISession(), number); + mgr.deleteBreakpoint(miSession, number); } else { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } public DestroyedEvent(Session s, MISharedLibUnloadedEvent slib) { session = s; SharedLibraryManager mgr = (SharedLibraryManager)session.getSharedLibraryManager(); + MISession miSession = slib.getMISession(); String name = slib.getName(); - ICDISharedLibrary lib = mgr.getSharedLibrary(slib.getMISession(), name); + ICDISharedLibrary lib = mgr.getSharedLibrary(miSession, name); if (lib != null) { - mgr.deleteSharedLibrary(slib.getMISession(), lib); + mgr.deleteSharedLibrary(miSession, lib); source = lib; } else { - source = new CObject((Target)session.getCurrentTarget()); + Target target = session.getTarget(miSession); + source = new CObject(target); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DisconnectedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DisconnectedEvent.java index d4bbf9b6566..e2e83cc23fc 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DisconnectedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/DisconnectedEvent.java @@ -14,6 +14,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.event; import org.eclipse.cdt.debug.core.cdi.event.ICDIDisconnectedEvent; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.mi.core.cdi.Session; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; +import org.eclipse.cdt.debug.mi.core.event.MIDetachedEvent; /** */ @@ -21,8 +23,9 @@ public class DisconnectedEvent implements ICDIDisconnectedEvent { ICDIObject source; - public DisconnectedEvent(Session session) { - source = session.getCurrentTarget(); + public DisconnectedEvent(Session session, MIDetachedEvent detach) { + Target target = session.getTarget(detach.getMISession()); + source = target; } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ExitedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ExitedEvent.java index 817f577668c..1da1976fe72 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ExitedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ExitedEvent.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.mi.core.cdi.ExitInfo; import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.cdi.SignalExitInfo; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.event.MIEvent; import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIInferiorSignalExitEvent; @@ -53,7 +54,8 @@ public class ExitedEvent implements ICDIExitedEvent { * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource() */ public ICDIObject getSource() { - return session.getCurrentTarget(); + Target target = session.getTarget(event.getMISession()); + return target; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java index 584e5f658ea..951ff9079d6 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/ResumedEvent.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.debug.mi.core.cdi.event; import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent; import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; import org.eclipse.cdt.debug.mi.core.cdi.Session; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent; /** @@ -31,7 +32,12 @@ public class ResumedEvent implements ICDIResumedEvent { * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource() */ public ICDIObject getSource() { - return session.getCurrentTarget(); + // We can send the target as the Source. CDI + // Will assume that all threads are supended for this. + // This is true for gdb when it suspend the inferior + // all threads are suspended. + Target target = session.getTarget(event.getMISession()); + return target; } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java index 434e9eb64b4..ac2802bba0d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/event/SuspendedEvent.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.event; import org.eclipse.cdt.debug.core.cdi.ICDISessionObject; 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.ICDITarget; import org.eclipse.cdt.debug.mi.core.cdi.BreakpointHit; import org.eclipse.cdt.debug.mi.core.cdi.EndSteppingRange; import org.eclipse.cdt.debug.mi.core.cdi.ErrorInfo; @@ -22,6 +21,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryEvent; import org.eclipse.cdt.debug.mi.core.cdi.SignalReceived; import org.eclipse.cdt.debug.mi.core.cdi.WatchpointScope; import org.eclipse.cdt.debug.mi.core.cdi.WatchpointTrigger; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointHitEvent; import org.eclipse.cdt.debug.mi.core.event.MIErrorEvent; import org.eclipse.cdt.debug.mi.core.event.MIEvent; @@ -73,7 +73,7 @@ public class SuspendedEvent implements ICDISuspendedEvent { * @see org.eclipse.cdt.debug.core.cdi.event.ICDIEvent#getSource() */ public ICDIObject getSource() { - ICDITarget target = session.getCurrentTarget(); + Target target = session.getTarget(event.getMISession()); // We can send the target as the Source. CDI // Will assume that all threads are supended for this. // This is true for gdb when it suspend the inferior diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Catchpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Catchpoint.java deleted file mode 100644 index 92ebfc1fe1f..00000000000 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Catchpoint.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2004 QNX Software Systems and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.mi.core.cdi.model; - -import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.ICDICatchEvent; -import org.eclipse.cdt.debug.core.cdi.model.ICDICatchpoint; -import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint; - -/** - */ -public class Catchpoint extends Breakpoint implements ICDICatchpoint { - - public Catchpoint(Target target, MIBreakpoint miBreak) { - super(target, miBreak); - } - - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDICatchpoint#getEvent() - */ - public ICDICatchEvent getEvent() throws CDIException { - return null; - } -} diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Exceptionpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Exceptionpoint.java new file mode 100644 index 00000000000..47293fc129b --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Exceptionpoint.java @@ -0,0 +1,62 @@ +/********************************************************************** + * Copyright (c) 2002,2003,2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ + +package org.eclipse.cdt.debug.mi.core.cdi.model; + +import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; +import org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint; +import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint; + +/** + * Exceptionpoint + */ +public class Exceptionpoint extends Breakpoint implements ICDIExceptionpoint { + + String fClazz; + boolean fStopOnThrow; + boolean fStopOnCatch; + + /** + */ + public Exceptionpoint(Target target, String name, boolean stopOnThrow, boolean stopOnCatch) { + super(target, ICDIBreakpoint.REGULAR, null, null, null); + fClazz = name; + fStopOnThrow = stopOnThrow; + fStopOnCatch = stopOnCatch; + } + + public String getExceptionName() { + return fClazz; + } + + /** + * @param target + * @param miBreak + */ + public Exceptionpoint(Target target, MIBreakpoint miBreak) { + super(target, miBreak); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint#isStopOnThrow() + */ + public boolean isStopOnThrow() { + return fStopOnThrow; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.debug.core.cdi.model.ICDIExceptionpoint#isStopOnCatch() + */ + public boolean isStopOnCatch() { + return fStopOnCatch; + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java index e06af32e35e..3da8503ddd1 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Thread.java @@ -107,10 +107,8 @@ public class Thread extends CObject implements ICDIThread { if (currentFrames == null || currentFrames.size() < depth) { currentFrames = new ArrayList(); Target target = (Target)getTarget(); - Session session = (Session) target.getSession(); - Target currentTarget = (Target) session.getCurrentTarget(); - ICDIThread currentThread = currentTarget.getCurrentThread(); - currentTarget.setCurrentThread(this, false); + ICDIThread currentThread = target.getCurrentThread(); + target.setCurrentThread(this, false); try { MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); @@ -131,7 +129,7 @@ public class Thread extends CObject implements ICDIThread { //throw e; //System.out.println(e); } finally { - currentTarget.setCurrentThread(currentThread, false); + target.setCurrentThread(currentThread, false); } // assign the currentFrame if it was not done yet. if (currentFrame == null) { @@ -152,10 +150,8 @@ public class Thread extends CObject implements ICDIThread { public int getStackFrameCount() throws CDIException { if (stackdepth == 0) { Target target = (Target)getTarget(); - Session session = (Session) (target.getSession()); - Target currentTarget = (Target) session.getCurrentTarget(); - ICDIThread currentThread = currentTarget.getCurrentThread(); - currentTarget.setCurrentThread(this, false); + ICDIThread currentThread = target.getCurrentThread(); + target.setCurrentThread(this, false); try { MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); @@ -185,7 +181,7 @@ public class Thread extends CObject implements ICDIThread { } catch (MIException e) { throw new MI2CDIException(e); } finally { - currentTarget.setCurrentThread(currentThread, false); + target.setCurrentThread(currentThread, false); } } return stackdepth; @@ -198,10 +194,8 @@ public class Thread extends CObject implements ICDIThread { if (currentFrames == null || currentFrames.size() < high) { currentFrames = new ArrayList(); Target target = (Target) getTarget(); - Session session = (Session) target.getSession(); - Target currentTarget = (Target) session.getCurrentTarget(); - ICDIThread currentThread = currentTarget.getCurrentThread(); - currentTarget.setCurrentThread(this, false); + ICDIThread currentThread = target.getCurrentThread(); + target.setCurrentThread(this, false); try { int depth = getStackFrameCount(); int upperBound; @@ -233,7 +227,7 @@ public class Thread extends CObject implements ICDIThread { //throw e; //System.out.println(e); } finally { - currentTarget.setCurrentThread(currentThread, false); + target.setCurrentThread(currentThread, false); } // take time to assign the currentFrame, if it is in the set if (currentFrame == null) { @@ -266,15 +260,18 @@ public class Thread extends CObject implements ICDIThread { } // Check to see if we are already at this level - ICDIStackFrame current = getCurrentStackFrame(); - if (current != null && current.getLevel() == frameLevel) { - // noop - return; + if (currentFrame != null && currentFrame.getLevel() == frameLevel) { + if (stackframe != null) { + Thread aThread = (Thread)stackframe.getThread(); + if (aThread != null && aThread.getId() == getId()) { + // noop + return; + } + } } try { Target target = (Target)getTarget(); - Session session = (Session) target.getSession(); MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); // Need the GDB/MI view of level which is the reverse, i.e. the highest level is 0 @@ -282,7 +279,7 @@ public class Thread extends CObject implements ICDIThread { int miLevel = getStackFrameCount() - frameLevel; MIStackSelectFrame frame = factory.createMIStackSelectFrame(miLevel); // Set ourself as the current thread first. - ((Target) getTarget()).setCurrentThread(this, doUpdate); + target.setCurrentThread(this, doUpdate); mi.postCommand(frame); MIInfo info = frame.getMIInfo(); if (info == null) { @@ -293,6 +290,7 @@ public class Thread extends CObject implements ICDIThread { // some variables like registers. Call an update() // To generate changeEvents. if (doUpdate) { + Session session = (Session) target.getSession(); RegisterManager regMgr = (RegisterManager) session.getRegisterManager(); if (regMgr.isAutoUpdate()) { regMgr.update(target); diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorCreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorCreatedEvent.java new file mode 100644 index 00000000000..a7a988a4321 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorCreatedEvent.java @@ -0,0 +1,29 @@ +/********************************************************************** + * Copyright (c) 2002,2003,2004 QNX Software Systems and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + ***********************************************************************/ + +package org.eclipse.cdt.debug.mi.core.event; + +import org.eclipse.cdt.debug.mi.core.MISession; + +/** + * MIInferiorCreatedEvent + */ +public class MIInferiorCreatedEvent extends MICreatedEvent { + + /** + * @param source + * @param id + */ + public MIInferiorCreatedEvent(MISession source, int id) { + super(source, id); + } + +} diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java index d9d6bc2f35c..e2e7fcf63ed 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CygwinGDBDebugger.java @@ -7,6 +7,7 @@ package org.eclipse.cdt.debug.mi.core; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISession; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; @@ -34,22 +35,25 @@ public class CygwinGDBDebugger extends GDBDebugger { boolean failed = false; try { session = (Session) super.createLaunchSession(config, exe); - Target target = (Target)session.getCurrentTarget(); - MISession miSession = target.getMISession(); - miSession.setCommandFactory(commandFactory); - // For windows we need to start the inferior in a new console window - // to separate the Inferior std{in,out,err} from gdb std{in,out,err} - try { - CommandFactory factory = miSession.getCommandFactory(); - MIGDBSet set = factory.createMIGDBSet(new String[] { "new-console" }); //$NON-NLS-1$ - miSession.postCommand(set); - MIInfo info = set.getMIInfo(); - if (info == null) { - throw new MIException(MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$ + ICDITarget[] targets = session.getTargets(); + for (int i = 0; i < targets.length; ++i) { + Target target = (Target)targets[i]; + MISession miSession = target.getMISession(); + miSession.setCommandFactory(commandFactory); + // For windows we need to start the inferior in a new console window + // to separate the Inferior std{in,out,err} from gdb std{in,out,err} + try { + CommandFactory factory = miSession.getCommandFactory(); + MIGDBSet set = factory.createMIGDBSet(new String[] { "new-console" }); //$NON-NLS-1$ + miSession.postCommand(set); + MIInfo info = set.getMIInfo(); + if (info == null) { + throw new MIException(MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$ + } + } catch (MIException e) { + // We ignore this exception, for example + // on GNU/Linux the new-console is an error. } - } catch (MIException e) { - // We ignore this exception, for example - // on GNU/Linux the new-console is an error. } return session; } catch (CDIException e) { @@ -73,8 +77,11 @@ public class CygwinGDBDebugger extends GDBDebugger { boolean failed = false; try { session = (Session) super.createAttachSession(config, exe, pid); - Target target = (Target)session.getCurrentTarget(); - target.getMISession().setCommandFactory(commandFactory); + ICDITarget[] targets = session.getTargets(); + for (int i = 0; i < targets.length; ++i) { + Target target = (Target)targets[i]; + target.getMISession().setCommandFactory(commandFactory); + } initializeLibraries(config, session); return session; } catch (CDIException e) { @@ -98,8 +105,11 @@ public class CygwinGDBDebugger extends GDBDebugger { boolean failed = false; try { session = (Session) super.createCoreSession(config, exe, corefile); - Target target = (Target)session.getCurrentTarget(); - target.getMISession().setCommandFactory(commandFactory); + ICDITarget[] targets = session.getTargets(); + for (int i = 0; i < targets.length; ++i) { + Target target = (Target)targets[i]; + target.getMISession().setCommandFactory(commandFactory); + } initializeLibraries(config, session); return session; } catch (CDIException e) { diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/EventThread.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/EventThread.java index a71710f43e1..061db037d8a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/EventThread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/EventThread.java @@ -54,7 +54,6 @@ public class EventThread extends Thread { void processSuspendedEvent(MIStoppedEvent stopped) { // give a chance also to the underlying inferior. session.getMIInferior().update(); - } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java index b2298750133..5a1decc0d6d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java @@ -20,6 +20,7 @@ import org.eclipse.cdt.debug.core.ICDebugger; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager; import org.eclipse.cdt.debug.mi.core.cdi.model.Target; @@ -77,21 +78,24 @@ public class GDBServerDebugger implements ICDebugger { String remote = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV, "invalid"); //$NON-NLS-1$ String remoteBaud = config.getAttribute(IGDBServerMILaunchConfigurationConstants.ATTR_DEV_SPEED, "invalid"); //$NON-NLS-1$ session = (Session)MIPlugin.getDefault().createCSession(gdb, exe.getLocation().toFile(), -1, null, cwd, gdbinit); - Target target = (Target)session.getCurrentTarget(); - MISession miSession = target.getMISession(); - CommandFactory factory = miSession.getCommandFactory(); - MIGDBSet setRemoteBaud = factory.createMIGDBSet(new String[]{"remotebaud", remoteBaud}); //$NON-NLS-1$ - // Set serial line parameters - miSession.postCommand(setRemoteBaud, launchTimeout); - MIInfo info = setRemoteBaud.getMIInfo(); - if (info == null) { - throw new MIException (MIPlugin.getResourceString("src.GDBServerDebugger.Can_not_set_Baud")); //$NON-NLS-1$ - } - MITargetSelect select = factory.createMITargetSelect(new String[] {"remote", remote}); //$NON-NLS-1$ - miSession.postCommand(select, launchTimeout); - select.getMIInfo(); - if (info == null) { - throw new MIException (MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$ + ICDITarget[] targets = session.getTargets(); + for (int i = 0; i < targets.length; ++i) { + Target target = (Target)targets[i]; + MISession miSession = target.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); + MIGDBSet setRemoteBaud = factory.createMIGDBSet(new String[]{"remotebaud", remoteBaud}); //$NON-NLS-1$ + // Set serial line parameters + miSession.postCommand(setRemoteBaud, launchTimeout); + MIInfo info = setRemoteBaud.getMIInfo(); + if (info == null) { + throw new MIException (MIPlugin.getResourceString("src.GDBServerDebugger.Can_not_set_Baud")); //$NON-NLS-1$ + } + MITargetSelect select = factory.createMITargetSelect(new String[] {"remote", remote}); //$NON-NLS-1$ + miSession.postCommand(select, launchTimeout); + select.getMIInfo(); + if (info == null) { + throw new MIException (MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$ + } } } initializeLibraries(config, session);