1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-05 23:35:48 +02:00

rename Session CSession to not confuse with the

CDI getSession() method.
This commit is contained in:
Alain Magloire 2002-08-09 18:07:05 +00:00
parent 369b1b1f4f
commit 3bfd79a7d0
12 changed files with 170 additions and 69 deletions

View file

@ -4,6 +4,7 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICCondition; import org.eclipse.cdt.debug.core.cdi.ICCondition;
import org.eclipse.cdt.debug.core.cdi.ICLocation; import org.eclipse.cdt.debug.core.cdi.ICLocation;
import org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint; import org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICInstruction;
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint; import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
/** /**
@ -16,22 +17,42 @@ import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
*/ */
public class Breakpoint extends SessionObject implements ICLocationBreakpoint { public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
int type;
ICLocation location; ICLocation location;
ICCondition condition; ICCondition condition;
String threadId = ""; String threadId = "";
boolean enabled = false;
MIBreakPoint miBreakPoint; MIBreakPoint miBreakPoint;
BreakpointManager mgr;
public Breakpoint(BreakpointManager mgr, MIBreakPoint miBreak) { public Breakpoint(BreakpointManager m, MIBreakPoint miBreak) {
super((Session)mgr.getSession()); super(m.getCSession());
miBreakPoint = miBreak; miBreakPoint = miBreak;
mgr = m;
}
MIBreakPoint getMIBreakPoint() {
return miBreakPoint;
} }
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#getCondition() * @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#getCondition()
*/ */
public ICCondition getCondition() throws CDIException { public ICCondition getCondition() throws CDIException {
if (condition == null) {
condition = new ICCondition () {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICCondition#getIgnoreCount()
*/
public int getIgnoreCount() {
return miBreakPoint.getIgnoreCount();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICCondition#getExpression()
*/
public String getExpression() {
return miBreakPoint.getWhat();
}
};
}
return condition; return condition;
} }
@ -46,21 +67,21 @@ public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isEnabled() * @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isEnabled()
*/ */
public boolean isEnabled() throws CDIException { public boolean isEnabled() throws CDIException {
return enabled; return miBreakPoint.isEnabled();
} }
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isHardware() * @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isHardware()
*/ */
public boolean isHardware() { public boolean isHardware() {
return false; return miBreakPoint.getType().startsWith("hw");
} }
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isTemporary() * @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isTemporary()
*/ */
public boolean isTemporary() { public boolean isTemporary() {
return false; return miBreakPoint.getDisposition().equals("del");
} }
/** /**
@ -74,28 +95,60 @@ public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#setEnabled(boolean) * @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#setEnabled(boolean)
*/ */
public void setEnabled(boolean enable) throws CDIException { public void setEnabled(boolean enable) throws CDIException {
/* if (enable == false && isEnabled() == true) {
if (enable == false && enabled == true) { mgr.disableBreakpoint(this);
if (miBreak != null) { } else if (enable == true && isEnabled() == false) {
MICommand cmd = new MIBreakDisable(miBreak.getNumber()); mgr.enableBreakpoint(this);
} }
} else if (enable == true && enabled == false) {
if (miBreak != null) {
MICommand cmd = new MIBreakEnable(miBreak.getNumber());
} else {
MIBreakInsert cmd = new MIBreakInsert();
miSession.postCommand(cmd);
miBreak = cmd.getBreakInsertInfo();
}
}
enabled = enable;
*/
} }
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint#getLocation() * @see org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint#getLocation()
*/ */
public ICLocation getLocation() throws CDIException { public ICLocation getLocation() throws CDIException {
if (location == null) {
location = new ICLocation () {
/**
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getAddress()
*/
public long getAddress() {
return miBreakPoint.getAddress();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getFile()
*/
public String getFile() {
return miBreakPoint.getFile();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getFunction()
*/
public String getFunction() {
return miBreakPoint.getFunction();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getLineNumber()
*/
public int getLineNumber() {
return miBreakPoint.getLine();
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getInstructions(int)
*/
public ICInstruction[] getInstructions(int maxCount)
throws CDIException {
return new ICInstruction[0];
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICLocation#getInstructions()
*/
public ICInstruction[] getInstructions() throws CDIException {
return new ICInstruction[0];
}
};
}
return location; return location;
} }

View file

@ -19,9 +19,12 @@ import org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint;
import org.eclipse.cdt.debug.core.cdi.ICWatchpoint; import org.eclipse.cdt.debug.core.cdi.ICWatchpoint;
import org.eclipse.cdt.debug.mi.core.MIException; import org.eclipse.cdt.debug.mi.core.MIException;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIBreakDisable;
import org.eclipse.cdt.debug.mi.core.command.MIBreakEnable;
import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert; import org.eclipse.cdt.debug.mi.core.command.MIBreakInsert;
import org.eclipse.cdt.debug.mi.core.output.MIBreakInsertInfo; import org.eclipse.cdt.debug.mi.core.output.MIBreakInsertInfo;
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint; import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
/** /**
* *
@ -30,7 +33,7 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
List breakList; List breakList;
public BreakpointManager(Session session) { public BreakpointManager(CSession session) {
super(session); super(session);
breakList = new ArrayList(1); breakList = new ArrayList(1);
} }
@ -55,6 +58,50 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
public void deleteBreakpoints(ICBreakpoint[] breakpoints) throws CDIException { public void deleteBreakpoints(ICBreakpoint[] breakpoints) throws CDIException {
} }
public void enableBreakpoint(ICBreakpoint breakpoint) throws CDIException {
int number = 0;
if (breakpoint instanceof Breakpoint) {
number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber();
} else {
//throw new CDIException();
}
CSession s = getCSession();
CommandFactory factory = s.getMISession().getCommandFactory();
MIBreakEnable breakEnable = factory.createMIBreakEnable(new int[]{number});
try {
s.getMISession().postCommand(breakEnable);
MIInfo info = breakEnable.getMIInfo();
if (info == null) {
//throw new CDIException();
}
} catch (MIException e) {
// throw new CDIException(e);
}
((Breakpoint)breakpoint).getMIBreakPoint().setEnabled(true);
}
public void disableBreakpoint(ICBreakpoint breakpoint) throws CDIException {
int number = 0;
if (breakpoint instanceof Breakpoint) {
number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber();
} else {
// throw new CDIException();
}
CSession s = getCSession();
CommandFactory factory = s.getMISession().getCommandFactory();
MIBreakDisable breakDisable = factory.createMIBreakDisable(new int[]{number});
try {
s.getMISession().postCommand(breakDisable);
MIInfo info = breakDisable.getMIInfo();
if (info == null) {
//throw new CDIException();
}
} catch (MIException e) {
// throw new CDIException(e);
}
((Breakpoint)breakpoint).getMIBreakPoint().setEnabled(false);
}
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#getBreakpoints() * @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#getBreakpoints()
*/ */
@ -65,35 +112,31 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#setCatchpoint(int, ICCatchEvent, String, ICCondition, boolean) * @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#setCatchpoint(int, ICCatchEvent, String, ICCondition, boolean)
*/ */
public ICCatchpoint setCatchpoint( public ICCatchpoint setCatchpoint(int type, ICCatchEvent event, String expression,
int type, ICCondition condition) throws CDIException {
ICCatchEvent event,
String expression,
ICCondition condition,
boolean enabled)
throws CDIException {
return null; return null;
} }
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#setLocationBreakpoint(int, ICLocation, ICCondition, boolean, String) * @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#setLocationBreakpoint(int, ICLocation, ICCondition, boolean, String)
*/ */
public ICLocationBreakpoint setLocationBreakpoint( public ICLocationBreakpoint setLocationBreakpoint(int type, ICLocation location,
int type, ICCondition condition, String threadId) throws CDIException {
ICLocation location,
ICCondition condition,
boolean enabled,
String threadId)
throws CDIException {
boolean hardware = type == ICBreakpoint.HARDWARE; boolean hardware = (type == ICBreakpoint.HARDWARE);
boolean temporary = type == ICBreakpoint.TEMPORARY; boolean temporary = (type == ICBreakpoint.TEMPORARY);
String exprCond = condition.getExpression(); String exprCond = null;
int ignoreCount = condition.getIgnoreCount(); int ignoreCount = 0;
String line = ""; String line = "";
if (condition != null) {
exprCond = condition.getExpression();
ignoreCount = condition.getIgnoreCount();
}
if (location != null) {
if (location.getFile() != null) { if (location.getFile() != null) {
line = location.getFile().getPath() + ":"; line = location.getFile() + ":";
if (location.getFunction() != null) { if (location.getFunction() != null) {
line += location.getFunction(); line += location.getFunction();
} else { } else {
@ -102,13 +145,15 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
} else { } else {
line = "*" + Long.toString(location.getAddress()); line = "*" + Long.toString(location.getAddress());
} }
}
Session s = (Session)getSession(); CSession s = getCSession();
CommandFactory factory = s.getMISession().getCommandFactory(); CommandFactory factory = s.getMISession().getCommandFactory();
MIBreakInsert breakInsert = factory.createMIBreakInsert(temporary, hardware, MIBreakInsert breakInsert = factory.createMIBreakInsert(temporary, hardware,
exprCond, ignoreCount, line); exprCond, ignoreCount, line);
MIBreakPoint[] points = null; MIBreakPoint[] points = null;
try { try {
s.getMISession().postCommand(breakInsert);
MIBreakInsertInfo info = breakInsert.getMIBreakInsertInfo(); MIBreakInsertInfo info = breakInsert.getMIBreakInsertInfo();
if (info == null) { if (info == null) {
//throw new CDIException(); //throw new CDIException();
@ -129,13 +174,8 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#setWatchpoint(int, int, String, ICCondition, boolean) * @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#setWatchpoint(int, int, String, ICCondition, boolean)
*/ */
public ICWatchpoint setWatchpoint( public ICWatchpoint setWatchpoint(int type, int watchType, String expression,
int type, ICCondition condition) throws CDIException {
int watchType,
String expression,
ICCondition condition,
boolean enabled)
throws CDIException {
return null; return null;
} }
} }

View file

@ -24,7 +24,7 @@ import org.eclipse.cdt.debug.mi.core.MISession;
/** /**
* @see org.eclipse.cdt.debug.core.cdi.ICSession * @see org.eclipse.cdt.debug.core.cdi.ICSession
*/ */
public class Session implements ICSession { public class CSession implements ICSession {
Properties props; Properties props;
MISession session; MISession session;
@ -36,7 +36,7 @@ public class Session implements ICSession {
SourceManager sourceManager; SourceManager sourceManager;
CTarget ctarget; CTarget ctarget;
public Session(MISession s) { public CSession(MISession s) {
session = s; session = s;
props = new Properties(); props = new Properties();
breakpointManager = new BreakpointManager(this); breakpointManager = new BreakpointManager(this);

View file

@ -29,7 +29,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICThread;
*/ */
public class CTarget extends SessionObject implements ICTarget { public class CTarget extends SessionObject implements ICTarget {
public CTarget(Session session) { public CTarget(CSession session) {
super(session); super(session);
} }

View file

@ -19,7 +19,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICEventListener;
*/ */
public class EventManager extends SessionObject implements ICEventManager { public class EventManager extends SessionObject implements ICEventManager {
public EventManager(Session session) { public EventManager(CSession session) {
super(session); super(session);
} }

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICExpression;
*/ */
public class ExpressionManager extends SessionObject implements ICExpressionManager { public class ExpressionManager extends SessionObject implements ICExpressionManager {
public ExpressionManager(Session session) { public ExpressionManager(CSession session) {
super(session); super(session);
} }

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICMemoryBlock;
*/ */
public class MemoryManager extends SessionObject implements ICMemoryManager { public class MemoryManager extends SessionObject implements ICMemoryManager {
public MemoryManager(Session session) { public MemoryManager(CSession session) {
super(session); super(session);
} }

View file

@ -13,9 +13,9 @@ import org.eclipse.cdt.debug.core.cdi.ICSessionObject;
*/ */
public class SessionObject implements ICSessionObject { public class SessionObject implements ICSessionObject {
Session session; private CSession session;
public SessionObject (Session session) { public SessionObject (CSession session) {
this.session = session; this.session = session;
} }
@ -25,4 +25,8 @@ public class SessionObject implements ICSessionObject {
public ICSession getSession() { public ICSession getSession() {
return session; return session;
} }
public CSession getCSession() {
return session;
}
} }

View file

@ -20,7 +20,7 @@ import org.eclipse.cdt.debug.core.cdi.ICSignalManager;
*/ */
public class SignalManager extends SessionObject implements ICSignalManager { public class SignalManager extends SessionObject implements ICSignalManager {
public SignalManager(Session session) { public SignalManager(CSession session) {
super(session); super(session);
} }

View file

@ -21,7 +21,7 @@ import org.eclipse.cdt.debug.core.cdi.ICSourceManager;
*/ */
public class SourceManager extends SessionObject implements ICSourceManager { public class SourceManager extends SessionObject implements ICSourceManager {
public SourceManager(Session session) { public SourceManager(CSession session) {
super(session); super(session);
} }

View file

@ -84,7 +84,7 @@ public class MIBreakInsert extends MICommand
opts[i] = "-h"; opts[i] = "-h";
i++; i++;
} }
if (condition != null) { if (condition != null && condition.length() > 0) {
opts[i] = "-c"; opts[i] = "-c";
i++; i++;
opts[i] = condition; opts[i] = condition;

View file

@ -49,6 +49,10 @@ public class MIBreakPoint {
return enabled; return enabled;
} }
public void setEnabled(boolean e) {
enabled = e;
}
public long getAddress() { public long getAddress() {
return address; return address;
} }