1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

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.
This commit is contained in:
Alain Magloire 2004-09-07 03:48:33 +00:00
parent 73e222cdd8
commit bfe004fad5
105 changed files with 1551 additions and 959 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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];

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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$
// }
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

Some files were not shown because too many files have changed in this diff Show more