mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
rename Session CSession to not confuse with the
CDI getSession() method.
This commit is contained in:
parent
369b1b1f4f
commit
3bfd79a7d0
12 changed files with 170 additions and 69 deletions
|
@ -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.ICLocation;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -16,22 +17,42 @@ import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
|
|||
*/
|
||||
public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
|
||||
|
||||
int type;
|
||||
ICLocation location;
|
||||
ICCondition condition;
|
||||
String threadId = "";
|
||||
boolean enabled = false;
|
||||
MIBreakPoint miBreakPoint;
|
||||
BreakpointManager mgr;
|
||||
|
||||
public Breakpoint(BreakpointManager mgr, MIBreakPoint miBreak) {
|
||||
super((Session)mgr.getSession());
|
||||
public Breakpoint(BreakpointManager m, MIBreakPoint miBreak) {
|
||||
super(m.getCSession());
|
||||
miBreakPoint = miBreak;
|
||||
mgr = m;
|
||||
}
|
||||
|
||||
MIBreakPoint getMIBreakPoint() {
|
||||
return miBreakPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#getCondition()
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -46,21 +67,21 @@ public class Breakpoint extends SessionObject implements ICLocationBreakpoint {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isEnabled()
|
||||
*/
|
||||
public boolean isEnabled() throws CDIException {
|
||||
return enabled;
|
||||
return miBreakPoint.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#isHardware()
|
||||
*/
|
||||
public boolean isHardware() {
|
||||
return false;
|
||||
return miBreakPoint.getType().startsWith("hw");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpoint#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)
|
||||
*/
|
||||
public void setEnabled(boolean enable) throws CDIException {
|
||||
/*
|
||||
if (enable == false && enabled == true) {
|
||||
if (miBreak != null) {
|
||||
MICommand cmd = new MIBreakDisable(miBreak.getNumber());
|
||||
}
|
||||
} 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();
|
||||
}
|
||||
if (enable == false && isEnabled() == true) {
|
||||
mgr.disableBreakpoint(this);
|
||||
} else if (enable == true && isEnabled() == false) {
|
||||
mgr.enableBreakpoint(this);
|
||||
}
|
||||
enabled = enable;
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICLocationBreakpoint#getLocation()
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.mi.core.MIException;
|
||||
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.output.MIBreakInsertInfo;
|
||||
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;
|
||||
|
||||
public BreakpointManager(Session session) {
|
||||
public BreakpointManager(CSession session) {
|
||||
super(session);
|
||||
breakList = new ArrayList(1);
|
||||
}
|
||||
|
@ -55,6 +58,50 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
|
|||
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()
|
||||
*/
|
||||
|
@ -65,50 +112,48 @@ public class BreakpointManager extends SessionObject implements ICBreakpointMana
|
|||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#setCatchpoint(int, ICCatchEvent, String, ICCondition, boolean)
|
||||
*/
|
||||
public ICCatchpoint setCatchpoint(
|
||||
int type,
|
||||
ICCatchEvent event,
|
||||
String expression,
|
||||
ICCondition condition,
|
||||
boolean enabled)
|
||||
throws CDIException {
|
||||
public ICCatchpoint setCatchpoint(int type, ICCatchEvent event, String expression,
|
||||
ICCondition condition) throws CDIException {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICBreakpointManager#setLocationBreakpoint(int, ICLocation, ICCondition, boolean, String)
|
||||
*/
|
||||
public ICLocationBreakpoint setLocationBreakpoint(
|
||||
int type,
|
||||
ICLocation location,
|
||||
ICCondition condition,
|
||||
boolean enabled,
|
||||
String threadId)
|
||||
throws CDIException {
|
||||
public ICLocationBreakpoint setLocationBreakpoint(int type, ICLocation location,
|
||||
ICCondition condition, String threadId) throws CDIException {
|
||||
|
||||
boolean hardware = type == ICBreakpoint.HARDWARE;
|
||||
boolean temporary = type == ICBreakpoint.TEMPORARY;
|
||||
String exprCond = condition.getExpression();
|
||||
int ignoreCount = condition.getIgnoreCount();
|
||||
boolean hardware = (type == ICBreakpoint.HARDWARE);
|
||||
boolean temporary = (type == ICBreakpoint.TEMPORARY);
|
||||
String exprCond = null;
|
||||
int ignoreCount = 0;
|
||||
String line = "";
|
||||
|
||||
if (location.getFile() != null) {
|
||||
line = location.getFile().getPath() + ":";
|
||||
if (location.getFunction() != null) {
|
||||
line += location.getFunction();
|
||||
} else {
|
||||
line += Integer.toString(location.getLineNumber());
|
||||
}
|
||||
} else {
|
||||
line = "*" + Long.toString(location.getAddress());
|
||||
if (condition != null) {
|
||||
exprCond = condition.getExpression();
|
||||
ignoreCount = condition.getIgnoreCount();
|
||||
}
|
||||
|
||||
Session s = (Session)getSession();
|
||||
if (location != null) {
|
||||
if (location.getFile() != null) {
|
||||
line = location.getFile() + ":";
|
||||
if (location.getFunction() != null) {
|
||||
line += location.getFunction();
|
||||
} else {
|
||||
line += Integer.toString(location.getLineNumber());
|
||||
}
|
||||
} else {
|
||||
line = "*" + Long.toString(location.getAddress());
|
||||
}
|
||||
}
|
||||
|
||||
CSession s = getCSession();
|
||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||
MIBreakInsert breakInsert = factory.createMIBreakInsert(temporary, hardware,
|
||||
exprCond, ignoreCount, line);
|
||||
MIBreakPoint[] points = null;
|
||||
try {
|
||||
s.getMISession().postCommand(breakInsert);
|
||||
MIBreakInsertInfo info = breakInsert.getMIBreakInsertInfo();
|
||||
if (info == null) {
|
||||
//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)
|
||||
*/
|
||||
public ICWatchpoint setWatchpoint(
|
||||
int type,
|
||||
int watchType,
|
||||
String expression,
|
||||
ICCondition condition,
|
||||
boolean enabled)
|
||||
throws CDIException {
|
||||
public ICWatchpoint setWatchpoint(int type, int watchType, String expression,
|
||||
ICCondition condition) throws CDIException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.cdt.debug.mi.core.MISession;
|
|||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICSession
|
||||
*/
|
||||
public class Session implements ICSession {
|
||||
public class CSession implements ICSession {
|
||||
|
||||
Properties props;
|
||||
MISession session;
|
||||
|
@ -36,7 +36,7 @@ public class Session implements ICSession {
|
|||
SourceManager sourceManager;
|
||||
CTarget ctarget;
|
||||
|
||||
public Session(MISession s) {
|
||||
public CSession(MISession s) {
|
||||
session = s;
|
||||
props = new Properties();
|
||||
breakpointManager = new BreakpointManager(this);
|
|
@ -29,7 +29,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICThread;
|
|||
*/
|
||||
public class CTarget extends SessionObject implements ICTarget {
|
||||
|
||||
public CTarget(Session session) {
|
||||
public CTarget(CSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICEventListener;
|
|||
*/
|
||||
public class EventManager extends SessionObject implements ICEventManager {
|
||||
|
||||
public EventManager(Session session) {
|
||||
public EventManager(CSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICExpression;
|
|||
*/
|
||||
public class ExpressionManager extends SessionObject implements ICExpressionManager {
|
||||
|
||||
public ExpressionManager(Session session) {
|
||||
public ExpressionManager(CSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICMemoryBlock;
|
|||
*/
|
||||
public class MemoryManager extends SessionObject implements ICMemoryManager {
|
||||
|
||||
public MemoryManager(Session session) {
|
||||
public MemoryManager(CSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ import org.eclipse.cdt.debug.core.cdi.ICSessionObject;
|
|||
*/
|
||||
public class SessionObject implements ICSessionObject {
|
||||
|
||||
Session session;
|
||||
private CSession session;
|
||||
|
||||
public SessionObject (Session session) {
|
||||
public SessionObject (CSession session) {
|
||||
this.session = session;
|
||||
}
|
||||
|
||||
|
@ -25,4 +25,8 @@ public class SessionObject implements ICSessionObject {
|
|||
public ICSession getSession() {
|
||||
return session;
|
||||
}
|
||||
|
||||
public CSession getCSession() {
|
||||
return session;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.eclipse.cdt.debug.core.cdi.ICSignalManager;
|
|||
*/
|
||||
public class SignalManager extends SessionObject implements ICSignalManager {
|
||||
|
||||
public SignalManager(Session session) {
|
||||
public SignalManager(CSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.debug.core.cdi.ICSourceManager;
|
|||
*/
|
||||
public class SourceManager extends SessionObject implements ICSourceManager {
|
||||
|
||||
public SourceManager(Session session) {
|
||||
public SourceManager(CSession session) {
|
||||
super(session);
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ public class MIBreakInsert extends MICommand
|
|||
opts[i] = "-h";
|
||||
i++;
|
||||
}
|
||||
if (condition != null) {
|
||||
if (condition != null && condition.length() > 0) {
|
||||
opts[i] = "-c";
|
||||
i++;
|
||||
opts[i] = condition;
|
||||
|
|
|
@ -49,6 +49,10 @@ public class MIBreakPoint {
|
|||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean e) {
|
||||
enabled = e;
|
||||
}
|
||||
|
||||
public long getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue