mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-14 03:35:37 +02:00
workon Exception.
This commit is contained in:
parent
e030d04985
commit
da98600ac3
4 changed files with 78 additions and 11 deletions
|
@ -28,6 +28,7 @@ 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.model.Breakpoint;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Exceptionpoint;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Watchpoint;
|
||||
import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
|
||||
|
@ -579,9 +580,56 @@ public class BreakpointManager extends Manager {
|
|||
return bkpt;
|
||||
}
|
||||
|
||||
Breakpoint[] exceptionBps = new Breakpoint[2];
|
||||
final int EXCEPTION_THROW_IDX = 0;
|
||||
final int EXCEPTION_CATCH_IDX = 1;
|
||||
final static String[] EXCEPTION_FUNCS = new String[] {"__cxa_throw", "__cxa_begin_catch"}; //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
||||
|
||||
public ICDIExceptionpoint setExceptionpoint(Target target, String clazz, boolean stopOnThrow,
|
||||
boolean stopOnCatch) throws CDIException {
|
||||
return null;
|
||||
|
||||
if (!stopOnThrow && !stopOnCatch) {
|
||||
throw new CDIException("Must suspend on throw or catch"); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
MIBreakpoint miBreakpoint = null;
|
||||
|
||||
if (stopOnThrow) {
|
||||
synchronized(exceptionBps) {
|
||||
int id = EXCEPTION_THROW_IDX;
|
||||
if (exceptionBps[EXCEPTION_THROW_IDX] == null) {
|
||||
Location location = new Location(null, EXCEPTION_FUNCS[id], 0);
|
||||
Breakpoint bp = new Breakpoint(target, ICDIBreakpoint.REGULAR, location, null, null);
|
||||
setLocationBreakpoint(bp);
|
||||
exceptionBps[id] = bp;
|
||||
miBreakpoint = bp.getMIBreakpoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stopOnCatch) {
|
||||
synchronized(exceptionBps) {
|
||||
int id = EXCEPTION_THROW_IDX;
|
||||
if (exceptionBps[id] == null) {
|
||||
Location location = new Location(null, EXCEPTION_FUNCS[id], 0);
|
||||
Breakpoint bp = new Breakpoint(target, ICDIBreakpoint.REGULAR, location, null, null);
|
||||
setLocationBreakpoint(bp);
|
||||
exceptionBps[id] = bp;
|
||||
miBreakpoint = bp.getMIBreakpoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Exceptionpoint excp = new Exceptionpoint(target, clazz, stopOnThrow, stopOnCatch);
|
||||
excp.setMIBreakpoint(miBreakpoint);
|
||||
List blist = getBreakpointsList(target);
|
||||
blist.add(excp);
|
||||
|
||||
// Fire a created Event.
|
||||
MISession miSession = target.getMISession();
|
||||
miSession.fireEvent(new MIBreakpointCreatedEvent(miSession, excp.getMIBreakpoint().getNumber()));
|
||||
|
||||
return excp;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.eclipse.cdt.debug.mi.core.command.MIThreadSelect;
|
|||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointChangedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointCreatedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointDeletedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIBreakpointHitEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIChangedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MICreatedEvent;
|
||||
import org.eclipse.cdt.debug.mi.core.event.MIDestroyedEvent;
|
||||
|
@ -273,6 +274,11 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
|||
return false;
|
||||
}
|
||||
|
||||
if (processBreakpointHitEvent(stopped)) {
|
||||
// Event was consumed, i.e. it was not the right exception.
|
||||
return false;
|
||||
}
|
||||
|
||||
int threadId = threadId = stopped.getThreadId();
|
||||
currentTarget.updateState(threadId);
|
||||
try {
|
||||
|
@ -506,6 +512,19 @@ public class EventManager extends SessionObject implements ICDIEventManager, Obs
|
|||
return false;
|
||||
}
|
||||
|
||||
boolean processBreakpointHitEvent(MIStoppedEvent stopped) {
|
||||
Session session = (Session)getSession();
|
||||
if (stopped instanceof MIBreakpointHitEvent) {
|
||||
MIBreakpointHitEvent bpEvent = (MIBreakpointHitEvent)stopped;
|
||||
BreakpointManager bpMgr = session.getBreakpointManager();
|
||||
int bpNo = bpEvent.getNumber();
|
||||
//if (bpMgr.isExceptionBreakpoint(bpNo)) {
|
||||
|
||||
//}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do any processing of before a running event.
|
||||
*/
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;
|
|||
*/
|
||||
public class Breakpoint extends CObject implements ICDILocationBreakpoint {
|
||||
|
||||
ICDILocation location;
|
||||
ICDILocation fLocation;
|
||||
ICDICondition condition;
|
||||
MIBreakpoint miBreakpoint;
|
||||
//BreakpointManager mgr;
|
||||
|
@ -37,7 +37,7 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint {
|
|||
super(target);
|
||||
//mgr = m;
|
||||
type = kind;
|
||||
location = loc;
|
||||
fLocation = loc;
|
||||
condition = cond;
|
||||
tid = threadId;
|
||||
enable = true;
|
||||
|
@ -57,7 +57,7 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint {
|
|||
miBreakpoint = newMIBreakpoint;
|
||||
// Force the reset to use GDB's values.
|
||||
condition = null;
|
||||
location = null;
|
||||
fLocation = null;
|
||||
}
|
||||
|
||||
public boolean isDeferred() {
|
||||
|
@ -148,18 +148,18 @@ public class Breakpoint extends CObject implements ICDILocationBreakpoint {
|
|||
* @see org.eclipse.cdt.debug.core.cdi.ICDILocationBreakpoint#getLocation()
|
||||
*/
|
||||
public ICDILocation getLocation() throws CDIException {
|
||||
if (location == null) {
|
||||
if (fLocation == null) {
|
||||
if (miBreakpoint != null) {
|
||||
location = new Location (miBreakpoint.getFile(),
|
||||
fLocation = new Location (miBreakpoint.getFile(),
|
||||
miBreakpoint.getFunction(),
|
||||
miBreakpoint.getLine(),
|
||||
miBreakpoint.getAddress());
|
||||
}
|
||||
}
|
||||
return location;
|
||||
return fLocation;
|
||||
}
|
||||
|
||||
public void setLocation(ICDILocation loc) {
|
||||
location = loc;
|
||||
fLocation = loc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ public class Exceptionpoint extends Breakpoint implements ICDIExceptionpoint {
|
|||
|
||||
/**
|
||||
*/
|
||||
public Exceptionpoint(Target target, String name, boolean stopOnThrow, boolean stopOnCatch) {
|
||||
public Exceptionpoint(Target target, String clazz, boolean stopOnThrow, boolean stopOnCatch) {
|
||||
super(target, ICDIBreakpoint.REGULAR, null, null, null);
|
||||
fClazz = name;
|
||||
fClazz = clazz;
|
||||
fStopOnThrow = stopOnThrow;
|
||||
fStopOnCatch = stopOnCatch;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue