mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-21 21:52:10 +02:00
More implementation.
This commit is contained in:
parent
c1f1744c46
commit
893ef39e38
1 changed files with 85 additions and 34 deletions
|
@ -23,8 +23,10 @@ import org.eclipse.cdt.debug.mi.core.command.MIBreakDelete;
|
|||
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.MIBreakList;
|
||||
import org.eclipse.cdt.debug.mi.core.command.MIBreakWatch;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakInsertInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakListInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakPoint;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIBreakWatchInfo;
|
||||
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
||||
|
@ -35,24 +37,48 @@ import org.eclipse.cdt.debug.mi.core.output.MIInfo;
|
|||
public class BreakpointManager extends SessionObject implements ICDIBreakpointManager {
|
||||
|
||||
List breakList;
|
||||
|
||||
|
||||
public BreakpointManager(CSession session) {
|
||||
super(session);
|
||||
breakList = new ArrayList(1);
|
||||
}
|
||||
|
||||
boolean containsBreakpoint(int number) {
|
||||
return (getBreakpoint(number) != null);
|
||||
}
|
||||
|
||||
Breakpoint getBreakpoint(int number) {
|
||||
ICDIBreakpoint[] bkpts = listBreakpoints();
|
||||
for (int i = 0; i < bkpts.length; i++) {
|
||||
if (bkpts[i] instanceof Breakpoint) {
|
||||
Breakpoint point = (Breakpoint) bkpts[i];
|
||||
MIBreakPoint miBreak = point.getMIBreakPoint();
|
||||
if (miBreak.getNumber() == number) {
|
||||
return point;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Breakpoint[] listBreakpoints() {
|
||||
return (Breakpoint[]) breakList.toArray(
|
||||
new Breakpoint[breakList.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteAllBreakpoints()
|
||||
*/
|
||||
public void deleteAllBreakpoints() throws CDIException {
|
||||
deleteBreakpoints(getBreakpoints());
|
||||
deleteBreakpoints(listBreakpoints());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#deleteBreakpoint(ICDIBreakpoint)
|
||||
*/
|
||||
public void deleteBreakpoint(ICDIBreakpoint breakpoint) throws CDIException {
|
||||
deleteBreakpoints(new ICDIBreakpoint[]{breakpoint});
|
||||
public void deleteBreakpoint(ICDIBreakpoint breakpoint)
|
||||
throws CDIException {
|
||||
deleteBreakpoints(new ICDIBreakpoint[] { breakpoint });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +89,8 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
for (int i = 0; i < numbers.length; i++) {
|
||||
if (breakpoints[i] instanceof Breakpoint
|
||||
&& breakList.contains(breakpoints[i])) {
|
||||
numbers[i] = ((Breakpoint)breakpoints[i]).getMIBreakPoint().getNumber();
|
||||
numbers[i] =
|
||||
((Breakpoint) breakpoints[i]).getMIBreakPoint().getNumber();
|
||||
} else {
|
||||
throw new CDIException("Not a CDT breakpoint");
|
||||
}
|
||||
|
@ -75,7 +102,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
s.getMISession().postCommand(breakDelete);
|
||||
MIInfo info = breakDelete.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException("Timedout");
|
||||
throw new CDIException("No answer");
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.toString());
|
||||
|
@ -87,59 +114,83 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
|
||||
public void enableBreakpoint(ICDIBreakpoint breakpoint) throws CDIException {
|
||||
int number = 0;
|
||||
if (breakpoint instanceof Breakpoint && breakList.contains(breakpoint)) {
|
||||
number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber();
|
||||
if (breakpoint instanceof Breakpoint
|
||||
&& breakList.contains(breakpoint)) {
|
||||
number = ((Breakpoint) breakpoint).getMIBreakPoint().getNumber();
|
||||
} else {
|
||||
throw new CDIException("Not a CDT breakpoint");
|
||||
}
|
||||
CSession s = getCSession();
|
||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||
MIBreakEnable breakEnable = factory.createMIBreakEnable(new int[]{number});
|
||||
MIBreakEnable breakEnable =
|
||||
factory.createMIBreakEnable(new int[] { number });
|
||||
try {
|
||||
s.getMISession().postCommand(breakEnable);
|
||||
MIInfo info = breakEnable.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException("Timedout");
|
||||
throw new CDIException("No answer");
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.toString());
|
||||
}
|
||||
((Breakpoint)breakpoint).getMIBreakPoint().setEnabled(true);
|
||||
((Breakpoint) breakpoint).getMIBreakPoint().setEnabled(true);
|
||||
}
|
||||
|
||||
public void disableBreakpoint(ICDIBreakpoint breakpoint) throws CDIException {
|
||||
int number = 0;
|
||||
if (breakpoint instanceof Breakpoint && breakList.contains(breakpoint)) {
|
||||
number = ((Breakpoint)breakpoint).getMIBreakPoint().getNumber();
|
||||
if (breakpoint instanceof Breakpoint
|
||||
&& breakList.contains(breakpoint)) {
|
||||
number = ((Breakpoint) breakpoint).getMIBreakPoint().getNumber();
|
||||
} else {
|
||||
throw new CDIException("Not a CDT breakpoint");
|
||||
}
|
||||
CSession s = getCSession();
|
||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||
MIBreakDisable breakDisable = factory.createMIBreakDisable(new int[]{number});
|
||||
MIBreakDisable breakDisable =
|
||||
factory.createMIBreakDisable(new int[] { number });
|
||||
try {
|
||||
s.getMISession().postCommand(breakDisable);
|
||||
MIInfo info = breakDisable.getMIInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException("Timeout");
|
||||
throw new CDIException("No answer");
|
||||
}
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.toString());
|
||||
}
|
||||
((Breakpoint)breakpoint).getMIBreakPoint().setEnabled(false);
|
||||
((Breakpoint) breakpoint).getMIBreakPoint().setEnabled(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#getBreakpoints()
|
||||
*/
|
||||
public ICDIBreakpoint[] getBreakpoints() throws CDIException {
|
||||
return (ICDIBreakpoint[])breakList.toArray(new ICDIBreakpoint[breakList.size()]);
|
||||
CSession s = getCSession();
|
||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||
MIBreakList breakpointList = factory.createMIBreakList();
|
||||
try {
|
||||
s.getMISession().postCommand(breakpointList);
|
||||
MIBreakListInfo info = breakpointList.getMIBreakListInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException("No answer");
|
||||
}
|
||||
MIBreakPoint[] miPoints = info.getBreakPoints();
|
||||
for (int i = 0; i < miPoints.length; i++) {
|
||||
if (!containsBreakpoint(miPoints[i].getNumber())) {
|
||||
// FIXME: Generate a Create/Change Event??
|
||||
breakList.add(new Breakpoint(this, miPoints[i]));
|
||||
}
|
||||
}
|
||||
// FIXME: Generate a DestroyEvent for deleted ones.
|
||||
} catch (MIException e) {
|
||||
throw new CDIException(e.toString());
|
||||
}
|
||||
return (ICDIBreakpoint[]) listBreakpoints();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setCatchpoint(int, ICDICatchEvent, String, ICDICondition, boolean)
|
||||
*/
|
||||
public ICDICatchpoint setCatchpoint(int type, ICDICatchEvent event, String expression,
|
||||
public ICDICatchpoint setCatchpoint( int type, ICDICatchEvent event, String expression,
|
||||
ICDICondition condition) throws CDIException {
|
||||
throw new CDIException("Not Supported");
|
||||
}
|
||||
|
@ -147,7 +198,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
/**
|
||||
* @see org.eclipse.cdt.debug.core.cdi.ICDIBreakpointManager#setLocationBreakpoint(int, ICDILocation, ICDICondition, boolean, String)
|
||||
*/
|
||||
public ICDILocationBreakpoint setLocationBreakpoint(int type, ICDILocation location,
|
||||
public ICDILocationBreakpoint setLocationBreakpoint( int type, ICDILocation location,
|
||||
ICDICondition condition, String threadId) throws CDIException {
|
||||
|
||||
boolean hardware = (type == ICDIBreakpoint.HARDWARE);
|
||||
|
@ -155,15 +206,14 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
String exprCond = null;
|
||||
int ignoreCount = 0;
|
||||
StringBuffer line = new StringBuffer();
|
||||
|
||||
if (condition != null) {
|
||||
exprCond = condition.getExpression();
|
||||
ignoreCount = condition.getIgnoreCount();
|
||||
}
|
||||
|
||||
if (location != null) {
|
||||
String file = location.getFile();
|
||||
String function = location.getFunction();
|
||||
String file = location.getFile();
|
||||
String function = location.getFunction();
|
||||
if (file != null && file.length() > 0) {
|
||||
line.append(file).append(':');
|
||||
if (function != null && function.length() > 0) {
|
||||
|
@ -172,7 +222,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
line.append(location.getLineNumber());
|
||||
}
|
||||
} else if (function != null && function.length() > 0) {
|
||||
line.append(function);
|
||||
line.append(function);
|
||||
} else {
|
||||
line.append('*').append(location.getAddress());
|
||||
}
|
||||
|
@ -180,14 +230,15 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
|
||||
CSession s = getCSession();
|
||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||
MIBreakInsert breakInsert = factory.createMIBreakInsert(temporary, hardware,
|
||||
exprCond, ignoreCount, line.toString());
|
||||
MIBreakInsert breakInsert =
|
||||
factory.createMIBreakInsert( temporary, hardware, exprCond,
|
||||
ignoreCount, line.toString());
|
||||
MIBreakPoint[] points = null;
|
||||
try {
|
||||
s.getMISession().postCommand(breakInsert);
|
||||
MIBreakInsertInfo info = breakInsert.getMIBreakInsertInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException("Timedout");
|
||||
throw new CDIException("No answer");
|
||||
}
|
||||
points = info.getBreakPoints();
|
||||
if (points == null || points.length == 0) {
|
||||
|
@ -197,7 +248,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
throw new CDIException(e.toString());
|
||||
}
|
||||
|
||||
Breakpoint bkpt= new Breakpoint(this, points[0]);
|
||||
Breakpoint bkpt = new Breakpoint(this, points[0]);
|
||||
breakList.add(bkpt);
|
||||
return bkpt;
|
||||
}
|
||||
|
@ -205,22 +256,22 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
/**
|
||||
* @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 {
|
||||
boolean access = (type == ICDIWatchpoint.WRITE);
|
||||
boolean read = (type == ICDIWatchpoint.READ);
|
||||
|
||||
CSession s = getCSession();
|
||||
CommandFactory factory = s.getMISession().getCommandFactory();
|
||||
MIBreakWatch breakWatch = factory.createMIBreakWatch(access, read, expression);
|
||||
MIBreakWatch breakWatch =
|
||||
factory.createMIBreakWatch(access, read, expression);
|
||||
MIBreakPoint[] points = null;
|
||||
try {
|
||||
s.getMISession().postCommand(breakWatch);
|
||||
MIBreakWatchInfo info = breakWatch.getMIBreakWatchInfo();
|
||||
if (info == null) {
|
||||
throw new CDIException("Timedout");
|
||||
}
|
||||
points = info.getBreakPoints();
|
||||
if (info == null) {
|
||||
throw new CDIException("No answer");
|
||||
}
|
||||
if (points == null || points.length == 0) {
|
||||
throw new CDIException("Parsing Error");
|
||||
}
|
||||
|
@ -228,7 +279,7 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
|
|||
throw new CDIException(e.toString());
|
||||
}
|
||||
|
||||
Watchpoint bkpt= new Watchpoint(this, points[0]);
|
||||
Watchpoint bkpt = new Watchpoint(this, points[0]);
|
||||
breakList.add(bkpt);
|
||||
return bkpt;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue