diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Breakpoint.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Breakpoint.java index 5dbba038c48..3da6407e3c3 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Breakpoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Breakpoint.java @@ -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; } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java index 5494c4fc1e4..e5ebdf88316 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java @@ -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; } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Session.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java similarity index 97% rename from debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Session.java rename to debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java index dbe26901c53..bb7427c53ab 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/Session.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CSession.java @@ -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); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CTarget.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CTarget.java index 3853f596aa6..f0d3178c9e9 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CTarget.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/CTarget.java @@ -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); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java index 51a37f59fa2..48d1f59f10d 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/EventManager.java @@ -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); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java index 3c6a4db91a6..af17ee52e5a 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/ExpressionManager.java @@ -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); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java index aadb1eb99fc..830cd7676c6 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/MemoryManager.java @@ -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); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SessionObject.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SessionObject.java index 559b6a84e30..b9b3e602104 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SessionObject.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SessionObject.java @@ -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; + } } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java index b84a696d462..8e7572383f0 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SignalManager.java @@ -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); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java index eb91ff0c1b6..ce35f55cb36 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/SourceManager.java @@ -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); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIBreakInsert.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIBreakInsert.java index f3668c805d4..29922af51c4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIBreakInsert.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MIBreakInsert.java @@ -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; diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakPoint.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakPoint.java index 5c5179b6bb5..953debf3dff 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakPoint.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/output/MIBreakPoint.java @@ -49,6 +49,10 @@ public class MIBreakPoint { return enabled; } + public void setEnabled(boolean e) { + enabled = e; + } + public long getAddress() { return address; }