diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index f138fd0b96f..1b759a03274 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -1,3 +1,17 @@ +2004-09-06 Alain Magloire + + The changes is move the MISession as part + of Target. The rationale; we want to have + Session + --------------- + | | + Target(gdb) Target(gdb) + To be able to do this we need to untie the MISession + from Session. + + Also we are moving toward retiring the ICDIXXXXManager + and move the methods in the the proper methods. + 2004-09-01 Alain Magloire Fix for 72974 diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointHit.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointHit.java index 74b6dc4bfa4..d853a6d51d4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointHit.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointHit.java @@ -34,7 +34,7 @@ public class BreakpointHit extends SessionObject implements ICDIBreakpointHit { // Ask the breakpointManager for the breakpoint BreakpointManager mgr = (BreakpointManager)getSession().getBreakpointManager(); // We need to return the same object as the breakpoint. - Breakpoint point = mgr.getBreakpoint(number); + Breakpoint point = mgr.getBreakpoint(breakEvent.getMISession(), number); // FIXME: if point == null ?? Create a new breakpoint ?? return point; } 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 3dcd0f73dac..173f38655aa 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,8 +11,12 @@ 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.ICDIBreakpointManager; @@ -54,23 +58,33 @@ import org.eclipse.cdt.debug.mi.core.output.MIInfo; */ public class BreakpointManager extends Manager implements ICDIBreakpointManager { - List breakList; - List deferredList; + public static ICDIBreakpoint[] EMPTY_BREAKPOINTS = {}; + + Map breakMap; + Map deferredMap; boolean allowInterrupt; public BreakpointManager(Session session) { super(session, false); - breakList = Collections.synchronizedList(new ArrayList()); - deferredList = Collections.synchronizedList(new ArrayList()); + breakMap = Collections.synchronizedMap(new HashMap()); + deferredMap = Collections.synchronizedMap(new HashMap()); allowInterrupt = true; } - public MIBreakpoint[] getMIBreakpoints() throws CDIException { - Session s = (Session)getSession(); - CommandFactory factory = s.getMISession().getCommandFactory(); + synchronized List getBreakpointsList(Target target) { + List bList = (List)breakMap.get(target); + if (bList == null) { + bList = Collections.synchronizedList(new ArrayList()); + breakMap.put(target, bList); + } + return bList; + } + + public MIBreakpoint[] getMIBreakpoints(MISession miSession) throws CDIException { + CommandFactory factory = miSession.getCommandFactory(); MIBreakList breakpointList = factory.createMIBreakList(); try { - s.getMISession().postCommand(breakpointList); + miSession.postCommand(breakpointList); MIBreakListInfo info = breakpointList.getMIBreakListInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -88,33 +102,37 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager miBreak.getIgnoreCount() != miBreakpoint.getIgnoreCount(); } - public Breakpoint getBreakpoint(int number) { - Breakpoint[] bkpts = (Breakpoint[]) breakList.toArray(new Breakpoint[0]); - for (int i = 0; i < bkpts.length; i++) { - MIBreakpoint miBreak = bkpts[i].getMIBreakpoint(); - if (miBreak.getNumber() == number) { - return bkpts[i]; + public Watchpoint getWatchpoint(MISession miSession, int number) { + return (Watchpoint)getBreakpoint(miSession, number); + } + public Breakpoint getBreakpoint(MISession miSession, int number) { + Session session = (Session)getSession(); + Target target = session.getTarget(miSession); + if (target != null) { + return getBreakpoint(target, number); + } + return null; + } + public Breakpoint getBreakpoint(Target target, int number) { + List bList = (List)breakMap.get(target); + if (bList != null) { + Breakpoint[] bkpts = (Breakpoint[]) bList.toArray(new Breakpoint[0]); + for (int i = 0; i < bkpts.length; i++) { + MIBreakpoint miBreak = bkpts[i].getMIBreakpoint(); + if (miBreak.getNumber() == number) { + return bkpts[i]; + } } } return null; } - public Watchpoint getWatchpoint(int number) { - return (Watchpoint)getBreakpoint(number); - } - - boolean suspendInferior(ICDITarget target) throws CDIException { + boolean suspendInferior(Target target) throws CDIException { boolean shouldRestart = false; // Stop the program if (allowInterrupt) { - if (target instanceof Target) { - Target ctarget = (Target)target; - // Disable events. - if (ctarget.isRunning()) { - ctarget.suspend(); - shouldRestart = true; - } - } else if (!target.isSuspended()) { + // Disable events. + if (target.isRunning()) { target.suspend(); shouldRestart = true; } @@ -122,36 +140,50 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager return shouldRestart; } - void resumeInferior(ICDITarget target, boolean shouldRestart) throws CDIException { + void resumeInferior(Target target, boolean shouldRestart) throws CDIException { if (shouldRestart) { target.resume(); } } - public void deleteBreakpoint (int no) { - Breakpoint[] points = (Breakpoint[]) breakList.toArray(new Breakpoint[0]); - for (int i = 0; i < points.length; i++) { - if (points[i].getMIBreakpoint().getNumber() == no) { - breakList.remove(points[i]); - break; + public void deleteBreakpoint(MISession miSession, int no) { + Session session = (Session)getSession(); + Target target = session.getTarget(miSession); + if (target != null) { + deleteBreakpoint(target, no); + } + } + public void deleteBreakpoint (Target target, int no) { + List bList = (List)breakMap.get(target); + if (bList != null) { + Breakpoint[] points = (Breakpoint[]) bList.toArray(new Breakpoint[0]); + for (int i = 0; i < points.length; i++) { + if (points[i].getMIBreakpoint().getNumber() == no) { + bList.remove(points[i]); + break; + } } } } public void enableBreakpoint(ICDIBreakpoint breakpoint) throws CDIException { + Target target = (Target)breakpoint.getTarget(); + List bList = (List)breakMap.get(target); + if (bList == null) { + throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ + } int number = 0; - if (breakpoint instanceof Breakpoint - && breakList.contains(breakpoint)) { + if (bList.contains(breakpoint)) { number = ((Breakpoint) breakpoint).getMIBreakpoint().getNumber(); } else { throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ } - boolean state = suspendInferior(breakpoint.getTarget()); - Session session = (Session)getSession(); - CommandFactory factory = session.getMISession().getCommandFactory(); + boolean state = suspendInferior(target); + MISession miSession = target.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); MIBreakEnable breakEnable = factory.createMIBreakEnable(new int[] { number }); try { - session.getMISession().postCommand(breakEnable); + miSession.postCommand(breakEnable); MIInfo info = breakEnable.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -160,30 +192,34 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager throw new MI2CDIException(e); } finally { // Resume the program and enable events. - resumeInferior(breakpoint.getTarget(), state); + resumeInferior(target, state); } ((Breakpoint) breakpoint).getMIBreakpoint().setEnabled(true); // Fire a changed Event. - MISession mi = session.getMISession(); - mi.fireEvent(new MIBreakpointChangedEvent(((Breakpoint)breakpoint).getMIBreakpoint().getNumber())); + miSession.fireEvent(new MIBreakpointChangedEvent(miSession, ((Breakpoint)breakpoint).getMIBreakpoint().getNumber())); } public void disableBreakpoint(ICDIBreakpoint breakpoint) throws CDIException { + Target target = (Target)breakpoint.getTarget(); + List bList = (List)breakMap.get(target); + if (bList == null) { + throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ + } int number = 0; - if (breakpoint instanceof Breakpoint - && breakList.contains(breakpoint)) { + if (bList.contains(breakpoint)) { number = ((Breakpoint) breakpoint).getMIBreakpoint().getNumber(); } else { throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ } - Session session = (Session)getSession(); - boolean state = suspendInferior(breakpoint.getTarget()); - CommandFactory factory = session.getMISession().getCommandFactory(); + Session session = (Session)target.getSession(); + boolean state = suspendInferior(target); + MISession miSession = target.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); MIBreakDisable breakDisable = factory.createMIBreakDisable(new int[] { number }); try { - session.getMISession().postCommand(breakDisable); + miSession.postCommand(breakDisable); MIInfo info = breakDisable.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -191,26 +227,30 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager } catch (MIException e) { throw new MI2CDIException(e); } finally { - resumeInferior(breakpoint.getTarget(), state); + resumeInferior(target, state); } ((Breakpoint) breakpoint).getMIBreakpoint().setEnabled(false); // Fire a changed Event. - MISession mi = session.getMISession(); - mi.fireEvent(new MIBreakpointChangedEvent(((Breakpoint)breakpoint).getMIBreakpoint().getNumber())); + miSession.fireEvent(new MIBreakpointChangedEvent(miSession, ((Breakpoint)breakpoint).getMIBreakpoint().getNumber())); } public void setCondition(ICDIBreakpoint breakpoint, ICDICondition condition) throws CDIException { + Target target = (Target)breakpoint.getTarget(); + List bList = (List)breakMap.get(target); + if (bList == null) { + throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ + } int number = 0; - if (breakpoint instanceof Breakpoint - && breakList.contains(breakpoint)) { + if (bList.contains(breakpoint)) { number = ((Breakpoint) breakpoint).getMIBreakpoint().getNumber(); } else { throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ } - Session session = (Session)getSession(); - boolean state = suspendInferior(breakpoint.getTarget()); - CommandFactory factory = session.getMISession().getCommandFactory(); + Session session = (Session)target.getSession(); + boolean state = suspendInferior(target); + MISession miSession = target.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); // reset the values to sane states. String exprCond = condition.getExpression(); @@ -223,16 +263,15 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager } try { - MIBreakCondition breakCondition = - factory.createMIBreakCondition(number, exprCond); - session.getMISession().postCommand(breakCondition); + MIBreakCondition breakCondition = factory.createMIBreakCondition(number, exprCond); + miSession.postCommand(breakCondition); MIInfo info = breakCondition.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ } MIBreakAfter breakAfter = factory.createMIBreakAfter(number, ignoreCount); - session.getMISession().postCommand(breakAfter); + miSession.postCommand(breakAfter); info = breakAfter.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -240,40 +279,50 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager } catch (MIException e) { throw new MI2CDIException(e); } finally { - resumeInferior(breakpoint.getTarget(), state); + resumeInferior(target, state); } // Fire a changed Event. - MISession mi = session.getMISession(); - mi.fireEvent(new MIBreakpointChangedEvent(((Breakpoint)breakpoint).getMIBreakpoint().getNumber())); + miSession.fireEvent(new MIBreakpointChangedEvent(miSession, ((Breakpoint)breakpoint).getMIBreakpoint().getNumber())); + } + + /** + * @deprecated + * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#update() + */ + public void update() throws CDIException { + Target target = (Target)getSession().getCurrentTarget(); + update(target); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#update() */ - public void update() throws CDIException { - MIBreakpoint[] newMIBreakpoints = getMIBreakpoints(); + public void update(Target target) throws CDIException { + MISession miSession = target.getMISession(); + MIBreakpoint[] newMIBreakpoints = getMIBreakpoints(miSession); + List bList = getBreakpointsList(target); List eventList = new ArrayList(newMIBreakpoints.length); for (int i = 0; i < newMIBreakpoints.length; i++) { int no = newMIBreakpoints[i].getNumber(); - Breakpoint bp = getBreakpoint(no); + Breakpoint bp = getBreakpoint(target, no); if (bp != null) { if (hasBreakpointChanged(bp, newMIBreakpoints[i])) { // Fire ChangedEvent bp.setMIBreakpoint(newMIBreakpoints[i]); - eventList.add(new MIBreakpointChangedEvent(no)); + eventList.add(new MIBreakpointChangedEvent(miSession, no)); } } else { // add the new breakpoint and fire CreatedEvent if (newMIBreakpoints[i].isWatchpoint()) { - breakList.add(new Watchpoint(this, newMIBreakpoints[i])); + bList.add(new Watchpoint(target, newMIBreakpoints[i])); } else { - breakList.add(new Breakpoint(this, newMIBreakpoints[i])); + bList.add(new Breakpoint(target, newMIBreakpoints[i])); } - eventList.add(new MIBreakpointCreatedEvent(no)); + eventList.add(new MIBreakpointCreatedEvent(miSession, no)); } } // Check if any breakpoint was removed. - Breakpoint[] oldBreakpoints = (Breakpoint[]) breakList.toArray(new Breakpoint[0]); + Breakpoint[] oldBreakpoints = (Breakpoint[]) bList.toArray(new Breakpoint[0]); for (int i = 0; i < oldBreakpoints.length; i++) { boolean found = false; int no = oldBreakpoints[i].getMIBreakpoint().getNumber(); @@ -285,12 +334,11 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager } if (!found) { // Fire destroyed Events. - eventList.add(new MIBreakpointDeletedEvent(no)); + eventList.add(new MIBreakpointDeletedEvent(miSession, no)); } } - MISession mi = ((Session)getSession()).getMISession(); MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); - mi.fireEvents(events); + miSession.fireEvents(events); } /** @@ -300,6 +348,20 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager allowInterrupt = e; } + public void deleteFromDeferredList(Breakpoint bkpt) { + List dList = (List)deferredMap.get(bkpt.getTarget()); + if (dList != null) { + dList.remove(bkpt); + } + } + + public void addToBreakpointList(Breakpoint bkpt) { + List bList = (List)breakMap.get(bkpt.getTarget()); + if (bList != null) { + bList.add(bkpt); + } + } + /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteAllBreakpoints() */ @@ -307,41 +369,51 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager deleteBreakpoints(getBreakpoints()); } + public void deleteAllBreakpoints(Target target) throws CDIException { + List bList = (List)breakMap.get(target); + if (bList != null) { + ICDIBreakpoint[] bps = new ICDIBreakpoint[bList.size()]; + bList.toArray(bps); + deleteBreakpoints(target, bps); + } + } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteBreakpoint(ICDIBreakpoint) */ public void deleteBreakpoint(ICDIBreakpoint breakpoint) throws CDIException { - deleteBreakpoints(new ICDIBreakpoint[] { breakpoint }); - } - - public void deleteFromDeferredList(Breakpoint bkpt) { - deferredList.remove(bkpt); - } - - public void addToBreakpointList(Breakpoint bkpt) { - breakList.add(bkpt); + 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); + if (bList == null) { + throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ + } for (int i = 0; i < numbers.length; i++) { if (breakpoints[i] instanceof Breakpoint - && breakList.contains(breakpoints[i])) { + && bList.contains(breakpoints[i])) { numbers[i] = ((Breakpoint) breakpoints[i]).getMIBreakpoint().getNumber(); } else { throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$ } } - Session session = (Session)getSession(); - boolean state = suspendInferior(session.getCurrentTarget()); - CommandFactory factory = session.getMISession().getCommandFactory(); + boolean state = suspendInferior(target); + MISession miSession = target.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); MIBreakDelete breakDelete = factory.createMIBreakDelete(numbers); try { - session.getMISession().postCommand(breakDelete); + miSession.postCommand(breakDelete); MIInfo info = breakDelete.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -349,27 +421,49 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager } catch (MIException e) { throw new MI2CDIException(e); } finally { - resumeInferior(session.getCurrentTarget(), state); + resumeInferior(target, state); } List eventList = new ArrayList(breakpoints.length); for (int i = 0; i < breakpoints.length; i++) { int no = ((Breakpoint)breakpoints[i]).getMIBreakpoint().getNumber(); - eventList.add(new MIBreakpointDeletedEvent(no)); + eventList.add(new MIBreakpointDeletedEvent(miSession, no)); } - MISession mi = session.getMISession(); MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); - mi.fireEvents(events); + miSession.fireEvents(events); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#getBreakpoints(ICDITarget) + */ + public ICDIBreakpoint[] getBreakpoints(Target target) throws CDIException { + List list = (List)breakMap.get(target); + if (list != null) { + ICDIBreakpoint[] bps = new ICDIBreakpoint[list.size()]; + list.toArray(bps); + return bps; + } + return EMPTY_BREAKPOINTS; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#getBreakpoints() */ public ICDIBreakpoint[] getBreakpoints() throws CDIException { - return (ICDIBreakpoint[]) breakList.toArray(new ICDIBreakpoint[0]); + Collection col = breakMap.values(); + Iterator itr = breakMap.values().iterator(); + ICDIBreakpoint[] bps = new ICDIBreakpoint[col.size()]; + col.toArray(bps); + return bps; } - public ICDIBreakpoint[] getDeferredBreakpoints() throws CDIException { - return (ICDIBreakpoint[]) deferredList.toArray(new ICDIBreakpoint[0]); + public ICDIBreakpoint[] getDeferredBreakpoints(Target target) throws CDIException { + List dlist = (List)deferredMap.get(target); + if (dlist != null) { + ICDIBreakpoint[] bps = new ICDIBreakpoint[dlist.size()]; + dlist.toArray(bps); + return bps; + } + return EMPTY_BREAKPOINTS; } /** @@ -394,25 +488,38 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, ICDICondition condition, String threadId, boolean deferred) throws CDIException { - Breakpoint bkpt = new Breakpoint(this, type, location, condition, threadId); + 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 { + + MISession miSession = target.getMISession(); + Breakpoint bkpt = new Breakpoint(target, type, location, condition, threadId); try { setLocationBreakpoint(bkpt); - breakList.add(bkpt); + List blist = getBreakpointsList(target); + blist.add(bkpt); // Fire a created Event. - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - mi.fireEvent(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber())); + miSession.fireEvent(new MIBreakpointCreatedEvent(miSession, bkpt.getMIBreakpoint().getNumber())); } catch (CDIException e) { if (!deferred) { throw e; } - Session session = (Session)getSession(); + Session session = (Session)target.getSession(); ICDISharedLibraryManager sharedMgr = session.getSharedLibraryManager(); if (sharedMgr instanceof SharedLibraryManager) { SharedLibraryManager mgr = (SharedLibraryManager)sharedMgr; if (mgr.isDeferredBreakpoint()) { - deferredList.add(bkpt); + List dList = (List)deferredMap.get(target); + if (dList == null) { + dList = Collections.synchronizedList(new ArrayList()); + deferredMap.put(target, dList); + } + dList.add(bkpt); } else { throw e; } @@ -420,12 +527,13 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager } return bkpt; } - + MIBreakInsert createMIBreakInsert(Breakpoint bkpt) throws CDIException { boolean hardware = bkpt.isHardware(); boolean temporary = bkpt.isTemporary(); String exprCond = null; int ignoreCount = 0; + String threadId = bkpt.getThreadId(); StringBuffer line = new StringBuffer(); if (bkpt.getCondition() != null) { @@ -453,18 +561,27 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager line.append('*').append(location.getAddress()); } } - Session session = (Session)getSession(); - CommandFactory factory = session.getMISession().getCommandFactory(); - return factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString()); + + int tid = 0; + if (threadId != null && threadId.length() > 0) { + try { + tid = Integer.parseInt(threadId); + } catch (NumberFormatException e) { + } + } + MISession miSession = ((Target)bkpt.getTarget()).getMISession(); + CommandFactory factory = miSession.getCommandFactory(); + return factory.createMIBreakInsert(temporary, hardware, exprCond, ignoreCount, line.toString(), tid); } - public void setLocationBreakpoint (Breakpoint bkpt) throws CDIException { - Session session = (Session)getSession(); - boolean state = suspendInferior(session.getCurrentTarget()); + void setLocationBreakpoint (Breakpoint bkpt) throws CDIException { + Target target = (Target)bkpt.getTarget(); + MISession miSession = target.getMISession(); + boolean state = suspendInferior(target); MIBreakInsert breakInsert = createMIBreakInsert(bkpt); MIBreakpoint[] points = null; try { - session.getMISession().postCommand(breakInsert); + miSession.postCommand(breakInsert); MIBreakInsertInfo info = breakInsert.getMIBreakInsertInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -476,7 +593,7 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager } catch (MIException e) { throw new MI2CDIException(e); } finally { - resumeInferior(session.getCurrentTarget(), state); + resumeInferior(target, state); } bkpt.setMIBreakpoint(points[0]); @@ -485,21 +602,27 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager /** * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setWatchpoint(int, int, String, ICDICondition, boolean) */ - public ICDIWatchpoint setWatchpoint( int type, int watchType, String expression, + 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 { + boolean access = ( (watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE && (watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ ); boolean read = ( !((watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE) && (watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ ); - Session session = (Session)getSession(); - boolean state = suspendInferior(session.getCurrentTarget()); - CommandFactory factory = session.getMISession().getCommandFactory(); + MISession miSession = target.getMISession(); + boolean state = suspendInferior(target); + CommandFactory factory = miSession.getCommandFactory(); MIBreakWatch breakWatch = factory.createMIBreakWatch(access, read, expression); MIBreakpoint[] points = null; try { - session.getMISession().postCommand(breakWatch); + miSession.postCommand(breakWatch); MIBreakWatchInfo info = breakWatch.getMIBreakWatchInfo(); points = info.getMIBreakpoints(); if (info == null) { @@ -511,14 +634,14 @@ public class BreakpointManager extends Manager implements ICDIBreakpointManager } catch (MIException e) { throw new MI2CDIException(e); } finally { - resumeInferior(session.getCurrentTarget(), state); + resumeInferior(target, state); } - Watchpoint bkpt = new Watchpoint(this, points[0]); - breakList.add(bkpt); + Watchpoint bkpt = new Watchpoint(target, points[0]); + List bList = getBreakpointsList(target); + bList.add(bkpt); // Fire a created Event. - MISession mi = session.getMISession(); - mi.fireEvent(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber())); + miSession.fireEvent(new MIBreakpointCreatedEvent(miSession, bkpt.getMIBreakpoint().getNumber())); return bkpt; } 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 bd641f3d5ae..2c8e178773b 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 @@ -19,18 +19,11 @@ import java.util.Observer; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager; import org.eclipse.cdt.debug.core.cdi.ICDIEventManager; -import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager; -import org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager; -import org.eclipse.cdt.debug.core.cdi.ICDIRegisterManager; import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager; -import org.eclipse.cdt.debug.core.cdi.ICDISignalManager; -import org.eclipse.cdt.debug.core.cdi.ICDISourceManager; -import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager; import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent; import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; @@ -119,7 +112,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs // We need to fire an event for all the register blocks // that may contain the modified addresses. MemoryManager mgr = (MemoryManager)session.getMemoryManager(); - MemoryBlock[] blocks = mgr.listMemoryBlocks(); + MemoryBlock[] blocks = mgr.getMemoryBlocks(miEvent.getMISession()); MIMemoryChangedEvent miMem = (MIMemoryChangedEvent)miEvent; Long[] addresses = miMem.getAddresses(); for (int i = 0; i < blocks.length; i++) { @@ -254,7 +247,13 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs */ boolean processSuspendedEvent(MIStoppedEvent stopped) { Session session = (Session)getSession(); - ICDITarget currentTarget = session.getCurrentTarget(); + MISession miSession = stopped.getMISession(); + Target currentTarget = session.getTarget(miSession); + try { + session.setCurrentTarget(currentTarget); + } catch (CDIException e) { + //TODO: Should not ignore this. + } if (processSharedLibEvent(stopped)) { // Event was consumed by the shared lib processing bailout @@ -262,56 +261,53 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs } int threadId = threadId = stopped.getThreadId(); - if (currentTarget instanceof Target) { - Target cTarget = (Target)currentTarget; - cTarget.updateState(threadId); - try { - ICDIThread cthread = cTarget.getCurrentThread(); - if (cthread != null) { - cthread.getCurrentStackFrame(); - } else { - return true; - } - } catch (CDIException e1) { - //e1.printStackTrace(); + currentTarget.updateState(threadId); + try { + ICDIThread cthread = currentTarget.getCurrentThread(); + if (cthread != null) { + cthread.getCurrentStackFrame(); + } else { return true; } + } catch (CDIException e1) { + //e1.printStackTrace(); + return true; } // Update the managers. // For the Variable/Expression Managers call only the updateManager. - ICDIVariableManager varMgr = session.getVariableManager(); - ICDIExpressionManager expMgr = session.getExpressionManager(); - ICDIRegisterManager regMgr = session.getRegisterManager(); - ICDIMemoryManager memMgr = session.getMemoryManager(); - ICDIBreakpointManager bpMgr = session.getBreakpointManager(); - ICDISignalManager sigMgr = session.getSignalManager(); - ICDISourceManager srcMgr = session.getSourceManager(); - ICDISharedLibraryManager libMgr = session.getSharedLibraryManager(); + VariableManager varMgr = (VariableManager)session.getVariableManager(); + ExpressionManager expMgr = (ExpressionManager)session.getExpressionManager(); + RegisterManager regMgr = (RegisterManager)session.getRegisterManager(); + MemoryManager memMgr = (MemoryManager)session.getMemoryManager(); + BreakpointManager bpMgr = (BreakpointManager)session.getBreakpointManager(); + SignalManager sigMgr = (SignalManager)session.getSignalManager(); + SourceManager srcMgr = (SourceManager)session.getSourceManager(); + SharedLibraryManager libMgr = (SharedLibraryManager)session.getSharedLibraryManager(); try { if (varMgr.isAutoUpdate()) { - varMgr.update(); + varMgr.update(currentTarget); } if (expMgr.isAutoUpdate()) { - expMgr.update(); + expMgr.update(currentTarget); } if (regMgr.isAutoUpdate()) { - regMgr.update(); + regMgr.update(currentTarget); } if (memMgr.isAutoUpdate()) { - memMgr.update(); + memMgr.update(currentTarget); } if (bpMgr.isAutoUpdate()) { - bpMgr.update(); + bpMgr.update(currentTarget); } if (sigMgr.isAutoUpdate()) { - sigMgr.update(); + sigMgr.update(currentTarget); } if (libMgr.isAutoUpdate()) { - libMgr.update(); + libMgr.update(currentTarget); } if (srcMgr.isAutoUpdate()) { - srcMgr.update(); + srcMgr.update(currentTarget); } } catch (CDIException e) { //System.out.println(e); @@ -329,9 +325,9 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs */ boolean processSharedLibEvent(MIStoppedEvent stopped) { Session session = (Session)getSession(); - MISession mi = session.getMISession(); + MISession miSession = stopped.getMISession(); - ICDITarget currentTarget = session.getCurrentTarget(); + Target currentTarget = session.getTarget(miSession); ICDISharedLibraryManager libMgr = session.getSharedLibraryManager(); SharedLibraryManager mgr = null; @@ -344,7 +340,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs // Check if we have a new library loaded List eventList = null; try { - eventList = mgr.updateState(); + eventList = mgr.updateState(currentTarget); } catch (CDIException e3) { eventList = Collections.EMPTY_LIST; } @@ -355,7 +351,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs BreakpointManager bpMgr = (BreakpointManager)manager; ICDIBreakpoint bpoints[] = null; try { - bpoints = bpMgr.getDeferredBreakpoints(); + bpoints = bpMgr.getDeferredBreakpoints(currentTarget); } catch (CDIException e) { bpoints = new ICDIBreakpoint[0]; } @@ -372,7 +368,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs if (!enable) { bpMgr.disableBreakpoint(bkpt); } - eventList.add(new MIBreakpointCreatedEvent(bkpt.getMIBreakpoint().getNumber())); + eventList.add(new MIBreakpointCreatedEvent(miSession, bkpt.getMIBreakpoint().getNumber())); } catch (CDIException e) { // ignore } @@ -380,9 +376,9 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs } } MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); - mi.fireEvents(events); + miSession.fireEvents(events); } - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); int type = (lastRunningEvent == null) ? MIRunningEvent.CONTINUE : lastRunningEvent.getType(); if (lastUserCommand == null) { switch (type) { @@ -407,7 +403,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs case MIRunningEvent.CONTINUE: { MIExecContinue cont = factory.createMIExecContinue(); try { - mi.postCommand(cont); + miSession.postCommand(cont); MIInfo info = cont.getMIInfo(); if (info == null) { // throw new CDIException("Target is not responding"); @@ -434,7 +430,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs if (tid > 0) { MIThreadSelect selectThread = factory.createMIThreadSelect(tid); try { - mi.postCommand(selectThread); + miSession.postCommand(selectThread); } catch (MIException e) { // ignore } @@ -447,7 +443,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs int count = 0; try { MIStackInfoDepth depth = factory.createMIStackInfoDepth(); - mi.postCommand(depth); + miSession.postCommand(depth); MIStackInfoDepthInfo info = depth.getMIStackInfoDepthInfo(); if (info == null) { //throw new CDIException("No answer"); @@ -469,8 +465,8 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs MIStackSelectFrame selectFrame = factory.createMIStackSelectFrame(miLevel); MIExecFinish finish = factory.createMIExecFinish(); try { - mi.postCommand(selectFrame); - mi.postCommand(finish); + miSession.postCommand(selectFrame); + miSession.postCommand(finish); } catch (MIException e) { // ignore } @@ -481,7 +477,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs Command cmd = lastUserCommand; lastUserCommand = null; try { - mi.postCommand(cmd); + miSession.postCommand(cmd); } catch (MIException e) { // ignore } @@ -491,7 +487,7 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs Command cmd = lastUserCommand; lastUserCommand = null; try { - mi.postCommand(cmd); + miSession.postCommand(cmd); } catch (MIException e) { } return true; 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 cd2c84828cf..e60c5f7e26a 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 @@ -12,7 +12,9 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.ArrayList; import java.util.Collections; +import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager; @@ -23,6 +25,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; 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.Expression; +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; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; @@ -41,24 +44,31 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo; */ public class ExpressionManager extends Manager implements ICDIExpressionManager{ - private List expList; + final static ICDIExpression[] EMPTY_EXPRESSIONS = {}; + Map expMap; MIVarChange[] noChanges = new MIVarChange[0]; public ExpressionManager(Session session) { super(session, true); - expList = Collections.synchronizedList(new ArrayList()); + expMap = new Hashtable(); } + synchronized List getExpressionList(Target target) { + List expList = (List)expMap.get(target); + if (expList == null) { + expList = Collections.synchronizedList(new ArrayList()); + expMap.put(target, expList); + } + return expList; + } /** * Tell gdb to remove the underlying var-object also. */ - void removeMIVar(MIVar miVar) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + void removeMIVar(MISession miSession, MIVar miVar) throws CDIException { + CommandFactory factory = miSession.getCommandFactory(); MIVarDelete var = factory.createMIVarDelete(miVar.getVarName()); try { - mi.postCommand(var); + miSession.postCommand(var); var.getMIInfo(); } catch (MIException e) { throw new MI2CDIException(e); @@ -66,16 +76,19 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ } /** - * When element are remove from the cache, they are put on the OutOfScope list, oos, - * because they are still needed for the destroy events. The destroy event will - * call removeOutOfScope. + * When element are remove from the cache, + * The destroy event will call removeExpression. */ - public void removeExpression(String varName) throws CDIException { - Expression[] exps = (Expression[])expList.toArray(new Expression[0]); - for (int i = 0; i < exps.length; i++) { - if (exps[i].getMIVar().getVarName().equals(varName)) { - expList.remove(exps[i]); - removeMIVar(exps[i].getMIVar()); + public void removeExpression(MISession miSession, String varName) throws CDIException { + Target target = ((Session)getSession()).getTarget(miSession); + List expList = (List)expMap.get(target); + if (expList != null) { + Expression[] exps = (Expression[]) expList.toArray(new Expression[expList.size()]); + for (int i = 0; i < exps.length; i++) { + if (exps[i].getMIVar().getVarName().equals(varName)) { + expList.remove(exps[i]); + removeMIVar(miSession, exps[i].getMIVar()); + } } } } @@ -84,11 +97,15 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ * @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#createExpression(String) */ public ICDIExpression createExpression(String name) throws CDIException { + Target target = (Target)getSession().getCurrentTarget(); + return createExpression(target, name); + } + public ICDIExpression createExpression(Target target, String name) throws CDIException { Expression expression = null; + ICDITarget currentTarget = getSession().getCurrentTarget(); + getSession().setCurrentTarget(target); try { - Session session = (Session)getSession(); - ICDITarget currentTarget = session.getCurrentTarget(); - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarCreate var = factory.createMIVarCreate(name); mi.postCommand(var); @@ -96,11 +113,14 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ } - VariableObject varObj = new VariableObject(currentTarget, name, null, 0, 0); + VariableObject varObj = new VariableObject(target, name, null, 0, 0); expression = new Expression(varObj, info.getMIVar()); + List expList = getExpressionList(target); expList.add(expression); } catch (MIException e) { throw new MI2CDIException(e); + } finally { + getSession().setCurrentTarget(currentTarget); } return expression; } @@ -116,7 +136,8 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); frame.getThread().setCurrentStackFrame(frame, false); try { - MISession mi = session.getMISession(); + Target target = (Target)frame.getThread().getTarget(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarCreate var = factory.createMIVarCreate(name); mi.postCommand(var); @@ -124,9 +145,9 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ } - ICDITarget tgt = frame.getThread().getTarget(); - VariableObject varObj = new VariableObject(tgt, name, frame, 0, 0); + VariableObject varObj = new VariableObject(target, name, frame, 0, 0); expression = new Expression(varObj, info.getMIVar()); + List expList = getExpressionList(target); expList.add(expression); } catch (MIException e) { throw new MI2CDIException(e); @@ -140,9 +161,17 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ * @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#getExpressions() */ public ICDIExpression[] getExpressions() throws CDIException { - return (ICDIExpression[])expList.toArray(new ICDIExpression[0]); + Target target = (Target)getSession().getCurrentTarget(); + return getExpressions(target); } + public ICDIExpression[] getExpressions(Target target) throws CDIException { + List expList = (List) expMap.get(target); + if (expList != null) { + return (ICDIExpression[])expList.toArray(EMPTY_EXPRESSIONS); + } + return EMPTY_EXPRESSIONS; + } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#removeExpression(ICDIExpression) */ @@ -150,10 +179,10 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ if (expression instanceof Expression) { // Fire a destroyEvent ? Expression exp= (Expression)expression; - MIVarDeletedEvent del = new MIVarDeletedEvent(exp.getMIVar().getVarName()); - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - mi.fireEvent(del); + Target target = (Target)exp.getTarget(); + MISession miSession = target.getMISession(); + MIVarDeletedEvent del = new MIVarDeletedEvent(miSession, exp.getMIVar().getVarName()); + miSession.fireEvent(del); } } @@ -161,28 +190,37 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ * Return the element that have the uniq varName. * null is return if the element is not in the cache. */ - public Variable getExpression(String varName) { - Expression[] exps = (Expression[])expList.toArray(new Expression[0]); - for (int i = 0; i < exps.length; i++) { - if (exps[i].getMIVar().getVarName().equals(varName)) { - return exps[i]; - } - Variable v = exps[i].getChild(varName); - if (v != null) { - return v; + public Variable getExpression(MISession miSession, String varName) { + Target target = ((Session)getSession()).getTarget(miSession); + List expList = (List)expMap.get(target); + if (expList != null) { + Expression[] exps = (Expression[]) expList.toArray(new Expression[expList.size()]); + for (int i = 0; i < exps.length; i++) { + if (exps[i].getMIVar().getVarName().equals(varName)) { + return exps[i]; + } + Variable v = exps[i].getChild(varName); + if (v != null) { + return v; + } } } return null; } /** + * @deprecated * @see org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager#update() */ public void update() throws CDIException { + Target target = (Target)getSession().getCurrentTarget(); + update(target); + } + public void update(Target target) throws CDIException { List eventList = new ArrayList(); - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); + List expList = getExpressionList(target); Expression[] exps = (Expression[])expList.toArray(new Expression[0]); for (int i = 0; i < exps.length; i++) { String varName = exps[i].getMIVar().getVarName(); @@ -197,12 +235,12 @@ public class ExpressionManager extends Manager implements ICDIExpressionManager{ changes = info.getMIVarChanges(); } catch (MIException e) { //throw new MI2CDIException(e); - eventList.add(new MIVarDeletedEvent(varName)); + eventList.add(new MIVarDeletedEvent(mi, varName)); } for (int j = 0 ; j < changes.length; j++) { String n = changes[j].getVarName(); if (changes[j].isInScope()) { - eventList.add(new MIVarChangedEvent(n)); + eventList.add(new MIVarChangedEvent(mi, n)); } // We do not implicitely delete Expressions. //else { diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java index 763c1f7c05a..465aa9bb978 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java @@ -11,15 +11,21 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MIFormat; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.model.MemoryBlock; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIDataReadMemory; import org.eclipse.cdt.debug.mi.core.event.MIEvent; @@ -27,15 +33,43 @@ import org.eclipse.cdt.debug.mi.core.event.MIMemoryChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MIMemoryCreatedEvent; import org.eclipse.cdt.debug.mi.core.output.MIDataReadMemoryInfo; + /** */ public class MemoryManager extends Manager implements ICDIMemoryManager { - List blockList; + ICDIMemoryBlock[] EMPTY_MEMORY_BLOCKS = {}; + Map blockMap; public MemoryManager(Session session) { super(session, true); - blockList = new ArrayList(); + blockMap = new Hashtable(); + } + + synchronized List getMemoryBlockList(Target target) { + List blockList = (List)blockMap.get(target); + if (blockList == null) { + blockList = Collections.synchronizedList(new ArrayList()); + blockMap.put(target, blockList); + } + return blockList; + } + + /** + * This method will be call by the eventManager.processSuspended() every time the + * inferior comes to a Stop/Suspended. It will allow to look at the blocks that + * are registered and fired any event if changed. + * Note: Frozen blocks are not updated. + * + * @deprecated use update(Target) + * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#createMemoryBlock(long, int) + */ + public void update() { + Session session = (Session)getSession(); + ICDITarget[] targets = session.getTargets(); + for (int i = 0; i < targets.length; ++i) { + update((Target)targets[i]); + } } /** @@ -46,10 +80,10 @@ public class MemoryManager extends Manager implements ICDIMemoryManager { * * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#createMemoryBlock(long, int) */ - public void update() { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - MemoryBlock[] blocks = listMemoryBlocks(); + public void update(Target target) { + MISession miSession = target.getMISession(); + List blockList = getMemoryBlockList(target); + MemoryBlock[] blocks = (MemoryBlock[]) blockList.toArray(new MemoryBlock[blockList.size()]); List eventList = new ArrayList(blocks.length); for (int i = 0; i < blocks.length; i++) { if (! blocks[i].isFrozen()) { @@ -60,13 +94,15 @@ public class MemoryManager extends Manager implements ICDIMemoryManager { } } MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); - mi.fireEvents(events); + miSession.fireEvents(events); } /** * update one Block. */ public Long[] update(MemoryBlock block, List aList) throws CDIException { + Target target = (Target)block.getTarget(); + MISession miSession = target.getMISession(); MemoryBlock newBlock = cloneBlock(block); boolean newAddress = ( newBlock.getStartAddress() != block.getStartAddress() ); Long[] array = compareBlocks(block, newBlock); @@ -74,23 +110,15 @@ public class MemoryManager extends Manager implements ICDIMemoryManager { block.setMIDataReadMemoryInfo(newBlock.getMIDataReadMemoryInfo()); if (array.length > 0 || newAddress) { if (aList != null) { - aList.add(new MIMemoryChangedEvent(array)); + aList.add(new MIMemoryChangedEvent(miSession, array)); } else { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - mi.fireEvent(new MIMemoryChangedEvent(array)); + // fire right away. + miSession.fireEvent(new MIMemoryChangedEvent(miSession, array)); } } return array; } - /** - * @return the registers MemoryBlock. - */ - public MemoryBlock[] listMemoryBlocks() { - return (MemoryBlock[])blockList.toArray(new MemoryBlock[0]); - } - /** * Compare two blocks and return an array of all _addresses_ that are different. * This method is not smart it always assume that: @@ -121,22 +149,20 @@ public class MemoryManager extends Manager implements ICDIMemoryManager { * with the MemoryManager. */ MemoryBlock cloneBlock(MemoryBlock block) throws CDIException { - Session session = (Session)getSession(); + Target target = (Target)block.getTarget(); String exp = block.getExpression(); - MIDataReadMemoryInfo info = createMIDataReadMemoryInfo(exp, (int)block.getLength()); - return new MemoryBlock(session.getCurrentTarget(), exp, info); + MIDataReadMemoryInfo info = createMIDataReadMemoryInfo(target.getMISession(), exp, (int)block.getLength()); + return new MemoryBlock(target, exp, info); } /** * Post a -data-read-memory to gdb/mi. */ - MIDataReadMemoryInfo createMIDataReadMemoryInfo(String exp, int length) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + MIDataReadMemoryInfo createMIDataReadMemoryInfo(MISession miSession, String exp, int length) throws CDIException { + CommandFactory factory = miSession.getCommandFactory(); MIDataReadMemory mem = factory.createMIDataReadMemory(0, exp, MIFormat.HEXADECIMAL, 1, 1, length, null); try { - mi.postCommand(mem); + miSession.postCommand(mem); MIDataReadMemoryInfo info = mem.getMIDataReadMemoryInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -161,11 +187,15 @@ public class MemoryManager extends Manager implements ICDIMemoryManager { */ public ICDIMemoryBlock createMemoryBlock(String address, int length) throws CDIException { Session session = (Session)getSession(); - MIDataReadMemoryInfo info = createMIDataReadMemoryInfo(address, length); - ICDIMemoryBlock block = new MemoryBlock(session.getCurrentTarget(), address, info); + return createMemoryBlock((Target)session.getCurrentTarget(), address, length); + } + public ICDIMemoryBlock createMemoryBlock(Target target, String address, int length) throws CDIException { + MIDataReadMemoryInfo info = createMIDataReadMemoryInfo(target.getMISession(), address, length); + ICDIMemoryBlock block = new MemoryBlock(target, address, info); + List blockList = getMemoryBlockList(target); blockList.add(block); - MISession mi = session.getMISession(); - mi.fireEvent(new MIMemoryCreatedEvent(block.getStartAddress(), block.getLength())); + MISession miSession = target.getMISession(); + miSession.fireEvent(new MIMemoryCreatedEvent(miSession, block.getStartAddress(), block.getLength())); return block; } @@ -173,31 +203,52 @@ public class MemoryManager extends Manager implements ICDIMemoryManager { * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#getBlocks() */ public ICDIMemoryBlock[] getMemoryBlocks() throws CDIException { - return listMemoryBlocks(); + Target target = (Target)getSession().getCurrentTarget(); + return getMemoryBlocks(target); + } + public MemoryBlock[] getMemoryBlocks(MISession miSession) { + Session session = (Session)getSession(); + Target target = session.getTarget(miSession); + List blockList = getMemoryBlockList(target); + return (MemoryBlock[]) blockList.toArray(new MemoryBlock[blockList.size()]); + } + public ICDIMemoryBlock[] getMemoryBlocks(Target target) throws CDIException { + List blockList = getMemoryBlockList(target); + return (ICDIMemoryBlock[]) blockList.toArray(new ICDIMemoryBlock[blockList.size()]); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#removeAllBlocks() */ public void removeAllBlocks() throws CDIException { - blockList.clear(); + Target target = (Target)getSession().getCurrentTarget(); + removeAllBlocks(target); } + public void removeAllBlocks(Target target) throws CDIException { + ICDIMemoryBlock[] blocks = getMemoryBlocks(target); + removeBlocks(target, blocks); + } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#removeBlock(ICDIMemoryBlock) */ public void removeBlock(ICDIMemoryBlock memoryBlock) throws CDIException { - blockList.remove(memoryBlock); + removeBlocks((Target)memoryBlock.getTarget(), new ICDIMemoryBlock[] { memoryBlock }); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDIMemoryManager#removeBlocks(ICDIMemoryBlock[]) */ - public void removeBlocks(ICDIMemoryBlock[] memoryBlocks) - throws CDIException { + public void removeBlocks(ICDIMemoryBlock[] memoryBlocks) throws CDIException { for (int i = 0; i < memoryBlocks.length; i++) { removeBlock(memoryBlocks[i]); } } + public void removeBlocks(Target target, ICDIMemoryBlock[] memoryBlocks) throws CDIException { + List blockList = (List)blockMap.get(target); + if (blockList != null) { + blockList.removeAll(Arrays.asList(memoryBlocks)); + } + } } 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 98dacae20f8..e1cc0a4a3e5 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 @@ -8,22 +8,20 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.HashMap; 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.model.Target; /** */ -public class ProcessManager extends Manager { //implements ICDIProcessManager { +public class ProcessManager extends Manager { - static final ICDITarget[] noProcess = new Target[0]; + static final Target[] noProcess = new Target[0]; HashMap processMap; class ProcessSet { - ICDITarget[] currentProcs; + Target[] currentProcs; int currentProcessId; - ProcessSet(ICDITarget[] procs, int id) { + ProcessSet(Target[] procs, int id) { currentProcs = procs; currentProcessId = id; } @@ -37,21 +35,23 @@ public class ProcessManager extends Manager { //implements ICDIProcessManager { /** * @see org.eclipse.cdt.debug.core.cdi.ICDIProcessManager#getProcesses() */ - public ICDITarget[] getProcesses(ICDISession session) throws CDIException { + public Target[] getProcesses(Session session) throws CDIException { ProcessSet set = (ProcessSet)processMap.get(session); if (set == null) { - set = getCProcesses(session); + set = getProcessSet(session); processMap.put(session, set); } return set.currentProcs; } - public ProcessSet getCProcesses(ICDISession session) throws CDIException { - ICDITarget[] cprocs = new Target[] {new Target((Session)session)}; - return new ProcessSet(cprocs, 0); + protected ProcessSet getProcessSet(Session session) throws CDIException { + //Target[] cprocs = new Target[] {new Target((Session)session)}; + //return new ProcessSet(cprocs, 0); + return null; } /** + * @deprecated * @see org.eclipse.cdt.derug.core.cdi.ICDIManager#update() */ public void update() throws CDIException { diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java index 9d12358a3d3..eddf5cbd759 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/RegisterManager.java @@ -12,16 +12,20 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.ArrayList; import java.util.Collections; +import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIRegisterManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister; import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject; +import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; 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.Register; import org.eclipse.cdt.debug.mi.core.cdi.model.RegisterObject; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIDataListChangedRegisters; import org.eclipse.cdt.debug.mi.core.command.MIDataListRegisterNames; @@ -41,20 +45,33 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo; */ public class RegisterManager extends Manager implements ICDIRegisterManager { - private List regList; + Map regsMap; MIVarChange[] noChanges = new MIVarChange[0]; public RegisterManager(Session session) { super(session, true); - regList = Collections.synchronizedList(new ArrayList()); + regsMap = new Hashtable(); } + synchronized List getRegistersList(Target target) { + List regsList = (List)regsMap.get(target); + if (regsList == null) { + regsList = Collections.synchronizedList(new ArrayList()); + regsMap.put(target, regsList); + } + return regsList; + } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getRegisterObjects() */ public ICDIRegisterObject[] getRegisterObjects() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + return getRegisterObjects(target); + } + public ICDIRegisterObject[] getRegisterObjects(Target target) throws CDIException { + ICDITarget currentTarget = getSession().getCurrentTarget(); + getSession().setCurrentTarget(target); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIDataListRegisterNames registers = factory.createMIDataListRegisterNames(); try { @@ -68,12 +85,14 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { List regsList = new ArrayList(names.length); for (int i = 0; i < names.length; i++) { if (names[i].length() > 0) { - regsList.add(new RegisterObject(session.getCurrentTarget(), names[i], i)); + regsList.add(new RegisterObject(target, names[i], i)); } } return (ICDIRegisterObject[])regsList.toArray(new ICDIRegisterObject[0]); } catch (MIException e) { throw new MI2CDIException(e); + } finally { + getSession().setCurrentTarget(currentTarget); } } @@ -90,8 +109,8 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { if (reg == null) { try { String name = "$" + regObj.getName(); //$NON-NLS-1$ - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)regObj.getTarget(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarCreate var = factory.createMIVarCreate(name); mi.postCommand(var); @@ -100,6 +119,7 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ } reg = new Register(regObj, info.getMIVar()); + List regList = getRegistersList(target); regList.add(reg); } catch (MIException e) { throw new MI2CDIException(e); @@ -112,6 +132,12 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { public Register createRegister(RegisterObject v, MIVar mivar) throws CDIException { Register reg = new Register(v, mivar); + Target target = (Target)v.getTarget(); + List regList = (List) regsMap.get(target); + if (regList == null) { + regList = Collections.synchronizedList(new ArrayList()); + regsMap.put(target, regList); + } regList.add(reg); return reg; } @@ -120,14 +146,19 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { * @see org.eclipse.cdt.debug.core.cdi.ICDIRegisterManager#destroyRegister(ICDIRegister) */ public void destroyRegister(ICDIRegister reg) { - regList.remove(reg); + Target target = (Target)reg.getTarget(); + List regList = (List)regsMap.get(target); + if (regList != null) { + regList.remove(reg); + } } /** * Use by the eventManager to find the Register; */ - public Register getRegister(String varName) { - Register[] regs = getRegisters(); + public Register getRegister(MISession miSession, String varName) { + Target target = ((Session)getSession()).getTarget(miSession); + Register[] regs = getRegisters(target); for (int i = 0; i < regs.length; i++) { if (regs[i].getMIVar().getVarName().equals(varName)) { return regs[i]; @@ -146,8 +177,12 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { /** * Use by the eventManager to find the Register; */ - public Register getRegister(int regno) { - Register[] regs = getRegisters(); + public Register getRegister(MISession miSession, int regno) { + Target target = ((Session)getSession()).getTarget(miSession); + return getRegister(target, regno); + } + public Register getRegister(Target target, int regno) { + Register[] regs = getRegisters(target); for (int i = 0; i < regs.length; i++) { if (regs[i].getPosition() == regno) { return regs[i]; @@ -157,11 +192,15 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { } /** + * @deprecated * Call the by the EventManager when the target is suspended. */ public void update() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + update(target); + } + public void update(Target target) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIDataListChangedRegisters changed = factory.createMIDataListChangedRegisters(); try { @@ -177,7 +216,7 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { // call -var-update to update the value in gdb. // And send the notification. for (int i = 0 ; i < regnos.length; i++) { - Register reg = getRegister(regnos[i]); + Register reg = getRegister(target, regnos[i]); if (reg != null) { String varName = reg.getMIVar().getVarName(); MIVarChange[] changes = noChanges; @@ -197,12 +236,12 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { for (int j = 0 ; j < changes.length; j++) { String n = changes[j].getVarName(); if (changes[j].isInScope()) { - eventList.add(new MIVarChangedEvent(n)); + eventList.add(new MIVarChangedEvent(mi, n)); } } } else { // Fall back to the register number. - eventList.add(new MIRegisterChangedEvent(update.getToken(), reg.getName(), regnos[i])); + eventList.add(new MIRegisterChangedEvent(mi, update.getToken(), reg.getName(), regnos[i])); } } } @@ -213,13 +252,18 @@ public class RegisterManager extends Manager implements ICDIRegisterManager { } } - private Register[] getRegisters() { - return (Register[])regList.toArray(new Register[0]); + private Register[] getRegisters(Target target) { + List regsList = (List)regsMap.get(target); + if (regsList != null) { + return (Register[]) regsList.toArray(new Register[regsList.size()]); + } + return new Register[0]; } + private Register getRegister(ICDIRegisterObject regObject) throws CDIException { - Register[] regs = getRegisters(); + Register[] regs = getRegisters((Target)regObject.getTarget()); for (int i = 0; i < regs.length; i++) { if (regObject.getName().equals(regs[i].getName())) { return regs[i]; diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java index 14cf9db10fe..617b7449f0a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/RuntimeOptions.java @@ -17,6 +17,7 @@ import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions; 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.Target; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentCD; import org.eclipse.cdt.debug.mi.core.command.MIExecArguments; @@ -37,10 +38,14 @@ public class RuntimeOptions implements ICDIRuntimeOptions { * @see org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions#setArguments(String) */ public void setArguments(String[] args) throws CDIException { + Target target = (Target)session.getCurrentTarget(); + setArguments(target, args); + } + public void setArguments(Target target, String[] args) throws CDIException { if (args == null || args.length == 0) { return; } - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIExecArguments arguments = factory.createMIExecArguments(args); try { @@ -58,10 +63,14 @@ public class RuntimeOptions implements ICDIRuntimeOptions { * @see org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions#setEnvironment(Properties) */ public void setEnvironment(Properties props) throws CDIException { + Target target = (Target)session.getCurrentTarget(); + setEnvironment(target, props); + } + public void setEnvironment(Target target, Properties props) throws CDIException { if (props == null) { return; } - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); Iterator iterator = props.keySet().iterator(); while (iterator.hasNext()) { @@ -90,10 +99,13 @@ public class RuntimeOptions implements ICDIRuntimeOptions { * @see org.eclipse.cdt.debug.core.cdi.ICDIRuntimeOptions#setWorkingDirectory(String) */ public void setWorkingDirectory(String wd) throws CDIException { + Target target = (Target)session.getCurrentTarget(); + } + public void setWorkingDirectory(Target target, String wd) throws CDIException { if (wd == null || wd.length() == 0) { return; } - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIEnvironmentCD cd = factory.createMIEnvironmentCD(wd); try { 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 f314f7e79b5..1488c844b6f 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 @@ -40,7 +40,6 @@ import org.eclipse.cdt.debug.mi.core.command.MIEnvironmentDirectory; public class Session implements ICDISession, ICDISessionObject { Properties props; - MISession session; EventManager eventManager; BreakpointManager breakpointManager; ExpressionManager expressionManager; @@ -51,7 +50,8 @@ public class Session implements ICDISession, ICDISessionObject { SignalManager signalManager; SourceManager sourceManager; ICDIConfiguration configuration; - Target ctarget; + Target[] debugTargets; + Target currentTarget; public Session(MISession s, boolean attach) { commonSetup(s); @@ -63,14 +63,12 @@ public class Session implements ICDISession, ICDISessionObject { configuration = new CoreFileConfiguration(); } - private void commonSetup(MISession s) { - session = s; + private void commonSetup(MISession miSession) { props = new Properties(); breakpointManager = new BreakpointManager(this); eventManager = new EventManager(this); - s.addObserver(eventManager); expressionManager = new ExpressionManager(this); variableManager = new VariableManager(this); @@ -79,11 +77,20 @@ public class Session implements ICDISession, ICDISessionObject { signalManager = new SignalManager(this); sourceManager = new SourceManager(this); sharedLibraryManager = new SharedLibraryManager(this); - ctarget = new Target(this); + currentTarget = new Target(this, miSession); + debugTargets = new Target[] { currentTarget }; + miSession.addObserver(eventManager); } - public MISession getMISession() { - return session; + 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; } /** @@ -160,14 +167,14 @@ public class Session implements ICDISession, ICDISessionObject { * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getTargets() */ public ICDITarget[] getTargets() { - return new ICDITarget[]{ctarget}; + return debugTargets; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getCurrentTarget() */ public ICDITarget getCurrentTarget() { - return ctarget; + return currentTarget; } /** @@ -175,7 +182,7 @@ public class Session implements ICDISession, ICDISessionObject { */ public void setCurrentTarget(ICDITarget target) throws CDIException { if (target instanceof Target) { - ctarget = (Target)target; + currentTarget = (Target)target; } else { throw new CDIException(CdiResources.getString("cdi.Session.Unknown_target")); //$NON-NLS-1$ } @@ -188,13 +195,6 @@ public class Session implements ICDISession, ICDISessionObject { props.setProperty(key, value); } - /** - * @see org.eclipse.cdt.debug.core.cdi.ICDISession#terminate() - */ - public void terminate() throws CDIException { - session.terminate(); - } - /** * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getConfiguration() */ @@ -221,13 +221,39 @@ 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(); + } + //TODO: the ExitEvent is sent by MISession.terminate() + // We nee move it here. + } + /** + * @deprecated + * @see org.eclipse.cdt.debug.core.cdi.ICDISession#terminate(ICDITarget) + */ + public void terminate(ICDITarget target) throws CDIException { + ((Target)target).getMISession().terminate(); + } + + /** + * @deprecated * @see org.eclipse.cdt.debug.core.cdi.ICDISession#addSearchPaths(String[]) */ public void addSearchPaths(String[] dirs) throws CDIException { - CommandFactory factory = session.getCommandFactory(); + addSearchPaths(currentTarget, dirs); + } + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDISession#addSearchPaths(String[]) + */ + public void addSearchPaths(ICDITarget target, String[] dirs) throws CDIException { + MISession miSession = ((Target)target).getMISession(); + CommandFactory factory = miSession.getCommandFactory(); MIEnvironmentDirectory dir = factory.createMIEnvironmentDirectory(dirs); try { - session.postCommand(dir); + miSession.postCommand(dir); dir.getMIInfo(); } catch (MIException e) { throw new MI2CDIException(e); @@ -235,10 +261,19 @@ public class Session implements ICDISession, ICDISessionObject { } /** + * @deprecated * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getSessionProcess() */ public Process getSessionProcess() throws CDIException { - return session.getSessionProcess(); + return getSessionProcess(currentTarget); + } + + /** + * @see org.eclipse.cdt.debug.core.cdi.ICDISession#getSessionProcess() + */ + public Process getSessionProcess(ICDITarget target) throws CDIException { + MISession miSession = ((Target)target).getMISession(); + return miSession.getSessionProcess(); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SessionObject.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SessionObject.java index e52caad1e34..5f07a155c1b 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SessionObject.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SessionObject.java @@ -17,17 +17,17 @@ import org.eclipse.cdt.debug.core.cdi.ICDISessionObject; */ public class SessionObject implements ICDISessionObject { - private Session session; + private Session fSession; public SessionObject (Session session) { - this.session = session; + fSession = session; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDISessionObject#getSession() */ public ICDISession getSession() { - return session; + return fSession; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java index 2a9f9ce548f..bc4e4fe8c31 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SharedLibraryManager.java @@ -13,7 +13,9 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.ArrayList; import java.util.Collections; +import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration; @@ -22,6 +24,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary; 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.SharedLibrary; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIGDBSetAutoSolib; import org.eclipse.cdt.debug.mi.core.command.MIGDBSetSolibSearchPath; @@ -45,21 +48,30 @@ import org.eclipse.cdt.debug.mi.core.output.MIShared; */ public class SharedLibraryManager extends Manager implements ICDISharedLibraryManager { - List sharedList; + ICDISharedLibrary[] EMPTY_SHAREDLIB = {}; + Map sharedMap; boolean isDeferred; public SharedLibraryManager (Session session) { super(session, true); - sharedList = new ArrayList(1); + sharedMap = new Hashtable(); } - MIShared[] getMIShareds() throws CDIException { + synchronized List getSharedList(Target target) { + List sharedList = (List)sharedMap.get(target); + if (sharedList == null) { + sharedList = Collections.synchronizedList(new ArrayList()); + sharedMap.put(target, sharedList); + } + return sharedList; + } + + MIShared[] getMIShareds(MISession miSession) throws CDIException { MIShared[] miLibs = new MIShared[0]; - Session session = (Session)getSession(); - CommandFactory factory = session.getMISession().getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIInfoSharedLibrary infoShared = factory.createMIInfoSharedLibrary(); try { - session.getMISession().postCommand(infoShared); + miSession.postCommand(infoShared); MIInfoSharedLibraryInfo info = infoShared.getMIInfoSharedLibraryInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -72,52 +84,61 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa } /** + * @deprecated * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#update() */ public void update() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - List eventList = updateState(); + Target target = (Target)getSession().getCurrentTarget(); + update(target); + } + public void update(Target target) throws CDIException { + MISession mi = target.getMISession(); + List eventList = updateState(target); MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); mi.fireEvents(events); } - public List updateState() throws CDIException { + public List updateState(Target target) throws CDIException { + MISession miSession = target.getMISession(); Session session = (Session)getSession(); ICDIConfiguration conf = session.getConfiguration(); if (!conf.supportsSharedLibrary()) { return Collections.EMPTY_LIST; // Bail out early; } - MIShared[] miLibs = getMIShareds(); + MIShared[] miLibs = getMIShareds(miSession); ArrayList eventList = new ArrayList(miLibs.length); for (int i = 0; i < miLibs.length; i++) { - ICDISharedLibrary sharedlib = getSharedLibrary(miLibs[i].getName()); + ICDISharedLibrary sharedlib = getSharedLibrary(target, miLibs[i].getName()); if (sharedlib != null) { if (hasSharedLibChanged(sharedlib, miLibs[i])) { // Fire ChangedEvent ((SharedLibrary)sharedlib).setMIShared(miLibs[i]); - eventList.add(new MISharedLibChangedEvent(miLibs[i].getName())); + eventList.add(new MISharedLibChangedEvent(miSession, miLibs[i].getName())); } } else { // add the new breakpoint and fire CreatedEvent - sharedList.add(new SharedLibrary(this, miLibs[i])); - eventList.add(new MISharedLibCreatedEvent(miLibs[i].getName())); + List sharedList = getSharedList(target); + sharedList.add(new SharedLibrary(target, miLibs[i])); + eventList.add(new MISharedLibCreatedEvent(miSession, miLibs[i].getName())); } } // Check if any libraries was unloaded. - ICDISharedLibrary[] oldlibs = (ICDISharedLibrary[])sharedList.toArray(new ICDISharedLibrary[0]); - for (int i = 0; i < oldlibs.length; i++) { - boolean found = false; - for (int j = 0; j < miLibs.length; j++) { - if (miLibs[j].getName().equals(oldlibs[i].getFileName())) { - found = true; - break; + List sharedList = (List)sharedMap.get(target); + if (sharedList != null) { + ICDISharedLibrary[] oldlibs = (ICDISharedLibrary[]) sharedList.toArray(new ICDISharedLibrary[sharedList.size()]); + for (int i = 0; i < oldlibs.length; i++) { + boolean found = false; + for (int j = 0; j < miLibs.length; j++) { + if (miLibs[j].getName().equals(oldlibs[i].getFileName())) { + found = true; + break; + } + } + if (!found) { + // Fire destroyed Events. + eventList.add(new MISharedLibUnloadedEvent(miSession, oldlibs[i].getFileName())); } - } - if (!found) { - // Fire destroyed Events. - eventList.add(new MISharedLibUnloadedEvent(oldlibs[i].getFileName())); } } return eventList; @@ -130,15 +151,29 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa miLib.isRead() != lib.areSymbolsLoaded(); } - public void deleteSharedLibrary(ICDISharedLibrary lib) { - sharedList.remove(lib); + /* + * this for the events + */ + public void deleteSharedLibrary(MISession miSession, ICDISharedLibrary lib) { + Target target = ((Session)getSession()).getTarget(miSession); + List sharedList = (List)sharedMap.get(target); + if (sharedList != null) { + sharedList.remove(lib); + } } - public ICDISharedLibrary getSharedLibrary(String name) { - ICDISharedLibrary[] libs = (ICDISharedLibrary[])sharedList.toArray(new ICDISharedLibrary[0]); - for (int i = 0; i < libs.length; i++) { - if (name.equals(libs[i].getFileName())) { + public ICDISharedLibrary getSharedLibrary(MISession miSession, String name) { + Target target = ((Session)getSession()).getTarget(miSession); + return getSharedLibrary(target, name); + } + public ICDISharedLibrary getSharedLibrary(Target target, String name) { + List sharedList = (List)sharedMap.get(target); + if (sharedList != null) { + ICDISharedLibrary[] libs = (ICDISharedLibrary[]) sharedList.toArray(new ICDISharedLibrary[sharedList.size()]); + for (int i = 0; i < libs.length; i++) { + if (name.equals(libs[i].getFileName())) { return libs[i]; + } } } return null; @@ -156,8 +191,11 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#setSharedLibraryPaths(String[]) */ public void setAutoLoadSymbols(boolean set) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + setAutoLoadSymbols(target, set); + } + public void setAutoLoadSymbols(Target target, boolean set) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIGDBSetAutoSolib solib = factory.createMIGDBSetAutoSolib(set); try { @@ -171,8 +209,11 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa /** */ public boolean isAutoLoadSymbols() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + return isAutoLoadSymbols(target); + } + public boolean isAutoLoadSymbols(Target target) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIGDBShow show = factory.createMIGDBShow(new String[]{"auto-solib-add"}); //$NON-NLS-1$ try { @@ -189,8 +230,11 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa } public void setStopOnSolibEvents(boolean set) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + setStopOnSolibEvents(target, set); + } + public void setStopOnSolibEvents(Target target, boolean set) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIGDBSetStopOnSolibEvents stop = factory.createMIGDBSetStopOnSolibEvents(set); try { @@ -202,8 +246,11 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa } public boolean isStopOnSolibEvents() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + return isStopOnSolibEvents(target); + } + public boolean isStopOnSolibEvents(Target target) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIGDBShow show = factory.createMIGDBShow(new String[]{"stop-on-solib-events"}); //$NON-NLS-1$ try { @@ -223,8 +270,11 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#setSharedLibraryPaths(String[]) */ public void setSharedLibraryPaths(String[] libPaths) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + setSharedLibraryPaths(target, libPaths); + } + public void setSharedLibraryPaths(Target target, String[] libPaths) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIGDBSetSolibSearchPath solib = factory.createMIGDBSetSolibSearchPath(libPaths); try { @@ -239,8 +289,11 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#getSharedLibraryPaths() */ public String[] getSharedLibraryPaths() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + return getSharedLibraryPaths(target); + } + public String[] getSharedLibraryPaths(Target target) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIGDBShowSolibSearchPath dir = factory.createMIGDBShowSolibSearchPath(); try { @@ -256,15 +309,26 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#getSharedLibraries() */ public ICDISharedLibrary[] getSharedLibraries() throws CDIException { - return (ICDISharedLibrary[])sharedList.toArray(new ICDISharedLibrary[0]); + Target target = (Target)getSession().getCurrentTarget(); + return getSharedLibraries(target); + } + public ICDISharedLibrary[] getSharedLibraries(Target target) throws CDIException { + List sharedList = (List)sharedMap.get(target); + if (sharedList != null) { + return (ICDISharedLibrary[]) sharedList.toArray(new ICDISharedLibrary[sharedList.size()]); + } + return EMPTY_SHAREDLIB; } /** * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#loadSymbols() */ public void loadSymbols() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + loadSymbols(target); + } + public void loadSymbols(Target target) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MISharedLibrary sharedlibrary = factory.createMISharedLibrary(); try { @@ -283,16 +347,19 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#loadSymbols(ICDISharedLibrary[]) */ public void loadSymbols(ICDISharedLibrary[] libs) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + Target target = (Target)getSession().getCurrentTarget(); + loadSymbols(target, libs); + } + public void loadSymbols(Target target, ICDISharedLibrary[] libs) throws CDIException { + MISession miSession = target.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); for (int i = 0; i < libs.length; i++) { if (libs[i].areSymbolsLoaded()) { continue; } MISharedLibrary sharedlibrary = factory.createMISharedLibrary(libs[i].getFileName()); try { - session.getMISession().postCommand(sharedlibrary); + miSession.postCommand(sharedlibrary); MIInfo info = sharedlibrary.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -304,23 +371,21 @@ public class SharedLibraryManager extends Manager implements ICDISharedLibraryMa // So we have to manually recheck all the shared with "info shared" //((SharedLibrary)libs[i]).getMIShared().setSymbolsRead(true); //mi.fireEvent(new MISharedLibChangedEvent(libs[i].getFileName())); - update(); + update(target); } } /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#supportsAutoLoadSymbols() */ - public boolean supportsAutoLoadSymbols() - { + public boolean supportsAutoLoadSymbols() { return true; } /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager#supportsStopOnSolibEvents() */ - public boolean supportsStopOnSolibEvents() - { + public boolean supportsStopOnSolibEvents() { return true; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java index 85517196231..e0fd4e92b0c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java @@ -12,7 +12,9 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.ArrayList; import java.util.Collections; +import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISignalManager; @@ -20,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; 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.Signal; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIHandle; import org.eclipse.cdt.debug.mi.core.command.MIInfoSignals; @@ -32,21 +35,30 @@ import org.eclipse.cdt.debug.mi.core.output.MISigHandle; */ public class SignalManager extends Manager implements ICDISignalManager { + ICDISignal[] EMPTY_SIGNALS = {}; MISigHandle[] noSigs = new MISigHandle[0]; - List signalsList = null; + Map signalsMap; public SignalManager(Session session) { super(session, false); + signalsMap = new Hashtable(); } - - MISigHandle[] getMISignals() throws CDIException { - MISigHandle[] miSigs = noSigs; - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + + synchronized List getSignalsList(Target target) { + List signalsList = (List)signalsMap.get(target); + if (signalsList == null) { + signalsList = Collections.synchronizedList(new ArrayList()); + signalsMap.put(target, signalsList); + } + return signalsList; + } + + MISigHandle[] getMISignals(MISession miSession) throws CDIException { + MISigHandle[] miSigs; + CommandFactory factory = miSession.getCommandFactory(); MIInfoSignals sigs = factory.createMIInfoSignals(); try { - mi.postCommand(sigs); + miSession.postCommand(sigs); MIInfoSignalsInfo info = sigs.getMIInfoSignalsInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -58,14 +70,12 @@ public class SignalManager extends Manager implements ICDISignalManager { return miSigs; } - MISigHandle getMISignal(String name) throws CDIException { + MISigHandle getMISignal(MISession miSession, String name) throws CDIException { MISigHandle sig = null; - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIInfoSignals sigs = factory.createMIInfoSignals(name); try { - mi.postCommand(sigs); + miSession.postCommand(sigs); MIInfoSignalsInfo info = sigs.getMIInfoSignalsInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -92,8 +102,9 @@ public class SignalManager extends Manager implements ICDISignalManager { sig.isIgnore() != !miSignal.isPass(); } - public ICDISignal findSignal(String name) { + protected ICDISignal findSignal(Target target, String name) { ICDISignal sig = null; + List signalsList = (List) signalsMap.get(target); if (signalsList != null) { ICDISignal[] sigs = (ICDISignal[])signalsList.toArray(new ICDISignal[0]); for (int i = 0; i < sigs.length; i++) { @@ -106,29 +117,33 @@ public class SignalManager extends Manager implements ICDISignalManager { return sig; } - public ICDISignal getSignal(String name) { - ICDISignal sig = findSignal(name); + public ICDISignal getSignal(MISession miSession, String name) { + Session session = (Session)getSession(); + Target target = session.getTarget(miSession); + return getSignal(target, name); + } + public ICDISignal getSignal(Target target, String name) { + ICDISignal sig = findSignal(target, name); if (sig == null) { MISigHandle miSig = null; try { - miSig = getMISignal(name); - sig = new Signal(this, miSig); - if (signalsList != null) { - signalsList.add(sig); - } + miSig = getMISignal(target.getMISession(), name); + sig = new Signal(target, miSig); + List signalsList = getSignalsList(target); + signalsList.add(sig); } catch (CDIException e) { // The session maybe terminated because of the signal. miSig = new MISigHandle(name, false, false, false, name); - sig = new Signal(this, miSig); + sig = new Signal(target, miSig); } } return sig; } - public void handle(ICDISignal sig, boolean isIgnore, boolean isStop) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + public void handle(Signal sig, boolean isIgnore, boolean isStop) throws CDIException { + Target target = (Target)sig.getTarget(); + MISession miSession = target.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); StringBuffer buffer = new StringBuffer(sig.getName()); buffer.append(" "); //$NON-NLS-1$ if (isIgnore) { @@ -144,51 +159,63 @@ public class SignalManager extends Manager implements ICDISignalManager { } MIHandle handle = factory.createMIHandle(buffer.toString()); try { - mi.postCommand(handle); + miSession.postCommand(handle); handle.getMIInfo(); } catch (MIException e) { throw new MI2CDIException(e); } - ((Signal)sig).getMISignal().handle(isIgnore, isStop); - mi.fireEvent(new MISignalChangedEvent(sig.getName())); + sig.getMISignal().handle(isIgnore, isStop); + miSession.fireEvent(new MISignalChangedEvent(miSession, sig.getName())); } /** * @see org.eclipse.cdt.debug.core.cdi.ICDISignalManager#getSignals() */ public ICDISignal[] getSignals() throws CDIException { - if (signalsList == null) { - update(); - } - return (ICDISignal[])signalsList.toArray(new ICDISignal[0]); + Target target = (Target)getSession().getCurrentTarget(); + return getSignals(target); } + public ICDISignal[] getSignals(Target target) throws CDIException { + List signalsList = (List)signalsMap.get(target); + if (signalsList == null) { + update(target); + } + signalsList = (List)signalsMap.get(target); + if (signalsList != null) { + return (ICDISignal[])signalsList.toArray(new ICDISignal[0]); + } + return EMPTY_SIGNALS; + } /** + * @deprecated * @see org.eclipse.cdt.debug.core.cdi.ICDISignalManager#update() */ public void update() throws CDIException { - Session session = (Session)getSession(); - MISigHandle[] miSigs = getMISignals(); + Target target = (Target)getSession().getCurrentTarget(); + update(target); + } + public void update(Target target) throws CDIException { + MISession miSession = target.getMISession(); + MISigHandle[] miSigs = getMISignals(miSession); List eventList = new ArrayList(miSigs.length); - if (signalsList == null) { - signalsList = Collections.synchronizedList(new ArrayList(5)); - } + List signalsList = getSignalsList(target); for (int i = 0; i < miSigs.length; i++) { - ICDISignal sig = findSignal(miSigs[i].getName()); + ICDISignal sig = findSignal(target, miSigs[i].getName()); if (sig != null) { if (hasSignalChanged(sig, miSigs[i])) { // Fire ChangedEvent ((Signal)sig).setMISignal(miSigs[i]); - eventList.add(new MISignalChangedEvent(miSigs[i].getName())); + eventList.add(new MISignalChangedEvent(miSession, miSigs[i].getName())); } } else { // add the new breakpoint and fire CreatedEvent - signalsList.add(new Signal(this, miSigs[i])); + signalsList.add(new Signal(target, miSigs[i])); + //eventList.add(new MISignCreatedEvent(miSession, miSigs[i].getName())); } } - MISession mi = session.getMISession(); MIEvent[] events = (MIEvent[])eventList.toArray(new MIEvent[0]); - mi.fireEvents(events); + miSession.fireEvents(events); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalReceived.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalReceived.java index 0545fae4b02..c5867dc3b52 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalReceived.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SignalReceived.java @@ -23,7 +23,7 @@ public class SignalReceived extends SessionObject implements ICDISignalReceived public SignalReceived(Session session, MISignalEvent event) { super(session); SignalManager mgr = (SignalManager)session.getSignalManager(); - signal = mgr.getSignal(event.getName()); + signal = mgr.getSignal(event.getMISession(), event.getName()); } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java index d7a6e1311e0..0a8e8489a53 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java @@ -16,7 +16,6 @@ import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDISourceManager; import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction; import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.mi.core.GDBTypeParser; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; @@ -24,6 +23,7 @@ import org.eclipse.cdt.debug.mi.core.GDBTypeParser.GDBDerivedType; import org.eclipse.cdt.debug.mi.core.GDBTypeParser.GDBType; import org.eclipse.cdt.debug.mi.core.cdi.model.Instruction; import org.eclipse.cdt.debug.mi.core.cdi.model.MixedInstruction; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.cdi.model.type.ArrayType; import org.eclipse.cdt.debug.mi.core.cdi.model.type.BoolType; import org.eclipse.cdt.debug.mi.core.cdi.model.type.CharType; @@ -71,8 +71,12 @@ public class SourceManager extends Manager implements ICDISourceManager { * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#addSourcePaths(String[]) */ public void addSourcePaths(String[] dirs) throws CDIException { + Target target = (Target)getSession().getCurrentTarget(); + addSourcePaths(target, dirs); + } + public void addSourcePaths(Target target, String[] dirs) throws CDIException { Session session = (Session)getSession(); - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIEnvironmentDirectory dir = factory.createMIEnvironmentDirectory(dirs); try { @@ -87,8 +91,11 @@ public class SourceManager extends Manager implements ICDISourceManager { * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getSourcePaths() */ public String[] getSourcePaths() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + return getSourcePaths(target); + } + public String[] getSourcePaths(Target target) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIGDBShowDirectories dir = factory.createMIGDBShowDirectories(); try { @@ -104,8 +111,11 @@ public class SourceManager extends Manager implements ICDISourceManager { * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getInstructions(String, int, int) */ public ICDIInstruction[] getInstructions(String filename, int linenum, int lines) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + return getInstructions(target, filename, linenum, lines); + } + public ICDIInstruction[] getInstructions(Target target, String filename, int linenum, int lines) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIDataDisassemble dis = factory.createMIDataDisassemble(filename, linenum, lines, false); try { @@ -114,7 +124,7 @@ public class SourceManager extends Manager implements ICDISourceManager { MIAsm[] asm = info.getMIAsms(); Instruction[] instructions = new Instruction[asm.length]; for (int i = 0; i < instructions.length; i++) { - instructions[i] = new Instruction(session.getCurrentTarget(), asm[i]); + instructions[i] = new Instruction(target, asm[i]); } return instructions; } catch (MIException e) { @@ -133,8 +143,11 @@ public class SourceManager extends Manager implements ICDISourceManager { * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getInstructions(long, long) */ public ICDIInstruction[] getInstructions(long start, long end) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + return getInstructions(target, start, end); + } + public ICDIInstruction[] getInstructions(Target target, long start, long end) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); String hex = "0x"; //$NON-NLS-1$ String sa = hex + Long.toHexString(start); @@ -146,7 +159,7 @@ public class SourceManager extends Manager implements ICDISourceManager { MIAsm[] asm = info.getMIAsms(); Instruction[] instructions = new Instruction[asm.length]; for (int i = 0; i < instructions.length; i++) { - instructions[i] = new Instruction(session.getCurrentTarget(), asm[i]); + instructions[i] = new Instruction(target, asm[i]); } return instructions; } catch (MIException e) { @@ -158,8 +171,11 @@ public class SourceManager extends Manager implements ICDISourceManager { * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getMixedInstructions(String, int, int) */ public ICDIMixedInstruction[] getMixedInstructions(String filename, int linenum, int lines) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + Target target = (Target)getSession().getCurrentTarget(); + return getMixedInstructions(target, filename, linenum, lines); + } + public ICDIMixedInstruction[] getMixedInstructions(Target target, String filename, int linenum, int lines) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIDataDisassemble dis = factory.createMIDataDisassemble(filename, linenum, lines, true); try { @@ -168,7 +184,7 @@ public class SourceManager extends Manager implements ICDISourceManager { MISrcAsm[] srcAsm = info.getMISrcAsms(); ICDIMixedInstruction[] mixed = new ICDIMixedInstruction[srcAsm.length]; for (int i = 0; i < mixed.length; i++) { - mixed[i] = new MixedInstruction(session.getCurrentTarget(), srcAsm[i]); + mixed[i] = new MixedInstruction(target, srcAsm[i]); } return mixed; } catch (MIException e) { @@ -186,9 +202,12 @@ public class SourceManager extends Manager implements ICDISourceManager { /** * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#getMixedInstructions(long, long) */ - public ICDIMixedInstruction[] getMixedInstructions(long start, long end) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + public ICDIMixedInstruction[] getMixedInstructions(long start, long end) throws CDIException { + Target target = (Target)getSession().getCurrentTarget(); + return getMixedInstructions(target, start, end); + } + public ICDIMixedInstruction[] getMixedInstructions(Target target, long start, long end) throws CDIException { + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); String hex = "0x"; //$NON-NLS-1$ String sa = hex + Long.toHexString(start); @@ -200,7 +219,7 @@ public class SourceManager extends Manager implements ICDISourceManager { MISrcAsm[] srcAsm = info.getMISrcAsms(); ICDIMixedInstruction[] mixed = new ICDIMixedInstruction[srcAsm.length]; for (int i = 0; i < mixed.length; i++) { - mixed[i] = new MixedInstruction(session.getCurrentTarget(), srcAsm[i]); + mixed[i] = new MixedInstruction(target, srcAsm[i]); } return mixed; } catch (MIException e) { @@ -209,13 +228,16 @@ public class SourceManager extends Manager implements ICDISourceManager { } /** + * @deprecated * @see org.eclipse.cdt.debug.core.cdi.ICDISourceManager#update() */ public void update() throws CDIException { } + public void update(Target target) throws CDIException { + } - public Type getType(ICDITarget target, String name) throws CDIException { + public Type getType(Target target, String name) throws CDIException { if (name == null) { name = new String(); } @@ -265,7 +287,7 @@ public class SourceManager extends Manager implements ICDISourceManager { throw new CDIException(CdiResources.getString("cdi.SourceManager.Unknown_type")); //$NON-NLS-1$ } - Type toCDIType(ICDITarget target, String name) throws CDIException { + Type toCDIType(Target target, String name) throws CDIException { // Check the derived types and agregate types if (name == null) { name = new String(); @@ -430,10 +452,9 @@ public class SourceManager extends Manager implements ICDISourceManager { throw new CDIException(CdiResources.getString("cdi.SourceManager.Unknown_type")); //$NON-NLS-1$ } - public String getDetailTypeName(String typename) throws CDIException { + public String getDetailTypeName(Target target, String typename) throws CDIException { try { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIPType ptype = factory.createMIPType(typename); mi.postCommand(ptype); @@ -447,10 +468,9 @@ public class SourceManager extends Manager implements ICDISourceManager { } } - public String getTypeName(String variable) throws CDIException { + public String getTypeName(Target target, String variable) throws CDIException { try { - Session session = (Session) getSession(); - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIWhatis whatis = factory.createMIWhatis(variable); mi.postCommand(whatis); diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ThreadManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ThreadManager.java index 8537afac581..1af55a02742 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ThreadManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/ThreadManager.java @@ -13,10 +13,10 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.HashMap; import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.mi.core.MIException; 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.cdi.model.Thread; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIInfoThreads; @@ -54,7 +54,7 @@ public class ThreadManager extends Manager { //implements ICDIThreadManager { /** * @see org.eclipse.cdt.debug.core.cdi.ICDIThreadManager#getThreads() */ - public ICDIThread[] getThreads(ICDITarget process) throws CDIException { + public ICDIThread[] getThreads(Target process) throws CDIException { ThreadSet set = (ThreadSet)threadMap.get(process); if (set == null) { set = getCThreads(process); @@ -63,10 +63,10 @@ public class ThreadManager extends Manager { //implements ICDIThreadManager { return set.currentThreads; } - public ThreadSet getCThreads(ICDITarget process) throws CDIException { + public ThreadSet getCThreads(Target process) throws CDIException { Thread[] cthreads = noThreads; int currentThreadId = 0; - MISession mi = ((Session)getSession()).getMISession(); + MISession mi = process.getMISession(); CommandFactory factory = mi.getCommandFactory(); try { // HACK/FIXME: gdb/mi thread-list-ids does not @@ -107,6 +107,7 @@ public class ThreadManager extends Manager { //implements ICDIThreadManager { } /** + * @deprecated * @see org.eclipse.cdt.derug.core.cdi.ICDIThreadManager#update() */ public void update() throws CDIException { 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 e07101f3845..74837ade7bd 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 @@ -12,7 +12,9 @@ package org.eclipse.cdt.debug.mi.core.cdi; import java.util.ArrayList; import java.util.Collections; +import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager; @@ -27,6 +29,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.Target; import org.eclipse.cdt.debug.mi.core.cdi.model.Variable; import org.eclipse.cdt.debug.mi.core.cdi.model.VariableObject; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; @@ -53,24 +56,38 @@ import org.eclipse.cdt.debug.mi.core.output.MIVarUpdateInfo; */ public class VariableManager extends Manager implements ICDIVariableManager { + static final ICDIVariable[] EMPTY_VARIABLES = {}; // We put a restriction on how deep we want to // go when doing update of the variables. // If the number is to high, gdb will just hang. int MAX_STACK_DEPTH = 200; - List variableList; + Map variablesMap; MIVarChange[] noChanges = new MIVarChange[0]; public VariableManager(Session session) { super(session, true); - variableList = Collections.synchronizedList(new ArrayList()); + variablesMap = new Hashtable(); + } + + synchronized List getVariablesList(Target target) { + List variablesList = (List) variablesMap.get(target); + if (variablesList == null) { + variablesList = Collections.synchronizedList(new ArrayList()); + variablesMap.put(target, variablesList); + } + return variablesList; } /** * Return the element that have the uniq varName. * null is return if the element is not in the cache. */ - public Variable getVariable(String varName) { - Variable[] vars = getVariables(); + public Variable getVariable(MISession miSession, String varName) { + Target target = ((Session)getSession()).getTarget(miSession); + return getVariable(target, varName); + } + public Variable getVariable(Target target, String varName) { + Variable[] vars = getVariables(target); for (int i = 0; i < vars.length; i++) { if (vars[i].getMIVar().getVarName().equals(varName)) { return vars[i]; @@ -88,11 +105,12 @@ public class VariableManager extends Manager implements ICDIVariableManager { * null is return if the element is not in the cache. */ Variable findVariable(VariableObject v) throws CDIException { + Target target = (Target)v.getTarget(); ICDIStackFrame stack = v.getStackFrame(); String name = v.getName(); int position = v.getPosition(); int depth = v.getStackDepth(); - Variable[] vars = getVariables(); + Variable[] vars = getVariables(target); for (int i = 0; i < vars.length; i++) { if (vars[i].getName().equals(name) && vars[i].getCastingArrayStart() == v.getCastingArrayStart() @@ -119,20 +137,23 @@ public class VariableManager extends Manager implements ICDIVariableManager { /** * Returns all the elements that are in the cache. */ - Variable[] getVariables() { - return (Variable[]) variableList.toArray(new Variable[0]); + Variable[] getVariables(Target target) { + List variableList = (List)variablesMap.get(target); + if (variableList != null) { + return (Variable[]) variableList.toArray(new Variable[variableList.size()]); + } + return new Variable[0]; } /** * Check the type */ - public void checkType(String type) throws CDIException { + public void checkType(MISession miSession, String type) throws CDIException { if (type != null && type.length() > 0) { try { - MISession mi = ((Session) getSession()).getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIPType ptype = factory.createMIPType(type); - mi.postCommand(ptype); + miSession.postCommand(ptype); MIPTypeInfo info = ptype.getMIPtypeInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -148,13 +169,11 @@ public class VariableManager extends Manager implements ICDIVariableManager { /** * Tell gdb to remove the underlying var-object also. */ - void removeMIVar(MIVar miVar) throws CDIException { - Session session = (Session) getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + void removeMIVar(MISession miSession, MIVar miVar) throws CDIException { + CommandFactory factory = miSession.getCommandFactory(); MIVarDelete var = factory.createMIVarDelete(miVar.getVarName()); try { - mi.postCommand(var); + miSession.postCommand(var); var.getMIInfo(); } catch (MIException e) { throw new MI2CDIException(e); @@ -166,12 +185,19 @@ public class VariableManager extends Manager implements ICDIVariableManager { * because they are still needed for the destroy events. The destroy event will * call removeOutOfScope. */ - public void removeVariable(String varName) throws CDIException { - Variable[] vars = getVariables(); + public void removeVariable(MISession miSession, String varName) throws CDIException { + Target target = ((Session)getSession()).getTarget(miSession); + removeVariable(target, varName); + } + public void removeVariable(Target target, String varName) throws CDIException { + Variable[] vars = getVariables(target); for (int i = 0; i < vars.length; i++) { if (vars[i].getMIVar().getVarName().equals(varName)) { - variableList.remove(vars[i]); - removeMIVar(vars[i].getMIVar()); + List variableList = (List)variablesMap.get(target); + if (variableList != null) { + variableList.remove(vars[i]); + } + removeMIVar(target.getMISession(), vars[i].getMIVar()); } } } @@ -203,7 +229,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { stack.getThread().setCurrentStackFrame(stack, false); } try { - MISession mi = session.getMISession(); + Target target = (Target)argObj.getTarget(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarCreate var = factory.createMIVarCreate(name); mi.postCommand(var); @@ -212,7 +239,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ } argument = new Argument(argObj, info.getMIVar()); - variableList.add(argument); + List variablesList = getVariablesList(target); + variablesList.add(argument); } catch (MIException e) { throw new MI2CDIException(e); } finally { @@ -237,7 +265,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); frame.getThread().setCurrentStackFrame(frame, false); try { - MISession mi = session.getMISession(); + Target target = (Target)frame.getTarget(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); int depth = frame.getThread().getStackFrameCount(); int level = frame.getLevel(); @@ -255,9 +284,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { args = miFrames[0].getArgs(); } if (args != null) { - ICDITarget tgt = frame.getThread().getTarget(); for (int i = 0; i < args.length; i++) { - ArgumentObject arg = new ArgumentObject(tgt, args[i].getName(), frame, args.length - i, level); + ArgumentObject arg = new ArgumentObject(target, args[i].getName(), frame, args.length - i, level); argObjects.add(arg); } } @@ -273,6 +301,10 @@ public class VariableManager extends Manager implements ICDIVariableManager { * @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#getGlobalVariableObject(String, String, String) */ public ICDIVariableObject getGlobalVariableObject(String filename, String function, String name) throws CDIException { + Target target = (Target)getSession().getCurrentTarget(); + return getGlobalVariableObject(target, filename, function, name); + } + public ICDIVariableObject getGlobalVariableObject(Target target, String filename, String function, String name) throws CDIException { if (filename == null) { filename = new String(); } @@ -290,7 +322,6 @@ public class VariableManager extends Manager implements ICDIVariableManager { buffer.append(function).append("::"); //$NON-NLS-1$ } buffer.append(name); - ICDITarget target = getSession().getCurrentTarget(); return new VariableObject(target, buffer.toString(), null, 0, 0); } @@ -306,7 +337,7 @@ public class VariableManager extends Manager implements ICDIVariableManager { if (obj != null) { VariableObject vo = new VariableObject( - obj.getTarget(), + (Target)obj.getTarget(), obj.getName(), obj.getFullName(), obj.getStackFrame(), @@ -329,10 +360,11 @@ public class VariableManager extends Manager implements ICDIVariableManager { } if (obj != null) { // throw an exception if not a good type. - checkType(type); + Target target = (Target)obj.getTarget(); + checkType(target.getMISession(), type); VariableObject vo = new VariableObject( - obj.getTarget(), + target, obj.getName(), obj.getFullName(), obj.getStackFrame(), @@ -359,7 +391,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { ICDIStackFrame currentFrame = currentThread.getCurrentStackFrame(); frame.getThread().setCurrentStackFrame(frame, false); try { - MISession mi = session.getMISession(); + Target target = (Target)frame.getTarget(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); int level = frame.getLevel(); MIArg[] args = null; @@ -371,9 +404,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { } args = info.getLocals(); if (args != null) { - ICDITarget tgt = frame.getThread().getTarget(); for (int i = 0; i < args.length; i++) { - VariableObject varObj = new VariableObject(tgt, args[i].getName(), frame, args.length - i, level); + VariableObject varObj = new VariableObject(target, args[i].getName(), frame, args.length - i, level); varObjects.add(varObj); } } @@ -420,7 +452,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { stack.getThread().setCurrentStackFrame(stack, false); } try { - MISession mi = session.getMISession(); + Target target = (Target)varObj.getTarget(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarCreate var = factory.createMIVarCreate(name); mi.postCommand(var); @@ -429,7 +462,8 @@ public class VariableManager extends Manager implements ICDIVariableManager { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ } variable = new Variable(varObj, info.getMIVar()); - variableList.add(variable); + List variablesList = getVariablesList(target); + variablesList.add(variable); } catch (MIException e) { throw new MI2CDIException(e); } finally { @@ -450,9 +484,9 @@ public class VariableManager extends Manager implements ICDIVariableManager { if (var instanceof Variable) { // Fire a destroyEvent ? Variable variable = (Variable) var; - MIVarDeletedEvent del = new MIVarDeletedEvent(variable.getMIVar().getVarName()); - Session session = (Session) getSession(); - MISession mi = session.getMISession(); + Target target = (Target)variable.getTarget(); + MISession mi = target.getMISession(); + MIVarDeletedEvent del = new MIVarDeletedEvent(mi, variable.getMIVar().getVarName()); mi.fireEvent(del); } } @@ -466,35 +500,36 @@ public class VariableManager extends Manager implements ICDIVariableManager { * the other locals in different frames. The downside if any side effects we loose, * This ok, since the IDE only a frame at a time. * + * @deprecated * @see org.eclipse.cdt.debug.core.cdi.ICDIVariableManager#createArgument(ICDIArgumentObject) */ public void update() throws CDIException { + Target target = (Target)getSession().getCurrentTarget(); + update(target); + } + public void update(Target target) throws CDIException { int high = 0; int low = 0; List eventList = new ArrayList(); - Session session = (Session) getSession(); - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); - Variable[] vars = getVariables(); - ICDITarget currentTarget = session.getCurrentTarget(); + Variable[] vars = getVariables(target); ICDIStackFrame[] frames = null; ICDIStackFrame currentStack = null; - if (currentTarget != null) { - ICDIThread currentThread = currentTarget.getCurrentThread(); - if (currentThread != null) { - currentStack = currentThread.getCurrentStackFrame(); - if (currentStack != null) { - high = currentStack.getLevel(); - } - if (high > 0) { - high--; - } - low = high - MAX_STACK_DEPTH; - if (low < 0) { - low = 0; - } - frames = currentThread.getStackFrames(low, high); + ICDIThread currentThread = target.getCurrentThread(); + if (currentThread != null) { + currentStack = currentThread.getCurrentStackFrame(); + if (currentStack != null) { + high = currentStack.getLevel(); } + if (high > 0) { + high--; + } + low = high - MAX_STACK_DEPTH; + if (low < 0) { + low = 0; + } + frames = currentThread.getStackFrames(low, high); } for (int i = 0; i < vars.length; i++) { Variable variable = vars[i]; @@ -511,14 +546,14 @@ public class VariableManager extends Manager implements ICDIVariableManager { changes = info.getMIVarChanges(); } catch (MIException e) { //throw new MI2CDIException(e); - eventList.add(new MIVarDeletedEvent(varName)); + eventList.add(new MIVarDeletedEvent(mi, varName)); } for (int j = 0; j < changes.length; j++) { String n = changes[j].getVarName(); if (changes[j].isInScope()) { - eventList.add(new MIVarChangedEvent(n)); + eventList.add(new MIVarChangedEvent(mi, n)); } else { - eventList.add(new MIVarDeletedEvent(n)); + eventList.add(new MIVarDeletedEvent(mi, n)); } } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/WatchpointScope.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/WatchpointScope.java index bab08d086cb..da8ab9a83f4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/WatchpointScope.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/WatchpointScope.java @@ -34,7 +34,7 @@ public class WatchpointScope extends SessionObject implements ICDIWatchpointScop // Ask the breakpointManager for the breakpoint BreakpointManager mgr = (BreakpointManager)getSession().getBreakpointManager(); // We need to return the same object as the reason. - Watchpoint point = mgr.getWatchpoint(number); + Watchpoint point = mgr.getWatchpoint(watchEvent.getMISession(), number); // FIXME: if point ==null ??? Create a new breakpoint ? return point; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/WatchpointTrigger.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/WatchpointTrigger.java index d02be3cc309..cafa9cf573a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/WatchpointTrigger.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/WatchpointTrigger.java @@ -48,7 +48,7 @@ public class WatchpointTrigger extends SessionObject implements ICDIWatchpointTr // Ask the breakpointManager for the breakpoint BreakpointManager mgr = (BreakpointManager)getSession().getBreakpointManager(); // We need to return the same object as the reason. - Watchpoint point = mgr.getWatchpoint(number); + Watchpoint point = mgr.getWatchpoint(watchEvent.getMISession(), number); // FIXME: if point ==null ??? Create a new breakpoint ? return point; } 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 c9a20a4bef8..d88a0a51030 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 @@ -23,6 +23,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager; import org.eclipse.cdt.debug.mi.core.cdi.SignalManager; 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.MIBreakpointChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MIRegisterChangedEvent; import org.eclipse.cdt.debug.mi.core.event.MISharedLibChangedEvent; @@ -42,23 +43,23 @@ public class ChangedEvent implements ICDIChangedEvent { // Try the Variable manager. VariableManager mgr = (VariableManager)session.getVariableManager(); String varName = var.getVarName(); - source = mgr.getVariable(varName); + source = mgr.getVariable(var.getMISession(), varName); // Try the Expression manager if (source == null) { ExpressionManager expMgr = (ExpressionManager)session.getExpressionManager(); - source = expMgr.getExpression(varName); + source = expMgr.getExpression(var.getMISession(), varName); } // Try the Register manager if (source == null) { RegisterManager regMgr = (RegisterManager)session.getRegisterManager(); - source = regMgr.getRegister(varName); + source = regMgr.getRegister(var.getMISession(), varName); } // Fall back if (source == null) { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -66,9 +67,9 @@ public class ChangedEvent implements ICDIChangedEvent { session = s; RegisterManager mgr = (RegisterManager)session.getRegisterManager(); int regno = var.getNumber(); - source = mgr.getRegister(regno); + source = mgr.getRegister(var.getMISession(), regno); if (source == null) { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -76,11 +77,11 @@ public class ChangedEvent implements ICDIChangedEvent { session = s; BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager(); int number = bpoint.getNumber(); - ICDIBreakpoint breakpoint = mgr.getBreakpoint(number); + ICDIBreakpoint breakpoint = mgr.getBreakpoint(bpoint.getMISession(), number); if (breakpoint != null) { source = breakpoint; } else { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -88,11 +89,11 @@ public class ChangedEvent implements ICDIChangedEvent { session = s; SharedLibraryManager mgr = (SharedLibraryManager)session.getSharedLibraryManager(); String name = slib.getName(); - ICDISharedLibrary lib = mgr.getSharedLibrary(name); + ICDISharedLibrary lib = mgr.getSharedLibrary(slib.getMISession(), name); if (lib != null) { source = lib; } else { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -100,11 +101,11 @@ public class ChangedEvent implements ICDIChangedEvent { session = s; SignalManager mgr = (SignalManager)session.getSignalManager(); String name = sig.getName(); - ICDISignal signal = mgr.getSignal(name); + ICDISignal signal = mgr.getSignal(sig.getMISession(), name); if (signal != null) { source = signal; } else { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } 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 991e23c4f9e..3190a66a4a1 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 @@ -39,9 +39,9 @@ public class CreatedEvent implements ICDICreatedEvent { session = s; BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager(); int number = bpoint.getNumber(); - source = mgr.getBreakpoint(number); + source = mgr.getBreakpoint(bpoint.getMISession(), number); if (source == null) { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -49,9 +49,9 @@ public class CreatedEvent implements ICDICreatedEvent { session = s; VariableManager mgr = (VariableManager)session.getVariableManager(); String varName = var.getVarName(); - source = mgr.getVariable(varName); + source = mgr.getVariable(var.getMISession(), varName); if (source == null) { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -59,9 +59,9 @@ public class CreatedEvent implements ICDICreatedEvent { session = s; RegisterManager mgr = (RegisterManager)session.getRegisterManager(); int regno = var.getNumber(); - source = mgr.getRegister(regno); + source = mgr.getRegister(var.getMISession(), regno); if (source == null) { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -70,14 +70,14 @@ public class CreatedEvent implements ICDICreatedEvent { Target target = (Target)session.getCurrentTarget(); source = target.getThread(ethread.getId()); if (source == null) { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } public CreatedEvent(Session s, MIMemoryCreatedEvent mblock) { session = s; MemoryManager mgr = (MemoryManager)session.getMemoryManager(); - ICDIMemoryBlock[] blocks = mgr.listMemoryBlocks(); + ICDIMemoryBlock[] blocks = mgr.getMemoryBlocks(mblock.getMISession()); for (int i = 0; i < blocks.length; i++) { if (blocks[i].getStartAddress() == mblock.getAddress() && blocks[i].getLength() == mblock.getLength()) { @@ -86,7 +86,7 @@ public class CreatedEvent implements ICDICreatedEvent { } } if (source == null) { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -94,9 +94,9 @@ public class CreatedEvent implements ICDICreatedEvent { session = s; SharedLibraryManager mgr = (SharedLibraryManager)session.getSharedLibraryManager(); String name = slib.getName(); - source = mgr.getSharedLibrary(name); + source = mgr.getSharedLibrary(slib.getMISession(), name); if (source == null) { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } 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 6b83e8fb386..4884c800940 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 @@ -21,6 +21,7 @@ import org.eclipse.cdt.debug.mi.core.cdi.SharedLibraryManager; import org.eclipse.cdt.debug.mi.core.cdi.VariableManager; import org.eclipse.cdt.debug.mi.core.cdi.model.Breakpoint; 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.cdi.model.Thread; import org.eclipse.cdt.debug.mi.core.cdi.model.Variable; import org.eclipse.cdt.debug.mi.core.event.MIBreakpointDeletedEvent; @@ -37,31 +38,31 @@ public class DestroyedEvent implements ICDIDestroyedEvent { public DestroyedEvent(Session s, MIThreadExitEvent ethread) { session = s; - source = new Thread(session.getCurrentTarget(), ethread.getId()); + source = new Thread((Target)session.getCurrentTarget(), ethread.getId()); } public DestroyedEvent(Session s, MIVarDeletedEvent var) { session = s; VariableManager varMgr = (VariableManager)session.getVariableManager(); String varName = var.getVarName(); - Variable variable = varMgr.getVariable(varName); + Variable variable = varMgr.getVariable(var.getMISession(), varName); if (variable!= null) { source = variable; try { - varMgr.removeVariable(variable.getMIVar().getVarName()); + varMgr.removeVariable(var.getMISession(), variable.getMIVar().getVarName()); } catch (CDIException e) { } } else { ExpressionManager expMgr = (ExpressionManager)session.getExpressionManager(); - variable = expMgr.getExpression(varName); + variable = expMgr.getExpression(var.getMISession(), varName); if (variable != null) { source = variable; try { - expMgr.removeExpression(variable.getMIVar().getVarName()); + expMgr.removeExpression(var.getMISession(), variable.getMIVar().getVarName()); } catch (CDIException e) { } } else { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } } @@ -70,12 +71,12 @@ public class DestroyedEvent implements ICDIDestroyedEvent { session = s; BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager(); int number = bpoint.getNumber(); - Breakpoint breakpoint = mgr.getBreakpoint(number); + Breakpoint breakpoint = mgr.getBreakpoint(bpoint.getMISession(), number); if (breakpoint != null) { source = breakpoint; - mgr.deleteBreakpoint(number); + mgr.deleteBreakpoint(bpoint.getMISession(), number); } else { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } @@ -83,12 +84,12 @@ public class DestroyedEvent implements ICDIDestroyedEvent { session = s; SharedLibraryManager mgr = (SharedLibraryManager)session.getSharedLibraryManager(); String name = slib.getName(); - ICDISharedLibrary lib = mgr.getSharedLibrary(name); + ICDISharedLibrary lib = mgr.getSharedLibrary(slib.getMISession(), name); if (lib != null) { - mgr.deleteSharedLibrary(lib); + mgr.deleteSharedLibrary(slib.getMISession(), lib); source = lib; } else { - source = new CObject(session.getCurrentTarget()); + source = new CObject((Target)session.getCurrentTarget()); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/ArgumentObject.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/ArgumentObject.java index 20bad93733f..27fe78cc05d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/ArgumentObject.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/ArgumentObject.java @@ -13,13 +13,12 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; 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; /** */ public class ArgumentObject extends VariableObject implements ICDIArgumentObject { - public ArgumentObject(ICDITarget target, String name, ICDIStackFrame frame, int pos, int depth) { + public ArgumentObject(Target target, String name, ICDIStackFrame frame, int pos, int depth) { super(target, name, frame, pos, depth); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java index 4edaeb908e4..e9286afe62a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Breakpoint.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager; import org.eclipse.cdt.debug.mi.core.cdi.Condition; import org.eclipse.cdt.debug.mi.core.cdi.Location; +import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint; /** @@ -27,14 +28,14 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { ICDILocation location; ICDICondition condition; MIBreakpoint miBreakpoint; - BreakpointManager mgr; + //BreakpointManager mgr; int type; String tid; boolean enable; - public Breakpoint(BreakpointManager m, int kind, ICDILocation loc, ICDICondition cond, String threadId) { - super(m.getSession().getCurrentTarget()); - mgr = m; + public Breakpoint(Target target, int kind, ICDILocation loc, ICDICondition cond, String threadId) { + super(target); + //mgr = m; type = kind; location = loc; condition = cond; @@ -42,10 +43,10 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { enable = true; } - public Breakpoint(BreakpointManager m, MIBreakpoint miBreak) { - super(m.getSession().getCurrentTarget()); + public Breakpoint(Target target, MIBreakpoint miBreak) { + super(target); miBreakpoint = miBreak; - mgr = m; + //mgr = m; } public MIBreakpoint getMIBreakpoint() { @@ -119,6 +120,8 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#setCondition(ICDICondition) */ public void setCondition(ICDICondition condition) throws CDIException { + Session session = (Session)getTarget().getSession(); + BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager(); if (isEnabled()) { mgr.setCondition(this, condition); } @@ -129,6 +132,8 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint { * @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpoint#setEnabled(boolean) */ public void setEnabled(boolean on) throws CDIException { + Session session = (Session)getTarget().getSession(); + BreakpointManager mgr = (BreakpointManager)session.getBreakpointManager(); if (miBreakpoint != null) { if (on == false && isEnabled() == true) { mgr.disableBreakpoint(this); diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/CObject.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/CObject.java index 5683bb74aad..21f29c4691d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/CObject.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/CObject.java @@ -17,17 +17,17 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; */ public class CObject implements ICDIObject { - ICDITarget target; + private Target fTarget; - public CObject(ICDITarget t) { - target = t; + public CObject(Target t) { + fTarget = t; } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getTarget() */ public ICDITarget getTarget() { - return target; + return fTarget; } } 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 index c534c3b1aae..92ebfc1fe1f 100644 --- 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 @@ -13,15 +13,14 @@ 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.cdi.BreakpointManager; import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint; /** */ public class Catchpoint extends Breakpoint implements ICDICatchpoint { - public Catchpoint(BreakpointManager m, MIBreakpoint miBreak) { - super(m, miBreak); + public Catchpoint(Target target, MIBreakpoint miBreak) { + super(target, miBreak); } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Instruction.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Instruction.java index c8c07925c45..48e5cb95a02 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Instruction.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Instruction.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.mi.core.output.MIAsm; /** @@ -20,7 +19,7 @@ public class Instruction extends CObject implements ICDIInstruction { MIAsm asm; - public Instruction(ICDITarget target, MIAsm a) { + public Instruction(Target target, MIAsm a) { super(target); asm = a; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/MemoryBlock.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/MemoryBlock.java index 1c8a18301cc..6d1f4a73149 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/MemoryBlock.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/MemoryBlock.java @@ -16,14 +16,12 @@ import java.util.List; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MIFormat; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.CdiResources; import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException; import org.eclipse.cdt.debug.mi.core.cdi.MemoryManager; -import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIDataWriteMemory; import org.eclipse.cdt.debug.mi.core.output.MIDataReadMemoryInfo; @@ -39,7 +37,7 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock { boolean frozen; boolean dirty; - public MemoryBlock(ICDITarget target, String exp, MIDataReadMemoryInfo info) { + public MemoryBlock(Target target, String exp, MIDataReadMemoryInfo info) { super(target); expression = exp; mem = info; @@ -129,16 +127,18 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock { * @see org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock#refresh() */ public void refresh() throws CDIException { - MemoryManager mgr = (MemoryManager)getTarget().getSession().getMemoryManager(); + Target target = (Target)getTarget(); + MemoryManager mgr = (MemoryManager)target.getSession().getMemoryManager(); setDirty(true); Long[] addresses = mgr.update(this, null); // Check if this affects other blocks. if (addresses.length > 0) { - MemoryBlock[] blocks = mgr.listMemoryBlocks(); + MemoryBlock[] blocks = mgr.getMemoryBlocks(target.getMISession()); for (int i = 0; i < blocks.length; i++) { - if (! blocks[i].equals(this) && blocks[i].contains(addresses)) { - blocks[i].setDirty(true); - mgr.update(blocks[i], null); + MemoryBlock block = blocks[i]; + if (! block.equals(this) && block.contains(addresses)) { + block.setDirty(true); + mgr.update(block, null); } } } @@ -179,16 +179,15 @@ public class MemoryBlock extends CObject implements ICDIMemoryBlock { if (offset >= getLength() || offset + bytes.length > getLength()) { throw new CDIException(CdiResources.getString("cdi.model.MemoryBlock.Bad_Offset")); //$NON-NLS-1$ } - Session session = (Session)getTarget().getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + MISession miSession = ((Target)getTarget()).getMISession(); + CommandFactory factory = miSession.getCommandFactory(); for (int i = 0; i < bytes.length; i++) { long l = new Byte(bytes[i]).longValue() & 0xff; String value = "0x" + Long.toHexString(l); //$NON-NLS-1$ MIDataWriteMemory mw = factory.createMIDataWriteMemory(offset + i, expression, MIFormat.HEXADECIMAL, 1, value); try { - mi.postCommand(mw); + miSession.postCommand(mw); MIInfo info = mw.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/MixedInstruction.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/MixedInstruction.java index f0f93c25031..2dd7865dad9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/MixedInstruction.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/MixedInstruction.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction; import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.mi.core.output.MIAsm; import org.eclipse.cdt.debug.mi.core.output.MISrcAsm; @@ -22,7 +21,7 @@ public class MixedInstruction extends CObject implements ICDIMixedInstruction { MISrcAsm srcAsm; - public MixedInstruction (ICDITarget target, MISrcAsm a) { + public MixedInstruction (Target target, MISrcAsm a) { super(target); srcAsm = a; } @@ -41,7 +40,7 @@ public class MixedInstruction extends CObject implements ICDIMixedInstruction { MIAsm[] asms = srcAsm.getMIAsms(); ICDIInstruction[] instructions = new ICDIInstruction[asms.length]; for (int i = 0; i < asms.length; i++) { - instructions[i] = new Instruction(getTarget(), asms[i]); + instructions[i] = new Instruction((Target)getTarget(), asms[i]); } return instructions; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java index 1fff84fda98..99712587123 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Register.java @@ -18,7 +18,6 @@ import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.CdiResources; import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException; import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager; -import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIVarListChildren; import org.eclipse.cdt.debug.mi.core.output.MIVar; @@ -46,40 +45,39 @@ public class Register extends Variable implements ICDIRegister { } public ICDIVariable[] getChildren() throws CDIException { - Session session = (Session)(getTarget().getSession()); - MISession mi = session.getMISession(); - RegisterManager mgr = (RegisterManager)session.getRegisterManager(); - CommandFactory factory = mi.getCommandFactory(); - MIVarListChildren var = + Target target = (Target)getTarget(); + MISession miSession = target.getMISession(); + RegisterManager mgr = (RegisterManager)target.getSession().getRegisterManager(); + CommandFactory factory = miSession.getCommandFactory(); + MIVarListChildren var = factory.createMIVarListChildren(getMIVar().getVarName()); - try { - mi.postCommand(var); - MIVarListChildrenInfo info = var.getMIVarListChildrenInfo(); - if (info == null) { - throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ - } - MIVar[] vars = info.getMIVars(); - children = new Register[vars.length]; - for (int i = 0; i < vars.length; i++) { - String fn; - String exp = vars[i].getExp(); - if (isCPPLanguage()) { - if ((exp.equals("private") || exp.equals("public") || exp.equals("protected"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - fn = getFullName(); - } else { - fn = getFullName() + "." + exp; //$NON-NLS-1$ - } + try { + miSession.postCommand(var); + MIVarListChildrenInfo info = var.getMIVarListChildrenInfo(); + if (info == null) { + throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ + } + MIVar[] vars = info.getMIVars(); + children = new Register[vars.length]; + for (int i = 0; i < vars.length; i++) { + String fn; + String exp = vars[i].getExp(); + if (isCPPLanguage()) { + if ((exp.equals("private") || exp.equals("public") || exp.equals("protected"))) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + fn = getFullName(); } else { fn = getFullName() + "." + exp; //$NON-NLS-1$ } - RegisterObject regObj = new RegisterObject(getTarget(), - exp, fn, getPosition()); - children[i] = mgr.createRegister(regObj, vars[i]); + } else { + fn = getFullName() + "." + exp; //$NON-NLS-1$ } - } catch (MIException e) { - throw new MI2CDIException(e); + RegisterObject regObj = new RegisterObject(target, exp, fn, getPosition()); + children[i] = mgr.createRegister(regObj, vars[i]); } - return children; + } catch (MIException e) { + throw new MI2CDIException(e); + } + return children; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterObject.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterObject.java index 1f11de96686..ecb9d7dfc02 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterObject.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/RegisterObject.java @@ -12,17 +12,16 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; /** */ public class RegisterObject extends VariableObject implements ICDIRegisterObject { - public RegisterObject(ICDITarget target, String name, int i) { + public RegisterObject(Target target, String name, int i) { super(target, name, null, i, 0); } - public RegisterObject(ICDITarget target, String name, String fn, int i) { + public RegisterObject(Target target, String name, String fn, int i) { super(target, name, fn, null, i, 0); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/SharedLibrary.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/SharedLibrary.java index 86137c33b4a..0edb1bc9202 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/SharedLibrary.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/SharedLibrary.java @@ -13,20 +13,20 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary; +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.output.MIShared; + /** * Place holder for shared library info. */ public class SharedLibrary extends CObject implements ICDISharedLibrary { - SharedLibraryManager mgr; MIShared miShared; - public SharedLibrary(SharedLibraryManager m, MIShared slib) { - super(m.getSession().getCurrentTarget()); - mgr = m; + public SharedLibrary(Target target, MIShared slib) { + super(target); miShared = slib; } @@ -69,7 +69,9 @@ public class SharedLibrary extends CObject implements ICDISharedLibrary { * @see org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary#loadSymbols() */ public void loadSymbols() throws CDIException { - mgr.loadSymbols(new ICDISharedLibrary[] { this }); + Target target = (Target)getTarget(); + SharedLibraryManager mgr = (SharedLibraryManager)((Session)target.getSession()).getSharedLibraryManager(); + mgr.loadSymbols(target, new ICDISharedLibrary[] { this }); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Signal.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Signal.java index e2c26bc6225..d30b8ce169b 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Signal.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Signal.java @@ -19,12 +19,10 @@ import org.eclipse.cdt.debug.mi.core.output.MISigHandle; */ public class Signal extends CObject implements ICDISignal { - SignalManager mgr; MISigHandle sig; - public Signal(SignalManager m, MISigHandle s) { - super(m.getSession().getCurrentTarget()); - mgr = m; + public Signal(Target target, MISigHandle s) { + super(target); sig = s; } @@ -54,6 +52,7 @@ public class Signal extends CObject implements ICDISignal { * @see org.eclipse.cdt.debug.core.cdi.ICDISignal#handle() */ public void handle(boolean ignore, boolean stop) throws CDIException { + SignalManager mgr = (SignalManager)getTarget().getSession().getSignalManager(); mgr.handle(this, ignore, stop); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java index 1efa44ec7dd..415779c9fe3 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/StackFrame.java @@ -57,7 +57,7 @@ public class StackFrame extends CObject implements ICDIStackFrame { frame={level="1 ",addr="0x42017499",func="__libc_start_main",from="/lib/i686/libc.so.6"}] */ public StackFrame(Thread thread, MIFrame f, int l) { - super(thread.getTarget()); + super((Target)thread.getTarget()); cthread = thread; frame = f; level = l; diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java index 38cfc3b3b3c..216587517e6 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java @@ -14,13 +14,18 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDILocation; import org.eclipse.cdt.debug.core.cdi.ICDISession; +import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; +import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; 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.ICDIWatchpoint; import org.eclipse.cdt.debug.mi.core.MIException; 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.MI2CDIException; import org.eclipse.cdt.debug.mi.core.cdi.RegisterManager; import org.eclipse.cdt.debug.mi.core.cdi.Session; @@ -57,24 +62,26 @@ import org.eclipse.cdt.debug.mi.core.cdi.CdiResources; public class Target implements ICDITarget { Session session; + MISession miSession; Thread[] noThreads = new Thread[0]; Thread[] currentThreads; int currentThreadId; Command lastExecutionCommand; - public Target(Session s) { + public Target(Session s, MISession mi) { session = s; + miSession = mi; currentThreads = noThreads; } - - public Session getCSession() { - return session; - } public Command getLastExecutionCommand() { return lastExecutionCommand; } + public MISession getMISession() { + return miSession; + } + /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getSession() */ @@ -121,11 +128,10 @@ public class Target implements ICDITarget { } // already the current thread? if (currentThreadId != id) { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIThreadSelect select = factory.createMIThreadSelect(id); try { - mi.postCommand(select); + miSession.postCommand(select); MIThreadSelectInfo info = select.getMIThreadSelectInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -148,13 +154,15 @@ public class Target implements ICDITarget { // some variables like Register. Call an update() // To generate changeEvents. if (doUpdate) { + // TODO: only our Process RegisterManager regMgr = (RegisterManager)session.getRegisterManager(); if (regMgr.isAutoUpdate()) { - regMgr.update(); + regMgr.update(this); } + // TODO: only our Process VariableManager varMgr = (VariableManager)session.getVariableManager(); if (varMgr.isAutoUpdate()) { - varMgr.update(); + varMgr.update(this); } } } @@ -162,8 +170,7 @@ public class Target implements ICDITarget { // We should be allright now. if (currentThreadId != id) { // thread is gone. Generate a Thread destroyed. - MISession mi = session.getMISession(); - mi.fireEvent(new MIThreadExitEvent(id)); + miSession.fireEvent(new MIThreadExitEvent(miSession, id)); throw new CDIException(CdiResources.getString("cdi.model.Target.Cannot_switch_to_thread") + id); //$NON-NLS-1$ } } @@ -208,9 +215,8 @@ public class Target implements ICDITarget { MIThreadCreatedEvent[] events = new MIThreadCreatedEvent[cList.size()]; for (int j = 0; j < events.length; j++) { int id = ((Integer)cList.get(j)).intValue(); - events[j] = new MIThreadCreatedEvent(id); + events[j] = new MIThreadCreatedEvent(miSession, id); } - MISession miSession = session.getMISession(); miSession.fireEvents(events); } @@ -232,9 +238,8 @@ public class Target implements ICDITarget { MIThreadExitEvent[] events = new MIThreadExitEvent[dList.size()]; for (int j = 0; j < events.length; j++) { int id = ((Integer)dList.get(j)).intValue(); - events[j] = new MIThreadExitEvent(id); + events[j] = new MIThreadExitEvent(miSession, id); } - MISession miSession = session.getMISession(); miSession.fireEvents(events); } } @@ -244,8 +249,7 @@ public class Target implements ICDITarget { */ public Thread[] getCThreads() throws CDIException { Thread[] cthreads = noThreads; - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIInfoThreads tids = factory.createMIInfoThreads(); try { // HACK/FIXME: gdb/mi thread-list-ids does not @@ -253,7 +257,7 @@ public class Target implements ICDITarget { // issuing "info threads" instead. //MIThreadListIds tids = factory.createMIThreadListIds(); //MIThreadListIdsInfo info = tids.getMIThreadListIdsInfo(); - mi.postCommand(tids); + miSession.postCommand(tids); MIInfoThreadsInfo info = tids.getMIInfoThreadsInfo(); int [] ids; String[] names; @@ -335,12 +339,11 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#restart() */ public void restart() throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIExecRun run = factory.createMIExecRun(new String[0]); lastExecutionCommand = run; try { - mi.postCommand(run); + miSession.postCommand(run); MIInfo info = run.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -354,15 +357,14 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#resume() */ public void resume() throws CDIException { - MISession mi = session.getMISession(); - if (mi.getMIInferior().isRunning()) { + if (miSession.getMIInferior().isRunning()) { throw new CDIException(CdiResources.getString("cdi.model.Target.Inferior_already_running")); //$NON-NLS-1$ - } else if (mi.getMIInferior().isSuspended()) { - CommandFactory factory = mi.getCommandFactory(); + } else if (miSession.getMIInferior().isSuspended()) { + CommandFactory factory = miSession.getCommandFactory(); MIExecContinue cont = factory.createMIExecContinue(); lastExecutionCommand = cont; try { - mi.postCommand(cont); + miSession.postCommand(cont); MIInfo info = cont.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -370,7 +372,7 @@ public class Target implements ICDITarget { } catch (MIException e) { throw new MI2CDIException(e); } - } else if (mi.getMIInferior().isTerminated()) { + } else if (miSession.getMIInferior().isTerminated()) { restart(); } else { restart(); @@ -381,12 +383,11 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#stepInto() */ public void stepInto() throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIExecStep step = factory.createMIExecStep(); lastExecutionCommand = step; try { - mi.postCommand(step); + miSession.postCommand(step); MIInfo info = step.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -400,12 +401,11 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#stepIntoInstruction() */ public void stepIntoInstruction() throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIExecStepInstruction stepi = factory.createMIExecStepInstruction(); lastExecutionCommand = stepi; try { - mi.postCommand(stepi); + miSession.postCommand(stepi); MIInfo info = stepi.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -419,12 +419,11 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#stepOver() */ public void stepOver() throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIExecNext next = factory.createMIExecNext(); lastExecutionCommand = next; try { - mi.postCommand(next); + miSession.postCommand(next); MIInfo info = next.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -438,12 +437,11 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#stepOverInstruction() */ public void stepOverInstruction() throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIExecNextInstruction nexti = factory.createMIExecNextInstruction(); lastExecutionCommand = nexti; try { - mi.postCommand(nexti); + miSession.postCommand(nexti); MIInfo info = nexti.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -474,12 +472,11 @@ public class Target implements ICDITarget { /** */ protected void finish() throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIExecFinish finish = factory.createMIExecFinish(); lastExecutionCommand = finish; try { - mi.postCommand(finish); + miSession.postCommand(finish); MIInfo info = finish.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -492,12 +489,11 @@ public class Target implements ICDITarget { /** */ protected void execReturn() throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIExecReturn ret = factory.createMIExecReturn(); lastExecutionCommand = ret; try { - mi.postCommand(ret); + miSession.postCommand(ret); MIInfo info = ret.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -511,9 +507,8 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#suspend() */ public void suspend() throws CDIException { - MISession mi = session.getMISession(); try { - mi.getMIInferior().interrupt(); + miSession.getMIInferior().interrupt(); } catch (MIException e) { throw new MI2CDIException(e); } @@ -523,11 +518,10 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#disconnect() */ public void disconnect() throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MITargetDetach detach = factory.createMITargetDetach(); try { - mi.postCommand(detach); + miSession.postCommand(detach); MIInfo info = detach.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -537,17 +531,15 @@ public class Target implements ICDITarget { } // Unfortunately -target-detach does not generate an // event so we do it here. - MISession miSession = session.getMISession(); - miSession.fireEvent(new MIDetachedEvent(detach.getToken())); - session.getMISession().getMIInferior().setDisconnected(); + miSession.fireEvent(new MIDetachedEvent(miSession, detach.getToken())); + miSession.getMIInferior().setDisconnected(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#runUntil(ICDILocation) */ public void runUntil(ICDILocation location) throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); String loc = ""; //$NON-NLS-1$ if (location.getFile() != null && location.getFile().length() > 0) { loc = location.getFile() + ":" + location.getLineNumber(); //$NON-NLS-1$ @@ -559,7 +551,7 @@ public class Target implements ICDITarget { MIExecUntil until = factory.createMIExecUntil(loc); lastExecutionCommand = until; try { - mi.postCommand(until); + miSession.postCommand(until); MIInfo info = until.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -574,8 +566,7 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#jump(ICDILocation) */ public void jump(ICDILocation location) throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); String loc = ""; //$NON-NLS-1$ if (location.getFile() != null && location.getFile().length() > 0) { loc = location.getFile() + ":" + location.getLineNumber(); //$NON-NLS-1$ @@ -587,7 +578,7 @@ public class Target implements ICDITarget { MIJump jump = factory.createMIJump(loc); lastExecutionCommand = jump; try { - mi.postCommand(jump); + miSession.postCommand(jump); MIInfo info = jump.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -602,12 +593,11 @@ public class Target implements ICDITarget { */ public String evaluateExpressionToString(String expressionText) throws CDIException { - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIDataEvaluateExpression evaluate = factory.createMIDataEvaluateExpression(expressionText); try { - mi.postCommand(evaluate); + miSession.postCommand(evaluate); MIDataEvaluateExpressionInfo info = evaluate.getMIDataEvaluateExpressionInfo(); if (info == null) { @@ -624,9 +614,11 @@ public class Target implements ICDITarget { */ public void terminate() throws CDIException { try { - session.getMISession().getMIInferior().terminate(); + miSession.getMIInferior().terminate(); } catch (MIException e) { - session.terminate(); + throw new MI2CDIException(e); + } finally { + miSession.terminate(); } } @@ -634,44 +626,42 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#isTerminated() */ public boolean isTerminated() { - return session.getMISession().getMIInferior().isTerminated(); + return miSession.getMIInferior().isTerminated(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#isDisconnected() */ public boolean isDisconnected() { - return !session.getMISession().getMIInferior().isConnected(); + return !miSession.getMIInferior().isConnected(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#isSuspended() */ public boolean isSuspended() { - return session.getMISession().getMIInferior().isSuspended(); + return miSession.getMIInferior().isSuspended(); } public boolean isRunning() { - return session.getMISession().getMIInferior().isRunning(); + return miSession.getMIInferior().isRunning(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#getProcess() */ public Process getProcess() { - return session.getMISession().getMIInferior(); + return miSession.getMIInferior(); } /** * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#signal() */ public void signal() throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MISignal signal = factory.createMISignal("0"); //$NON-NLS-1$ try { - mi.postCommand(signal); + miSession.postCommand(signal); MIInfo info = signal.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -685,12 +675,10 @@ public class Target implements ICDITarget { * @see org.eclipse.cdt.debug.core.cdi.model.ICDITarget#signal(ICDISignal) */ public void signal(ICDISignal signal) throws CDIException { - Session session = (Session)getSession(); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MISignal sig = factory.createMISignal(signal.getName()); try { - mi.postCommand(sig); + miSession.postCommand(sig); MIInfo info = sig.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.model.Target.Target_not_responding")); //$NON-NLS-1$ @@ -700,4 +688,38 @@ public class Target implements ICDITarget { } } + // Implementaton of ICDIBreapointManagement. + + + public ICDIBreakpoint[] getBreakpoints() throws CDIException { + BreakpointManager bMgr = (BreakpointManager)getSession().getBreakpointManager(); + return bMgr.getBreakpoints(this); + } + + public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, + ICDICondition condition, String threadId, boolean deferred) throws CDIException { + BreakpointManager bMgr = (BreakpointManager)getSession().getBreakpointManager(); + return bMgr.setLocationBreakpoint(this, type, location, condition, threadId, deferred); + } + + public ICDIWatchpoint setWatchpoint(int type, int watchType, String expression, + ICDICondition condition) throws CDIException { + BreakpointManager bMgr = (BreakpointManager)getSession().getBreakpointManager(); + return bMgr.setWatchpoint(this, type, watchType, expression, condition); + } + + public void deleteBreakpoints(ICDIBreakpoint[] breakpoints) throws CDIException { + BreakpointManager bMgr = (BreakpointManager)getSession().getBreakpointManager(); + bMgr.deleteBreakpoints(this, breakpoints); + } + + public void deleteAllBreakpoints() throws CDIException { + BreakpointManager bMgr = (BreakpointManager)getSession().getBreakpointManager(); + bMgr.deleteAllBreakpoints(this); + } + +// public ICDIExceptionBreakpoint setExceptionBreakpoint(String clazz, boolean stopOnThrow, boolean stopOnCatch) +// throws CDIException { +// throw new CDIException("Not Implemented"); //$NON-NLS-1$ +// } } 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 bdcac2fe406..e06af32e35e 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 @@ -14,10 +14,12 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.cdt.debug.core.cdi.CDIException; +import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.ICDILocation; +import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; +import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint; import org.eclipse.cdt.debug.core.cdi.model.ICDISignal; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; @@ -48,11 +50,11 @@ public class Thread extends CObject implements ICDIThread { final static int STACKFRAME_DEFAULT_DEPTH = 200; - public Thread(ICDITarget target, int threadId) { + public Thread(Target target, int threadId) { this(target, threadId, null); } - public Thread(ICDITarget target, int threadId, String threadName) { + public Thread(Target target, int threadId, String threadName) { super(target); id = threadId; name = threadName; @@ -104,12 +106,13 @@ public class Thread extends CObject implements ICDIThread { // refresh if we have nothing or if we have just a subset get everything. if (currentFrames == null || currentFrames.size() < depth) { currentFrames = new ArrayList(); - Session session = (Session) getTarget().getSession(); + Target target = (Target)getTarget(); + Session session = (Session) target.getSession(); Target currentTarget = (Target) session.getCurrentTarget(); ICDIThread currentThread = currentTarget.getCurrentThread(); currentTarget.setCurrentThread(this, false); try { - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIStackListFrames frames = factory.createMIStackListFrames(); mi.postCommand(frames); @@ -148,12 +151,13 @@ public class Thread extends CObject implements ICDIThread { */ public int getStackFrameCount() throws CDIException { if (stackdepth == 0) { - Session session = (Session) (getTarget().getSession()); + Target target = (Target)getTarget(); + Session session = (Session) (target.getSession()); Target currentTarget = (Target) session.getCurrentTarget(); ICDIThread currentThread = currentTarget.getCurrentThread(); currentTarget.setCurrentThread(this, false); try { - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIStackInfoDepth depth = factory.createMIStackInfoDepth(); mi.postCommand(depth); @@ -193,7 +197,8 @@ public class Thread extends CObject implements ICDIThread { public ICDIStackFrame[] getStackFrames(int low, int high) throws CDIException { if (currentFrames == null || currentFrames.size() < high) { currentFrames = new ArrayList(); - Session session = (Session) getTarget().getSession(); + Target target = (Target) getTarget(); + Session session = (Session) target.getSession(); Target currentTarget = (Target) session.getCurrentTarget(); ICDIThread currentThread = currentTarget.getCurrentThread(); currentTarget.setCurrentThread(this, false); @@ -209,7 +214,7 @@ public class Thread extends CObject implements ICDIThread { } else { upperBound = depth; } - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); MIStackListFrames frames = factory.createMIStackListFrames(0, upperBound); mi.postCommand(frames); @@ -268,8 +273,9 @@ public class Thread extends CObject implements ICDIThread { } try { - Session session = (Session) getTarget().getSession(); - MISession mi = session.getMISession(); + 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 // See comment in StackFrame constructor. @@ -289,11 +295,11 @@ public class Thread extends CObject implements ICDIThread { if (doUpdate) { RegisterManager regMgr = (RegisterManager) session.getRegisterManager(); if (regMgr.isAutoUpdate()) { - regMgr.update(); + regMgr.update(target); } VariableManager varMgr = (VariableManager) session.getVariableManager(); if (varMgr.isAutoUpdate()) { - varMgr.update(); + varMgr.update(target); } } } catch (MIException e) { @@ -415,4 +421,30 @@ public class Thread extends CObject implements ICDIThread { return super.equals(thread); } + public ICDIBreakpoint[] getBreakpoints() throws CDIException { + Target target = (Target)getTarget(); + ICDIBreakpoint[] bps = target.getBreakpoints(); + ArrayList list = new ArrayList(bps.length); + for (int i = 0; i < bps.length; i++) { + String threadId = bps[i].getThreadId(); + int tid = 0; + try { + tid = Integer.parseInt(threadId); + } catch (NumberFormatException e) { + // + } + if (tid == getId()) { + list.add(bps[i]); + } + } + return (ICDIBreakpoint[]) list.toArray(new ICDIBreakpoint[list.size()]); + } + + public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location, + ICDICondition condition, boolean deferred) throws CDIException { + Target target = (Target)getTarget(); + String threadId = Integer.toString(getId()); + return target.setLocationBreakpoint(type, location, condition, threadId, deferred); + } + } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Value.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Value.java index 3313ed8e541..05f72176305 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Value.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Value.java @@ -16,7 +16,6 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.CdiResources; -import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIVarEvaluateExpression; import org.eclipse.cdt.debug.mi.core.output.MIVarEvaluateExpressionInfo; @@ -28,7 +27,7 @@ public class Value extends CObject implements ICDIValue { protected Variable variable; public Value(Variable v) { - super(v.getTarget()); + super((Target)v.getTarget()); variable = v; } @@ -44,7 +43,7 @@ public class Value extends CObject implements ICDIValue { */ public String getValueString() throws CDIException { String result = ""; //$NON-NLS-1$ - MISession mi = ((Session)(getTarget().getSession())).getMISession(); + MISession mi = ((Target)getTarget()).getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarEvaluateExpression var = factory.createMIVarEvaluateExpression(variable.getMIVar().getVarName()); diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java index e39f0e5f120..0f21fce64ab 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Variable.java @@ -15,7 +15,6 @@ import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager; import org.eclipse.cdt.debug.core.cdi.ICDIRegisterManager; import org.eclipse.cdt.debug.core.cdi.ICDIVariableManager; 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.ICDIValue; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType; @@ -39,7 +38,6 @@ import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.cdi.CdiResources; import org.eclipse.cdt.debug.mi.core.cdi.Format; import org.eclipse.cdt.debug.mi.core.cdi.MI2CDIException; -import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.cdi.model.type.ArrayValue; import org.eclipse.cdt.debug.mi.core.cdi.model.type.BoolValue; import org.eclipse.cdt.debug.mi.core.cdi.model.type.CharValue; @@ -84,7 +82,7 @@ public class Variable extends VariableObject implements ICDIVariable { miVar = v; } - public Variable(ICDITarget target, String n, String q, ICDIStackFrame stack, int pos, int depth, MIVar v) { + public Variable(Target target, String n, String q, ICDIStackFrame stack, int pos, int depth, MIVar v) { super(target, n, q, stack, pos, depth); miVar = v; } @@ -110,8 +108,7 @@ public class Variable extends VariableObject implements ICDIVariable { String getLanguage() throws CDIException { if (language == null) { - Session session = (Session) (getTarget().getSession()); - MISession mi = session.getMISession(); + MISession mi = ((Target)getTarget()).getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarInfoExpression var = factory.createMIVarInfoExpression(getMIVar().getVarName()); try { @@ -150,8 +147,7 @@ public class Variable extends VariableObject implements ICDIVariable { * allow the override of the timeout. */ public ICDIVariable[] getChildren(int timeout) throws CDIException { - Session session = (Session) (getTarget().getSession()); - MISession mi = session.getMISession(); + MISession mi = ((Target)getTarget()).getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarListChildren var = factory.createMIVarListChildren(getMIVar().getVarName()); try { @@ -223,7 +219,7 @@ public class Variable extends VariableObject implements ICDIVariable { fn = "(" + fn + ")." + vars[i].getExp(); //$NON-NLS-1$ //$NON-NLS-2$ } } - Variable v = new Variable(getTarget(), childName, fn, getStackFrame(), getPosition(), getStackDepth(), vars[i]); + Variable v = new Variable((Target)getTarget(), childName, fn, getStackFrame(), getPosition(), getStackDepth(), vars[i]); if (childType != null) { // Hack to reset the typename to a known value v.type = childType; @@ -295,12 +291,12 @@ public class Variable extends VariableObject implements ICDIVariable { * @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(String) */ public void setValue(String expression) throws CDIException { - Session session = (Session) (getTarget().getSession()); - MISession mi = session.getMISession(); - CommandFactory factory = mi.getCommandFactory(); + Target target = (Target)getTarget(); + MISession miSession = target.getMISession(); + CommandFactory factory = miSession.getCommandFactory(); MIVarAssign var = factory.createMIVarAssign(miVar.getVarName(), expression); try { - mi.postCommand(var); + miSession.postCommand(var); MIInfo info = var.getMIInfo(); if (info == null) { throw new CDIException(CdiResources.getString("cdi.Common.No_answer")); //$NON-NLS-1$ @@ -311,8 +307,8 @@ public class Variable extends VariableObject implements ICDIVariable { // If the assign was succesfull fire a MIVarChangedEvent() for the variable // Note GDB will not fire an event for the changed variable we have to do it manually. - MIVarChangedEvent change = new MIVarChangedEvent(var.getToken(), miVar.getVarName()); - mi.fireEvent(change); + MIVarChangedEvent change = new MIVarChangedEvent(miSession, var.getToken(), miVar.getVarName()); + miSession.fireEvent(change); // Changing values may have side effects i.e. affecting other variables // if the manager is on autoupdate check all the other variables. @@ -320,20 +316,20 @@ public class Variable extends VariableObject implements ICDIVariable { if (this instanceof Register) { // If register was on autoupdate, update all the other registers // assigning may have side effects i.e. affecting other registers. - ICDIRegisterManager mgr = session.getRegisterManager(); + ICDIRegisterManager mgr = target.getSession().getRegisterManager(); if (mgr.isAutoUpdate()) { mgr.update(); } } else if (this instanceof Expression) { // If expression was on autoupdate, update all the other expression // assigning may have side effects i.e. affecting other expressions. - ICDIExpressionManager mgr = session.getExpressionManager(); + ICDIExpressionManager mgr = target.getSession().getExpressionManager(); if (mgr.isAutoUpdate()) { mgr.update(); } } else { // FIXME: Should we always call the Variable Manager ? - ICDIVariableManager mgr = session.getVariableManager(); + ICDIVariableManager mgr = target.getSession().getVariableManager(); if (mgr.isAutoUpdate()) { mgr.update(); } @@ -347,7 +343,7 @@ public class Variable extends VariableObject implements ICDIVariable { */ public boolean isEditable() throws CDIException { if (editable == null) { - MISession mi = ((Session) (getTarget().getSession())).getMISession(); + MISession mi = ((Target) getTarget()).getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarShowAttributes var = factory.createMIVarShowAttributes(miVar.getVarName()); try { @@ -369,7 +365,7 @@ public class Variable extends VariableObject implements ICDIVariable { */ public void setFormat(int format) throws CDIException { int fmt = Format.toMIFormat(format); - MISession mi = ((Session) (getTarget().getSession())).getMISession(); + MISession mi = ((Target) getTarget()).getMISession(); CommandFactory factory = mi.getCommandFactory(); MIVarSetFormat var = factory.createMIVarSetFormat(miVar.getVarName(), fmt); try { diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java index d72abcf78d8..712ca708657 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/VariableObject.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.CDIException; 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.ICDIVariableObject; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFunctionType; @@ -57,7 +56,7 @@ public class VariableObject extends CObject implements ICDIVariableObject { * @param obj */ public VariableObject(VariableObject obj) { - super(obj.getTarget()); + super((Target)obj.getTarget()); name = obj.getName(); fullName = obj.fullName; sizeof = obj.sizeof; @@ -73,11 +72,11 @@ public class VariableObject extends CObject implements ICDIVariableObject { castingType = obj.getCastingType(); } - public VariableObject(ICDITarget target, String n, ICDIStackFrame stack, int pos, int depth) { + public VariableObject(Target target, String n, ICDIStackFrame stack, int pos, int depth) { this(target, n, null, stack, pos, depth); } - public VariableObject(ICDITarget target, String n, String fn, ICDIStackFrame stack, int pos, int depth) { + public VariableObject(Target target, String n, String fn, ICDIStackFrame stack, int pos, int depth) { super(target); name = n; fullName = fn; @@ -161,23 +160,23 @@ public class VariableObject extends CObject implements ICDIVariableObject { */ public ICDIType getType() throws CDIException { if (type == null) { - ICDITarget target = getTarget(); + Target target = (Target)getTarget(); Session session = (Session) (target.getSession()); SourceManager sourceMgr = (SourceManager) session.getSourceManager(); - String nametype = sourceMgr.getTypeName(getQualifiedName()); + String nametype = sourceMgr.getTypeName(target, getQualifiedName()); try { type = sourceMgr.getType(target, nametype); } catch (CDIException e) { // Try with ptype. try { - String ptype = sourceMgr.getDetailTypeName(nametype); + String ptype = sourceMgr.getDetailTypeName(target, nametype); type = sourceMgr.getType(target, ptype); } catch (CDIException ex) { // Some version of gdb does not work woth the name of the class // ex: class data foo --> ptype data --> fails // ex: class data foo --> ptype foo --> succeed try { - String ptype = sourceMgr.getDetailTypeName(getQualifiedName()); + String ptype = sourceMgr.getDetailTypeName(target, getQualifiedName()); type = sourceMgr.getType(target, ptype); } catch (CDIException e2) { // give up. @@ -196,9 +195,9 @@ public class VariableObject extends CObject implements ICDIVariableObject { */ public int sizeof() throws CDIException { if (sizeof == null) { - ICDITarget target = getTarget(); + Target target = (Target) getTarget(); Session session = (Session) (target.getSession()); - MISession mi = session.getMISession(); + MISession mi = target.getMISession(); CommandFactory factory = mi.getCommandFactory(); String exp = "sizeof(" + getTypeName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ MIDataEvaluateExpression evaluate = factory.createMIDataEvaluateExpression(exp); diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java index bfbe8470f1e..303ab38ab14 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.debug.mi.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.CDIException; import org.eclipse.cdt.debug.core.cdi.ICDICondition; import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint; -import org.eclipse.cdt.debug.mi.core.cdi.BreakpointManager; import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint; /** @@ -23,14 +22,14 @@ public class Watchpoint extends Breakpoint implements ICDIWatchpoint { int watchType; String what; - public Watchpoint(BreakpointManager m, String expression, int type, int wType, ICDICondition cond) { - super(m, type, null, cond, ""); //$NON-NLS-1$ + public Watchpoint(Target target, String expression, int type, int wType, ICDICondition cond) { + super(target, type, null, cond, ""); //$NON-NLS-1$ watchType = wType; what = expression; } - public Watchpoint(BreakpointManager m, MIBreakpoint miBreak) { - super(m, miBreak); + public Watchpoint(Target target, MIBreakpoint miBreak) { + super(target, miBreak); } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/AggregateType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/AggregateType.java index 677c22ba25d..566c226499b 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/AggregateType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/AggregateType.java @@ -11,14 +11,14 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIAggregateType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ public abstract class AggregateType extends Type implements ICDIAggregateType { - public AggregateType(ICDITarget target, String typename) { + public AggregateType(Target target, String typename) { super(target, typename); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayType.java index dee455bf943..5b63362e4e6 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ArrayType.java @@ -11,9 +11,9 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -24,7 +24,7 @@ public class ArrayType extends DerivedType implements ICDIArrayType { /** * @param typename */ - public ArrayType(ICDITarget target, String typename,int dim) { + public ArrayType(Target target, String typename,int dim) { super(target, typename); dimension = dim; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/BoolType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/BoolType.java index bedff753750..d258b1216f4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/BoolType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/BoolType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIBoolType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class BoolType extends IntegralType implements ICDIBoolType { /** * @param typename */ - public BoolType(ICDITarget target, String typename) { + public BoolType(Target target, String typename) { this(target, typename, false); } - public BoolType(ICDITarget target, String typename, boolean usigned) { + public BoolType(Target target, String typename, boolean usigned) { super(target, typename, usigned); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/CharType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/CharType.java index 3829c6f44d4..9575d2055e9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/CharType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/CharType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDICharType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class CharType extends IntegralType implements ICDICharType { /** * @param typename */ - public CharType(ICDITarget target, String typename) { + public CharType(Target target, String typename) { this(target, typename, false); } - public CharType(ICDITarget target, String typename, boolean usigned) { + public CharType(Target target, String typename, boolean usigned) { super(target, typename, usigned); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DerivedType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DerivedType.java index 89ba36d6173..ce7b77a31c7 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DerivedType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DerivedType.java @@ -12,11 +12,11 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; import org.eclipse.cdt.debug.core.cdi.CDIException; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; import org.eclipse.cdt.debug.mi.core.cdi.Session; import org.eclipse.cdt.debug.mi.core.cdi.SourceManager; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -24,7 +24,7 @@ public abstract class DerivedType extends Type implements ICDIDerivedType { ICDIType derivedType; - public DerivedType(ICDITarget target, String typename) { + public DerivedType(Target target, String typename) { super(target, typename); } @@ -33,7 +33,7 @@ public abstract class DerivedType extends Type implements ICDIDerivedType { } public void setComponentType(String name) { - ICDITarget target = getTarget(); + Target target = (Target)getTarget(); Session session = (Session)(target.getSession()); SourceManager sourceMgr = (SourceManager)session.getSourceManager(); try { @@ -41,13 +41,13 @@ public abstract class DerivedType extends Type implements ICDIDerivedType { } catch (CDIException e) { // Try after ptype. try { - String ptype = sourceMgr.getDetailTypeName(name); + String ptype = sourceMgr.getDetailTypeName(target, name); derivedType = sourceMgr.getType(target, ptype); } catch (CDIException ex) { } } if (derivedType == null) { - derivedType = new IncompleteType(getTarget(), name); + derivedType = new IncompleteType(target, name); } } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DoubleType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DoubleType.java index 9f88d69a80b..483e1ec8196 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DoubleType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/DoubleType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class DoubleType extends FloatingPointType implements ICDIDoubleType { /** * @param typename */ - public DoubleType(ICDITarget target, String typename) { + public DoubleType(Target target, String typename) { this(target, typename, false, false, false); } - public DoubleType(ICDITarget target, String typename, boolean isComplex, boolean isImg, boolean isLong) { + public DoubleType(Target target, String typename, boolean isComplex, boolean isImg, boolean isLong) { super(target, typename, isComplex, isImg, isLong); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/EnumType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/EnumType.java index 634dad8c3fc..0db2216899c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/EnumType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/EnumType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIEnumType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class EnumType extends IntegralType implements ICDIEnumType { /** * @param typename */ - public EnumType(ICDITarget target, String typename) { + public EnumType(Target target, String typename) { this(target, typename, false); } - public EnumType(ICDITarget target, String typename, boolean usigned) { + public EnumType(Target target, String typename, boolean usigned) { super(target, typename, usigned); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatType.java index 4e39d460fff..f67a66311f7 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class FloatType extends FloatingPointType implements ICDIFloatType { /** * @param typename */ - public FloatType(ICDITarget target, String typename) { + public FloatType(Target target, String typename) { this(target, typename, false, false); } - public FloatType(ICDITarget target, String typename, boolean isComplex, boolean isImg) { + public FloatType(Target target, String typename, boolean isComplex, boolean isImg) { super(target, typename, isComplex, isImg, false); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointType.java index 86e1a113be0..cb4223cb80c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FloatingPointType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -22,7 +22,7 @@ public abstract class FloatingPointType extends Type implements ICDIFloatingPoin boolean imaginary; boolean islong; - public FloatingPointType(ICDITarget target, String typename, boolean comp, boolean img, boolean l) { + public FloatingPointType(Target target, String typename, boolean comp, boolean img, boolean l) { super(target, typename); complex = comp; imaginary = img; diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FunctionType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FunctionType.java index a4e3bb388c1..375e433fc3e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FunctionType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/FunctionType.java @@ -11,9 +11,9 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFunctionType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,7 +21,7 @@ public class FunctionType extends DerivedType implements ICDIFunctionType { String params = ""; //$NON-NLS-1$ - public FunctionType(ICDITarget target, String typename) { + public FunctionType(Target target, String typename) { super(target, typename); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IncompleteType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IncompleteType.java index 8fe73584a30..db68c8e39fb 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IncompleteType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IncompleteType.java @@ -11,7 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; + /** @@ -21,7 +22,7 @@ public class IncompleteType extends Type { /** * @param name */ - public IncompleteType(ICDITarget target, String name) { + public IncompleteType(Target target, String name) { super(target, name); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IntType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IntType.java index 3b359756ba1..0357aff9ef9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IntType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IntType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIIntType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class IntType extends IntegralType implements ICDIIntType { /** * @param typename */ - public IntType(ICDITarget target, String typename) { + public IntType(Target target, String typename) { this(target, typename, false); } - public IntType(ICDITarget target, String typename, boolean isUnsigned) { + public IntType(Target target, String typename, boolean isUnsigned) { super(target, typename, isUnsigned); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IntegralType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IntegralType.java index 79a64991d94..8a68eb009b1 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IntegralType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/IntegralType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIIntegralType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -20,7 +20,7 @@ public abstract class IntegralType extends Type implements ICDIIntegralType { boolean unSigned; - public IntegralType(ICDITarget target, String typename, boolean isUnsigned) { + public IntegralType(Target target, String typename, boolean isUnsigned) { super(target, typename); unSigned = isUnsigned; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/LongLongType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/LongLongType.java index 51395f13676..8abe43b767d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/LongLongType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/LongLongType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDILongLongType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class LongLongType extends IntegralType implements ICDILongLongType { /** * @param typename */ - public LongLongType(ICDITarget target, String typename) { + public LongLongType(Target target, String typename) { this(target, typename, false); } - public LongLongType(ICDITarget target, String typename, boolean usigned) { + public LongLongType(Target target, String typename, boolean usigned) { super(target, typename, usigned); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/LongType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/LongType.java index 72441cb9447..5c015d1ef19 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/LongType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/LongType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDILongType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class LongType extends IntegralType implements ICDILongType { /** * @param typename */ - public LongType(ICDITarget target, String typename) { + public LongType(Target target, String typename) { this(target, typename, false); } - public LongType(ICDITarget target, String typename, boolean usigned) { + public LongType(Target target, String typename, boolean usigned) { super(target, typename, usigned); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/PointerType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/PointerType.java index cadee7b9547..68f1a9b8e1c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/PointerType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/PointerType.java @@ -11,15 +11,15 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ public class PointerType extends DerivedType implements ICDIPointerType { - public PointerType(ICDITarget target, String typename) { + public PointerType(Target target, String typename) { super(target, typename); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ReferenceType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ReferenceType.java index 29c90be2e8a..4d71c6fa02b 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ReferenceType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ReferenceType.java @@ -11,9 +11,9 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceType; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -22,7 +22,7 @@ public class ReferenceType extends DerivedType implements ICDIReferenceType { /** * @param name */ - public ReferenceType(ICDITarget target, String name) { + public ReferenceType(Target target, String name) { super(target, name); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ShortType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ShortType.java index 458f9bab62f..e085f5cfb54 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ShortType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/ShortType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIShortType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,11 +21,11 @@ public class ShortType extends IntegralType implements ICDIShortType { /** * @param typename */ - public ShortType(ICDITarget target, String typename) { + public ShortType(Target target, String typename) { this(target, typename, false); } - public ShortType(ICDITarget target, String typename, boolean usigned) { + public ShortType(Target target, String typename, boolean usigned) { super(target, typename, usigned); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/StructType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/StructType.java index 71b5b0d81f5..4bf4730942a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/StructType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/StructType.java @@ -11,8 +11,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -21,7 +21,7 @@ public class StructType extends AggregateType implements ICDIStructType { /** * @param typename */ - public StructType(ICDITarget target, String typename) { + public StructType(Target target, String typename) { super(target, typename); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/Type.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/Type.java index 5c18c60fb9f..1ee225567d0 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/Type.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/Type.java @@ -11,9 +11,9 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType; import org.eclipse.cdt.debug.mi.core.cdi.model.CObject; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -22,7 +22,7 @@ public abstract class Type extends CObject implements ICDIType { String typename; String detailName; - public Type(ICDITarget target, String name) { + public Type(Target target, String name) { super(target); typename = name; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/VoidType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/VoidType.java index 336e5a566d5..e520cc716d1 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/VoidType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/VoidType.java @@ -11,14 +11,14 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIVoidType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ public class VoidType extends Type implements ICDIVoidType { - public VoidType(ICDITarget target, String typename) { + public VoidType(Target target, String typename) { super(target, typename); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/WCharType.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/WCharType.java index dc419583911..038692fe35a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/WCharType.java +++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/type/WCharType.java @@ -12,8 +12,8 @@ package org.eclipse.cdt.debug.mi.core.cdi.model.type; -import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIWCharType; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; /** */ @@ -22,11 +22,11 @@ public class WCharType extends IntegralType implements ICDIWCharType { /** * @param typename */ - public WCharType(ICDITarget target, String typename) { + public WCharType(Target target, String typename) { this(target, typename, false); } - public WCharType(ICDITarget target, String typename, boolean usigned) { + public WCharType(Target target, String typename, boolean usigned) { super(target, typename, usigned); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java index f438819eecf..0bb60f666ee 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java @@ -36,9 +36,14 @@ public class CommandFactory { return new MIBreakEnable(brknum); } +// public MIBreakInsert createMIBreakInsert(boolean isTemporary, boolean isHardware, +// String condition, int ignoreCount, String line) { +// return new MIBreakInsert(isTemporary, isHardware, condition, ignoreCount, line, 0); +// } + public MIBreakInsert createMIBreakInsert(boolean isTemporary, boolean isHardware, - String condition, int ignoreCount, String line) { - return new MIBreakInsert(isTemporary, isHardware, condition, ignoreCount, line); + String condition, int ignoreCount, String line, int tid) { + return new MIBreakInsert(isTemporary, isHardware, condition, ignoreCount, line, tid); } public MIBreakInsert createMIBreakInsert(String func) { diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIBreakInsert.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIBreakInsert.java index a421eea2d6f..54fa2f09b5c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIBreakInsert.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/command/MIBreakInsert.java @@ -61,11 +61,11 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput; public class MIBreakInsert extends MICommand { public MIBreakInsert(String func) { - this(false, false, null, 0, func); + this(false, false, null, 0, func, 0); } public MIBreakInsert(boolean isTemporary, boolean isHardware, - String condition, int ignoreCount, String line) { + String condition, int ignoreCount, String line, int tid) { super("-break-insert"); //$NON-NLS-1$ int i = 0; @@ -78,7 +78,9 @@ public class MIBreakInsert extends MICommand if (ignoreCount > 0) { i += 2; } - + if (tid > 0) { + i += 2; + } String[] opts = new String[i]; i = 0; @@ -101,6 +103,11 @@ public class MIBreakInsert extends MICommand opts[i] = Integer.toString(ignoreCount); i++; } + if (tid > 0) { + opts[i] = "-p"; //$NON-NLS-1$ + i++; + opts[i] = Integer.toString(tid); + } if (opts.length > 0) { setOptions(opts); diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointChangedEvent.java index 99aebe3e982..c17acd91f52 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointChangedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointChangedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -19,12 +21,12 @@ public class MIBreakpointChangedEvent extends MIChangedEvent { int no; - public MIBreakpointChangedEvent(int number) { - this(0, number); + public MIBreakpointChangedEvent(MISession source, int number) { + this(source, 0, number); } - public MIBreakpointChangedEvent(int id, int number) { - super(id); + public MIBreakpointChangedEvent(MISession source, int id, int number) { + super(source, id); no = number; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointCreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointCreatedEvent.java index 2c059035b85..b31bd60030c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointCreatedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointCreatedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -19,12 +21,12 @@ public class MIBreakpointCreatedEvent extends MICreatedEvent { int no; - public MIBreakpointCreatedEvent(int number) { - this(0, number); + public MIBreakpointCreatedEvent(MISession source, int number) { + this(source, 0, number); } - public MIBreakpointCreatedEvent(int id, int number) { - super(id); + public MIBreakpointCreatedEvent(MISession source, int id, int number) { + super(source, id); no = number; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointDeletedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointDeletedEvent.java index 5d25f3e373a..d9f4c536943 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointDeletedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointDeletedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -19,12 +21,12 @@ public class MIBreakpointDeletedEvent extends MIDestroyedEvent { int no; - public MIBreakpointDeletedEvent(int number) { - this(0, number); + public MIBreakpointDeletedEvent(MISession source, int number) { + this(source, 0, number); } - public MIBreakpointDeletedEvent(int id, int number) { - super(id); + public MIBreakpointDeletedEvent(MISession source, int id, int number) { + super(source, id); no = number; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java index baecefbaf8a..8b2cfc26a71 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIBreakpointHitEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIFrame; @@ -27,13 +28,13 @@ public class MIBreakpointHitEvent extends MIStoppedEvent { int bkptno; MIFrame frame; - public MIBreakpointHitEvent(MIExecAsyncOutput record) { - super(record); + public MIBreakpointHitEvent(MISession source, MIExecAsyncOutput record) { + super(source, record); parse(); } - public MIBreakpointHitEvent(MIResultRecord record) { - super(record); + public MIBreakpointHitEvent(MISession source, MIResultRecord record) { + super(source, record); parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIChangedEvent.java index 6badb71e34a..86c65b1e8c1 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIChangedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIChangedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -17,7 +19,7 @@ package org.eclipse.cdt.debug.mi.core.event; * */ public abstract class MIChangedEvent extends MIEvent { - public MIChangedEvent(int id) { - super(id); + public MIChangedEvent(MISession source, int id) { + super(source, id); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MICreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MICreatedEvent.java index 1de5eb75e84..f5f01b04ef5 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MICreatedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MICreatedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -17,7 +19,7 @@ package org.eclipse.cdt.debug.mi.core.event; * */ public abstract class MICreatedEvent extends MIEvent { - public MICreatedEvent(int id) { - super(id); + public MICreatedEvent(MISession source, int id) { + super(source, id); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIDestroyedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIDestroyedEvent.java index 3ab68051952..895ee6ec536 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIDestroyedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIDestroyedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -17,7 +19,7 @@ package org.eclipse.cdt.debug.mi.core.event; * */ public abstract class MIDestroyedEvent extends MIEvent { - public MIDestroyedEvent(int id) { - super(id); + public MIDestroyedEvent(MISession source, int id) { + super(source, id); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIDetachedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIDetachedEvent.java index 397b4d39ef5..d71fe52f3ee 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIDetachedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIDetachedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -18,8 +20,8 @@ package org.eclipse.cdt.debug.mi.core.event; */ public class MIDetachedEvent extends MIDestroyedEvent { - public MIDetachedEvent(int token) { - super(token); + public MIDetachedEvent(MISession source, int token) { + super(source, token); } public String toString() { diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIErrorEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIErrorEvent.java index 9e5983637f4..24ac1687606 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIErrorEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIErrorEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MILogStreamOutput; import org.eclipse.cdt.debug.mi.core.output.MIOOBRecord; @@ -32,8 +33,8 @@ public class MIErrorEvent extends MIStoppedEvent { String log = ""; //$NON-NLS-1$ MIOOBRecord[] oobs; - public MIErrorEvent(MIResultRecord rr, MIOOBRecord[] o) { - super(rr); + public MIErrorEvent(MISession source, MIResultRecord rr, MIOOBRecord[] o) { + super(source, rr); oobs = o; parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIEvent.java index b297141ad94..a0680f07040 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIEvent.java @@ -10,17 +10,26 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import java.util.EventObject; + +import org.eclipse.cdt.debug.mi.core.MISession; + /** */ -public abstract class MIEvent { +public abstract class MIEvent extends EventObject { int token; - public MIEvent(int token) { + public MIEvent(MISession session, int token) { + super(session); this.token = token; } public int getToken() { return token; } + + public MISession getMISession() { + return (MISession)getSource(); + } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIFunctionFinishedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIFunctionFinishedEvent.java index cd1321bcd78..0f8d7ed6c16 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIFunctionFinishedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIFunctionFinishedEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIFrame; @@ -26,13 +27,13 @@ public class MIFunctionFinishedEvent extends MIStoppedEvent { String gdbResult = ""; //$NON-NLS-1$ String returnValue = ""; //$NON-NLS-1$ - public MIFunctionFinishedEvent(MIExecAsyncOutput async) { - super(async); + public MIFunctionFinishedEvent(MISession source, MIExecAsyncOutput async) { + super(source, async); parse(); } - public MIFunctionFinishedEvent(MIResultRecord record) { - super(record); + public MIFunctionFinishedEvent(MISession source, MIResultRecord record) { + super(source, record); parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIGDBExitEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIGDBExitEvent.java index fb12fb8a5a7..1d1eccc796b 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIGDBExitEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIGDBExitEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -17,7 +19,7 @@ package org.eclipse.cdt.debug.mi.core.event; */ public class MIGDBExitEvent extends MIDestroyedEvent { - public MIGDBExitEvent(int token) { - super(token); + public MIGDBExitEvent(MISession source, int token) { + super(source, token); } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorExitEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorExitEvent.java index b605e59aed2..633581ce9f9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorExitEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorExitEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIResult; @@ -31,18 +32,18 @@ public class MIInferiorExitEvent extends MIDestroyedEvent { MIExecAsyncOutput exec = null; MIResultRecord rr = null; - public MIInferiorExitEvent(int token) { - super(token); + public MIInferiorExitEvent(MISession source, int token) { + super(source, token); } - public MIInferiorExitEvent(MIExecAsyncOutput async) { - super(async.getToken()); + public MIInferiorExitEvent(MISession source, MIExecAsyncOutput async) { + super(source, async.getToken()); exec = async; parse(); } - public MIInferiorExitEvent(MIResultRecord record) { - super(record.getToken()); + public MIInferiorExitEvent(MISession source, MIResultRecord record) { + super(source, record.getToken()); rr = record; parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorSignalExitEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorSignalExitEvent.java index 8652cb80363..01a5fb0bca6 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorSignalExitEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIInferiorSignalExitEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIResult; @@ -30,14 +31,14 @@ public class MIInferiorSignalExitEvent extends MIDestroyedEvent { MIExecAsyncOutput exec = null; MIResultRecord rr = null; - public MIInferiorSignalExitEvent(MIExecAsyncOutput async) { - super(async.getToken()); + public MIInferiorSignalExitEvent(MISession source, MIExecAsyncOutput async) { + super(source, async.getToken()); exec = async; parse(); } - public MIInferiorSignalExitEvent(MIResultRecord record) { - super(record.getToken()); + public MIInferiorSignalExitEvent(MISession source, MIResultRecord record) { + super(source, record.getToken()); rr = record; parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MILocationReachedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MILocationReachedEvent.java index e13090840ab..7bd4f0e313b 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MILocationReachedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MILocationReachedEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIFrame; @@ -23,13 +24,13 @@ import org.eclipse.cdt.debug.mi.core.output.MIValue; */ public class MILocationReachedEvent extends MIStoppedEvent { - public MILocationReachedEvent(MIExecAsyncOutput async) { - super(async); + public MILocationReachedEvent(MISession source, MIExecAsyncOutput async) { + super(source, async); parse(); } - public MILocationReachedEvent(MIResultRecord record) { - super(record); + public MILocationReachedEvent(MISession source, MIResultRecord record) { + super(source, record); parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIMemoryChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIMemoryChangedEvent.java index 1b05912a22b..9530e50d5bb 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIMemoryChangedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIMemoryChangedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -20,12 +22,12 @@ public class MIMemoryChangedEvent extends MIChangedEvent { Long[] addresses; - public MIMemoryChangedEvent(Long[] addrs) { - this(0, addrs); + public MIMemoryChangedEvent(MISession source, Long[] addrs) { + this(source, 0, addrs); } - public MIMemoryChangedEvent(int token, Long[] addrs) { - super(token); + public MIMemoryChangedEvent(MISession source, int token, Long[] addrs) { + super(source, token); addresses = addrs; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIMemoryCreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIMemoryCreatedEvent.java index 15792e2932a..4132d86b185 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIMemoryCreatedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIMemoryCreatedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -21,12 +23,12 @@ public class MIMemoryCreatedEvent extends MICreatedEvent { long address; long totalBytes; - public MIMemoryCreatedEvent(long addr, long total) { - this(0, addr, total); + public MIMemoryCreatedEvent(MISession source, long addr, long total) { + this(source, 0, addr, total); } - public MIMemoryCreatedEvent(int token, long addr, long total) { - super(token); + public MIMemoryCreatedEvent(MISession source, int token, long addr, long total) { + super(source, token); address = addr; totalBytes = total; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRegisterChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRegisterChangedEvent.java index 769880c9ce5..942e2cfd6cc 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRegisterChangedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRegisterChangedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -21,8 +23,8 @@ public class MIRegisterChangedEvent extends MIChangedEvent { String regName; int regno; - public MIRegisterChangedEvent(int token, String name, int no) { - super(token); + public MIRegisterChangedEvent(MISession source, int token, String name, int no) { + super(source, token); regName = name; regno = no; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRegisterCreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRegisterCreatedEvent.java index 654c2649b9f..25411ddbf17 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRegisterCreatedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRegisterCreatedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -21,12 +23,12 @@ public class MIRegisterCreatedEvent extends MICreatedEvent { String regName; int regno; - public MIRegisterCreatedEvent(String name, int number) { - this(0, name, number); + public MIRegisterCreatedEvent(MISession source, String name, int number) { + this(source, 0, name, number); } - public MIRegisterCreatedEvent(int token, String name, int number) { - super(token); + public MIRegisterCreatedEvent(MISession source, int token, String name, int number) { + super(source, token); regName = name; regno = number; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java index 6427c3536f8..f1a19ceeba8 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIRunningEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -29,8 +31,8 @@ public class MIRunningEvent extends MIEvent { int type; - public MIRunningEvent(int token, int t) { - super(token); + public MIRunningEvent(MISession source, int token, int t) { + super(source, token); type = t; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibChangedEvent.java index 4608907648a..8c3cac02819 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibChangedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibChangedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -19,12 +21,12 @@ public class MISharedLibChangedEvent extends MIChangedEvent { String filename; - public MISharedLibChangedEvent(String name) { - this(0, name); + public MISharedLibChangedEvent(MISession source, String name) { + this(source, 0, name); } - public MISharedLibChangedEvent(int id, String name) { - super(id); + public MISharedLibChangedEvent(MISession source, int id, String name) { + super(source, id); filename = name; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibCreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibCreatedEvent.java index d78fce6d325..5455f3f43ac 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibCreatedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibCreatedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -19,12 +21,12 @@ public class MISharedLibCreatedEvent extends MICreatedEvent { String filename; - public MISharedLibCreatedEvent(String name) { - this(0, name); + public MISharedLibCreatedEvent(MISession source, String name) { + this(source, 0, name); } - public MISharedLibCreatedEvent(int id, String name) { - super(id); + public MISharedLibCreatedEvent(MISession source, int id, String name) { + super(source, id); filename = name; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibEvent.java index 78874262bc2..6125c522a76 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIResultRecord; @@ -20,13 +21,13 @@ import org.eclipse.cdt.debug.mi.core.output.MIResultRecord; */ public class MISharedLibEvent extends MIStoppedEvent { - public MISharedLibEvent(MIExecAsyncOutput async) { - super(async); + public MISharedLibEvent(MISession source, MIExecAsyncOutput async) { + super(source, async); parse(); } - public MISharedLibEvent(MIResultRecord record) { - super(record); + public MISharedLibEvent(MISession source, MIResultRecord record) { + super(source, record); parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibUnloadedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibUnloadedEvent.java index 2dcf59dbca2..dea9764c8a1 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibUnloadedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISharedLibUnloadedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** * */ @@ -17,12 +19,12 @@ public class MISharedLibUnloadedEvent extends MIDestroyedEvent { String filename; - public MISharedLibUnloadedEvent(String name) { - this(0, name); + public MISharedLibUnloadedEvent(MISession source, String name) { + this(source, 0, name); } - public MISharedLibUnloadedEvent(int id, String name) { - super(id); + public MISharedLibUnloadedEvent(MISession source, int id, String name) { + super(source, id); filename = name; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISignalChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISignalChangedEvent.java index 71038942638..40b6bb6b2a6 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISignalChangedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISignalChangedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -19,12 +21,12 @@ public class MISignalChangedEvent extends MIChangedEvent { String name; - public MISignalChangedEvent(String n) { - this(0, n); + public MISignalChangedEvent(MISession source, String n) { + this(source, 0, n); } - public MISignalChangedEvent(int id, String n) { - super(id); + public MISignalChangedEvent(MISession source, int id, String n) { + super(source, id); name = n; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISignalEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISignalEvent.java index 3ff0372a2c6..8e5f71c0714 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISignalEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISignalEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIFrame; @@ -27,13 +28,13 @@ public class MISignalEvent extends MIStoppedEvent { String sigName = ""; //$NON-NLS-1$ String sigMeaning = ""; //$NON-NLS-1$ - public MISignalEvent(MIExecAsyncOutput async) { - super(async); + public MISignalEvent(MISession source, MIExecAsyncOutput async) { + super(source, async); parse(); } - public MISignalEvent(MIResultRecord record) { - super(record); + public MISignalEvent(MISession source, MIResultRecord record) { + super(source, record); parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISteppingRangeEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISteppingRangeEvent.java index 5c8f9e626e2..d23fc87d5bd 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISteppingRangeEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MISteppingRangeEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIFrame; @@ -24,13 +25,13 @@ import org.eclipse.cdt.debug.mi.core.output.MIValue; */ public class MISteppingRangeEvent extends MIStoppedEvent { - public MISteppingRangeEvent(MIExecAsyncOutput async) { - super(async); + public MISteppingRangeEvent(MISession source, MIExecAsyncOutput async) { + super(source, async); parse(); } - public MISteppingRangeEvent(MIResultRecord record) { - super(record); + public MISteppingRangeEvent(MISession source, MIResultRecord record) { + super(source, record); parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIStoppedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIStoppedEvent.java index 97fadc7891a..347722a622f 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIStoppedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIStoppedEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIFrame; @@ -31,14 +32,14 @@ public class MIStoppedEvent extends MIEvent { private MIExecAsyncOutput exec; private MIResultRecord rr; - public MIStoppedEvent(MIExecAsyncOutput record) { - super(record.getToken()); + public MIStoppedEvent(MISession source, MIExecAsyncOutput record) { + super(source, record.getToken()); exec = record; parse(); } - public MIStoppedEvent(MIResultRecord record) { - super(record.getToken()); + public MIStoppedEvent(MISession source, MIResultRecord record) { + super(source, record.getToken()); rr = record; parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIThreadCreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIThreadCreatedEvent.java index 64068bc2c2e..8c8804807c0 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIThreadCreatedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIThreadCreatedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** * This can not be detected yet by gdb/mi. @@ -19,12 +21,12 @@ public class MIThreadCreatedEvent extends MICreatedEvent { int tid; - public MIThreadCreatedEvent(int id) { - this(0, id); + public MIThreadCreatedEvent(MISession source, int id) { + this(source, 0, id); } - public MIThreadCreatedEvent(int token, int id) { - super(token); + public MIThreadCreatedEvent(MISession source, int token, int id) { + super(source, token); tid = id; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIThreadExitEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIThreadExitEvent.java index 2ab1d40bb16..5bd0bd1ed1d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIThreadExitEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIThreadExitEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** * This can not be detected yet by gdb/mi. @@ -19,12 +21,12 @@ public class MIThreadExitEvent extends MIDestroyedEvent { int tid; - public MIThreadExitEvent(int id) { - this(0, id); + public MIThreadExitEvent(MISession source, int id) { + this(source, 0, id); } - public MIThreadExitEvent(int token, int id) { - super(token); + public MIThreadExitEvent(MISession source, int token, int id) { + super(source, token); tid = id; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarChangedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarChangedEvent.java index 869490be077..b58c0cf8fad 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarChangedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarChangedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -20,12 +22,12 @@ public class MIVarChangedEvent extends MIChangedEvent { String varName; - public MIVarChangedEvent(String var) { - this(0, var); + public MIVarChangedEvent(MISession source, String var) { + this(source, 0, var); } - public MIVarChangedEvent(int token, String var) { - super(token); + public MIVarChangedEvent(MISession source, int token, String var) { + super(source, token); varName = var; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarCreatedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarCreatedEvent.java index 26e0af061a5..9de879be407 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarCreatedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarCreatedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -20,13 +22,13 @@ public class MIVarCreatedEvent extends MICreatedEvent { String varName; - public MIVarCreatedEvent(String var) { - super(0); + public MIVarCreatedEvent(MISession source, String var) { + super(source, 0); varName = var; } - public MIVarCreatedEvent(int token, String var) { - super(token); + public MIVarCreatedEvent(MISession source, int token, String var) { + super(source, token); varName = var; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarDeletedEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarDeletedEvent.java index c0c7665effa..5fb93bce51d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarDeletedEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIVarDeletedEvent.java @@ -10,6 +10,8 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; + /** @@ -20,12 +22,12 @@ public class MIVarDeletedEvent extends MIDestroyedEvent { String varName; - public MIVarDeletedEvent(String var) { - this(0, var); + public MIVarDeletedEvent(MISession source, String var) { + this(source, 0, var); } - public MIVarDeletedEvent(int token, String var) { - super(token); + public MIVarDeletedEvent(MISession source, int token, String var) { + super(source, token); varName = var; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIWatchpointScopeEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIWatchpointScopeEvent.java index 4fedb76b90f..d04b4778a23 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIWatchpointScopeEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIWatchpointScopeEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIFrame; @@ -26,13 +27,13 @@ public class MIWatchpointScopeEvent extends MIStoppedEvent { int number; - public MIWatchpointScopeEvent(MIExecAsyncOutput async) { - super(async); + public MIWatchpointScopeEvent(MISession source, MIExecAsyncOutput async) { + super(source, async); parse(); } - public MIWatchpointScopeEvent(MIResultRecord record) { - super(record); + public MIWatchpointScopeEvent(MISession source, MIResultRecord record) { + super(source, record); parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIWatchpointTriggerEvent.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIWatchpointTriggerEvent.java index f4cb51741bb..b8b78eaae5e 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIWatchpointTriggerEvent.java +++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/event/MIWatchpointTriggerEvent.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.mi.core.event; +import org.eclipse.cdt.debug.mi.core.MISession; import org.eclipse.cdt.debug.mi.core.output.MIConst; import org.eclipse.cdt.debug.mi.core.output.MIExecAsyncOutput; import org.eclipse.cdt.debug.mi.core.output.MIFrame; @@ -29,13 +30,13 @@ public class MIWatchpointTriggerEvent extends MIStoppedEvent { String oldValue = ""; //$NON-NLS-1$ String newValue = ""; //$NON-NLS-1$ - public MIWatchpointTriggerEvent(MIExecAsyncOutput async) { - super(async); + public MIWatchpointTriggerEvent(MISession source, MIExecAsyncOutput async) { + super(source, async); parse(); } - public MIWatchpointTriggerEvent(MIResultRecord record) { - super(record); + public MIWatchpointTriggerEvent(MISession source, MIResultRecord record) { + super(source, record); parse(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java index 5be57f1270f..38d42b74fe3 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/CLIProcessor.java @@ -50,7 +50,7 @@ public class CLIProcessor { if (type != -1) { // if it was a step instruction set state running session.getMIInferior().setRunning(); - MIEvent event = new MIRunningEvent(cmd.getToken(), type); + MIEvent event = new MIRunningEvent(session, cmd.getToken(), type); session.fireEvent(event); } else if (isSettingBreakpoint(operation) || isSettingWatchpoint(operation) || @@ -58,14 +58,14 @@ public class CLIProcessor { isDeletingBreakpoint(operation)) { // We know something change, we just do not know what. // So the easiest way is to let the top layer handle it. - session.fireEvent(new MIBreakpointChangedEvent(0)); + session.fireEvent(new MIBreakpointChangedEvent(session, 0)); } else if (isSettingSignal(operation)) { // We do no know which signal let the upper layer find it. - session.fireEvent(new MISignalChangedEvent("")); //$NON-NLS-1$ + session.fireEvent(new MISignalChangedEvent(session, "")); //$NON-NLS-1$ } else if (isDetach(operation)) { // if it was a "detach" command change the state. session.getMIInferior().setDisconnected(); - MIEvent event = new MIDetachedEvent(cmd.getToken()); + MIEvent event = new MIDetachedEvent(session, cmd.getToken()); session.fireEvent(event); } } 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 0d0ea8b34fb..d9d6bc2f35c 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 @@ -8,6 +8,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.mi.core.cdi.Session; +import org.eclipse.cdt.debug.mi.core.cdi.model.Target; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.CygwinCommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIGDBSet; @@ -33,14 +34,15 @@ public class CygwinGDBDebugger extends GDBDebugger { boolean failed = false; try { session = (Session) super.createLaunchSession(config, exe); - session.getMISession().setCommandFactory(commandFactory); + 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} - MISession mi = session.getMISession(); try { - CommandFactory factory = mi.getCommandFactory(); + CommandFactory factory = miSession.getCommandFactory(); MIGDBSet set = factory.createMIGDBSet(new String[] { "new-console" }); //$NON-NLS-1$ - mi.postCommand(set); + miSession.postCommand(set); MIInfo info = set.getMIInfo(); if (info == null) { throw new MIException(MIPlugin.getResourceString("src.common.No_answer")); //$NON-NLS-1$ @@ -71,7 +73,8 @@ public class CygwinGDBDebugger extends GDBDebugger { boolean failed = false; try { session = (Session) super.createAttachSession(config, exe, pid); - session.getMISession().setCommandFactory(commandFactory); + Target target = (Target)session.getCurrentTarget(); + target.getMISession().setCommandFactory(commandFactory); initializeLibraries(config, session); return session; } catch (CDIException e) { @@ -95,7 +98,8 @@ public class CygwinGDBDebugger extends GDBDebugger { boolean failed = false; try { session = (Session) super.createCoreSession(config, exe, corefile); - session.getMISession().setCommandFactory(commandFactory); + Target target = (Target)session.getCurrentTarget(); + 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/GDBServerDebugger.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBServerDebugger.java index 75f04ac56c8..b2298750133 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 @@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.ICDISession; import org.eclipse.cdt.debug.core.cdi.ICDISharedLibraryManager; 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; import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.MIGDBSet; import org.eclipse.cdt.debug.mi.core.command.MITargetSelect; @@ -76,7 +77,8 @@ 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); - MISession miSession = session.getMISession(); + 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 diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java index 47862035da2..3d103058c1c 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java @@ -307,7 +307,7 @@ public class MIInferior extends Process { } } if (fireEvent) { - session.fireEvent(new MIInferiorExitEvent(token)); + session.fireEvent(new MIInferiorExitEvent(session, token)); } notifyAll(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java index bbe09d3f1e5..903460bafd0 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MISession.java @@ -481,7 +481,7 @@ public class MISession extends Observable { } // Tell the observers that the session is terminated - notifyObservers(new MIGDBExitEvent(0)); + notifyObservers(new MIGDBExitEvent(this, 0)); } /** diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java index f42f3ce5675..79f56417a1a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/RxThread.java @@ -161,7 +161,7 @@ public class RxThread extends Thread { type = MIRunningEvent.CONTINUE; } session.getMIInferior().setRunning(); - MIEvent event = new MIRunningEvent(id, type); + MIEvent event = new MIRunningEvent(session, id, type); list.add(event); } else if ("exit".equals(state)) { //$NON-NLS-1$ // No need to do anything, terminate() will. @@ -171,7 +171,7 @@ public class RxThread extends Thread { } else if ("error".equals(state)) { //$NON-NLS-1$ if (session.getMIInferior().isRunning()) { session.getMIInferior().setSuspended(); - MIEvent event = new MIErrorEvent(rr, oobRecords); + MIEvent event = new MIErrorEvent(session, rr, oobRecords); list.add(event); } } else if ("done".equals(state)) { //$NON-NLS-1$ @@ -255,7 +255,7 @@ public class RxThread extends Thread { for (int i = 0; i < logs.length; i++) { if (logs[i].equalsIgnoreCase("Stopped due to shared library event")) { //$NON-NLS-1$ session.getMIInferior().setSuspended(); - MIEvent e = new MISharedLibEvent(exec); + MIEvent e = new MISharedLibEvent(session, exec); list.add(e); } } @@ -266,7 +266,7 @@ public class RxThread extends Thread { // "reason" ??? still fire a stopped event. if (list.isEmpty()) { session.getMIInferior().setSuspended(); - MIEvent e = new MIStoppedEvent(exec); + MIEvent e = new MIStoppedEvent(session, exec); list.add(e); } } @@ -358,7 +358,7 @@ public class RxThread extends Thread { for (int i = 0; i < logs.length; i++) { if (logs[i].equalsIgnoreCase("Stopped due to shared library event")) { //$NON-NLS-1$ session.getMIInferior().setSuspended(); - MIEvent e = new MISharedLibEvent(rr); + MIEvent e = new MISharedLibEvent(session, rr); list.add(e); } } @@ -369,7 +369,7 @@ public class RxThread extends Thread { if (list.isEmpty()) { if (session.getMIInferior().isRunning()) { session.getMIInferior().setSuspended(); - MIEvent event = new MIStoppedEvent(rr); + MIEvent event = new MIStoppedEvent(session, rr); session.fireEvent(event); } } @@ -387,9 +387,9 @@ public class RxThread extends Thread { MIEvent event = null; if ("breakpoint-hit".equals(reason)) { //$NON-NLS-1$ if (exec != null) { - event = new MIBreakpointHitEvent(exec); + event = new MIBreakpointHitEvent(session, exec); } else if (rr != null) { - event = new MIBreakpointHitEvent(rr); + event = new MIBreakpointHitEvent(session, rr); } session.getMIInferior().setSuspended(); } else if ( @@ -397,58 +397,58 @@ public class RxThread extends Thread { || "read-watchpoint-trigger".equals(reason) //$NON-NLS-1$ || "access-watchpoint-trigger".equals(reason)) { //$NON-NLS-1$ if (exec != null) { - event = new MIWatchpointTriggerEvent(exec); + event = new MIWatchpointTriggerEvent(session, exec); } else if (rr != null) { - event = new MIWatchpointTriggerEvent(rr); + event = new MIWatchpointTriggerEvent(session, rr); } session.getMIInferior().setSuspended(); } else if ("watchpoint-scope".equals(reason)) { //$NON-NLS-1$ if (exec != null) { - event = new MIWatchpointScopeEvent(exec); + event = new MIWatchpointScopeEvent(session, exec); } else if (rr != null) { - event = new MIWatchpointScopeEvent(rr); + event = new MIWatchpointScopeEvent(session, rr); } session.getMIInferior().setSuspended(); } else if ("end-stepping-range".equals(reason)) { //$NON-NLS-1$ if (exec != null) { - event = new MISteppingRangeEvent(exec); + event = new MISteppingRangeEvent(session, exec); } else if (rr != null) { - event = new MISteppingRangeEvent(rr); + event = new MISteppingRangeEvent(session, rr); } session.getMIInferior().setSuspended(); } else if ("signal-received".equals(reason)) { //$NON-NLS-1$ if (exec != null) { - event = new MISignalEvent(exec); + event = new MISignalEvent(session, exec); } else if (rr != null) { - event = new MISignalEvent(rr); + event = new MISignalEvent(session, rr); } session.getMIInferior().setSuspended(); } else if ("location-reached".equals(reason)) { //$NON-NLS-1$ if (exec != null) { - event = new MILocationReachedEvent(exec); + event = new MILocationReachedEvent(session, exec); } else if (rr != null) { - event = new MILocationReachedEvent(rr); + event = new MILocationReachedEvent(session, rr); } session.getMIInferior().setSuspended(); } else if ("function-finished".equals(reason)) { //$NON-NLS-1$ if (exec != null) { - event = new MIFunctionFinishedEvent(exec); + event = new MIFunctionFinishedEvent(session, exec); } else if (rr != null) { - event = new MIFunctionFinishedEvent(rr); + event = new MIFunctionFinishedEvent(session, rr); } session.getMIInferior().setSuspended(); } else if ("exited-normally".equals(reason) || "exited".equals(reason)) { //$NON-NLS-1$ //$NON-NLS-2$ if (exec != null) { - event = new MIInferiorExitEvent(exec); + event = new MIInferiorExitEvent(session, exec); } else if (rr != null) { - event = new MIInferiorExitEvent(rr); + event = new MIInferiorExitEvent(session, rr); } session.getMIInferior().setTerminated(); } else if ("exited-signalled".equals(reason)) { //$NON-NLS-1$ if (exec != null) { - event = new MIInferiorSignalExitEvent(exec); + event = new MIInferiorSignalExitEvent(session, exec); } else if (rr != null) { - event = new MIInferiorSignalExitEvent(rr); + event = new MIInferiorSignalExitEvent(session, rr); } session.getMIInferior().setTerminated(); }