1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

More cleanup for bug 303968.

This commit is contained in:
Ken Ryall 2010-03-04 22:16:13 +00:00
parent ebdc876c9b
commit a8b9452abb
8 changed files with 39 additions and 179 deletions

View file

@ -41,7 +41,6 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIEvent;
import org.eclipse.cdt.dsf.mi.service.command.events.MIInferiorExitEvent;
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
import org.eclipse.cdt.dsf.mi.service.command.events.MIThreadExitEvent;
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfSession;
@ -259,55 +258,6 @@ public class GDBRunControl extends MIRunControl {
canResume(context, rm);
}
/** @since 3.0 */
@Override
public void runToLocation(IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){
assert context != null;
final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
if (dmc == null){
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Given context: " + context + " is not an execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$
rm.done();
return;
}
if (doCanResume(dmc)) {
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class);
getConnection().queueCommand(
fCommandFactory.createMIBreakInsert(bpDmc, true, false, null, 0,
location, dmc.getThreadId()),
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) {
@Override
public void handleSuccess() {
// We must set are RunToLineActiveOperation *before* we do the resume
// or else we may get the stopped event, before we have set this variable.
int bpId = getData().getMIBreakpoints()[0].getNumber();
String addr = getData().getMIBreakpoints()[0].getAddress();
fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, location, addr, skipBreakpoints);
resume(dmc, new RequestMonitor(getExecutor(), rm) {
@Override
public void handleFailure() {
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fRunToLineActiveOperation.getThreadContext(),
IBreakpointsTargetDMContext.class);
int bpId = fRunToLineActiveOperation.getBreakointId();
getConnection().queueCommand(fCommandFactory.createMIBreakDelete(bpDmc, new int[] {bpId}),
new DataRequestMonitor<MIInfo>(getExecutor(), null));
fRunToLineActiveOperation = null;
super.handleFailure();
}
});
}
});
} else {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED,
"Cannot resume given DMC.", null)); //$NON-NLS-1$
rm.done();
}
}
/**
* @nooverride This method is not intended to be re-implemented or extended by clients.

View file

@ -41,7 +41,6 @@ import org.eclipse.cdt.dsf.mi.service.command.CommandFactory;
import org.eclipse.cdt.dsf.mi.service.command.events.MIBreakpointHitEvent;
import org.eclipse.cdt.dsf.mi.service.command.events.MIInferiorExitEvent;
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
import org.eclipse.cdt.dsf.service.DsfSession;
@ -431,90 +430,7 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
}
});
}
/** @since 3.0 */
@Override
public void runToLocation(final IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){
assert context != null;
final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
if (dmc == null){
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Given context: " + context + " is not an execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$
rm.done();
return;
}
if (doCanResume(dmc)) {
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class);
getConnection().queueCommand(
fCommandFactory.createMIBreakInsert(bpDmc, true, false, null, 0,
location, dmc.getThreadId()),
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) {
@Override
public void handleSuccess() {
// We must set are RunToLineActiveOperation *before* we do the resume
// or else we may get the stopped event, before we have set this variable.
int bpId = getData().getMIBreakpoints()[0].getNumber();
String addr = getData().getMIBreakpoints()[0].getAddress();
fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, location, addr, skipBreakpoints);
resume(dmc, new RequestMonitor(getExecutor(), rm) {
@Override
public void handleFailure() {
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fRunToLineActiveOperation.getThreadContext(),
IBreakpointsTargetDMContext.class);
int bpId = fRunToLineActiveOperation.getBreakointId();
getConnection().queueCommand(fCommandFactory.createMIBreakDelete(bpDmc, new int[] {bpId}),
new DataRequestMonitor<MIInfo>(getExecutor(), null));
fRunToLineActiveOperation = null;
super.handleFailure();
}
});
}
});
} else {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED,
"Cannot resume given DMC.", null)); //$NON-NLS-1$
rm.done();
}
}
/** @since 3.0 */
@Override
public void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm) {
assert context != null;
final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
if (dmc == null){
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Given context: " + context + " is not an thread execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$
rm.done();
return;
}
if (doCanResume(dmc)) {
setResumePending(true);
getCache().setContextAvailable(dmc, false);
getConnection().queueCommand(
fCommandFactory.createMIExecJump(dmc, location),
new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
@Override
protected void handleFailure() {
setResumePending(false);
getCache().setContextAvailable(dmc, true);
super.handleFailure();
}
});
} else {
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED,
"Cannot resume given DMC.", null)); //$NON-NLS-1$
rm.done();
}
}
/**
* @nooverride This method is not intended to be re-implemented or extended by clients.
* @noreference This method is not intended to be referenced by clients.

View file

@ -622,8 +622,7 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
// Run to line
// ------------------------------------------------------------------------
/** @since 3.0 */
public void runToLocation(final IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){
private void runToLocation(final IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){
assert context != null;
@ -686,8 +685,7 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
// Resume at location
// ------------------------------------------------------------------------
/** @since 3.0 */
public void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm) {
private void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm) {
assert context != null;
final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
@ -1205,7 +1203,7 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
*/
public void runToAddress(IExecutionDMContext context, IAddress address,
boolean skipBreakpoints, RequestMonitor rm) {
runToLocation(context, "*0x" + address.toHexAddressString(), skipBreakpoints, rm); //$NON-NLS-1$
runToLocation(context, "*0x" + address.toString(16), skipBreakpoints, rm); //$NON-NLS-1$
}
/* (non-Javadoc)
@ -1233,20 +1231,21 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
}
else
{
// Create the breakpoint attributes
Map<String,Object> attr = new HashMap<String,Object>();
attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT);
attr.put(MIBreakpoints.FILE_NAME, sourceFile);
attr.put(MIBreakpoints.LINE_NUMBER, lineNumber);
attr.put(MIBreakpointDMData.IS_TEMPORARY, true);
attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId()));
// Now do the operation
String location = sourceFile + ":" + lineNumber; //$NON-NLS-1$
if (resume)
resumeAtLocation(context, location, rm);
else
{
// Create the breakpoint attributes
Map<String,Object> attr = new HashMap<String,Object>();
attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT);
attr.put(MIBreakpoints.FILE_NAME, sourceFile);
attr.put(MIBreakpoints.LINE_NUMBER, lineNumber);
attr.put(MIBreakpointDMData.IS_TEMPORARY, true);
attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId()));
// Now do the operation
moveToLocation(context, location, attr, rm);
}
}
}
@ -1274,19 +1273,21 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
}
else
{
// Create the breakpoint attributes
Map<String,Object> attr = new HashMap<String,Object>();
attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT);
attr.put(MIBreakpoints.ADDRESS, "0x" + address.toString(16)); //$NON-NLS-1$
attr.put(MIBreakpointDMData.IS_TEMPORARY, true);
attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId()));
// Now do the operation
String location = "*0x" + address.toString(16); //$NON-NLS-1$
if (resume)
resumeAtLocation(context, location, rm);
else
{
// Create the breakpoint attributes
Map<String,Object> attr = new HashMap<String,Object>();
attr.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.BREAKPOINT);
attr.put(MIBreakpoints.ADDRESS, "0x" + address.toString(16)); //$NON-NLS-1$
attr.put(MIBreakpointDMData.IS_TEMPORARY, true);
attr.put(MIBreakpointDMData.THREAD_ID, Integer.toString(threadExecDmc.getThreadId()));
// Now do the operation
moveToLocation(context, location, attr, rm);
}
}
}

View file

@ -726,8 +726,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I
rm.done();
}
/** @since 3.0 */
public void runToLocation(IExecutionDMContext context, String location, boolean skipBreakpoints, final RequestMonitor rm){
private void runToLocation(IExecutionDMContext context, String location, boolean skipBreakpoints, final RequestMonitor rm){
// skipBreakpoints is not used at the moment. Implement later
assert context != null;
@ -751,8 +750,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I
}
}
/** @since 3.0 */
public void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm) {
private void resumeAtLocation(IExecutionDMContext context, String location, RequestMonitor rm) {
assert context != null;
final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
@ -978,7 +976,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I
*/
public void runToAddress(IExecutionDMContext context, IAddress address,
boolean skipBreakpoints, RequestMonitor rm) {
runToLocation(context, "*0x" + address.toHexAddressString(), skipBreakpoints, rm); //$NON-NLS-1$
runToLocation(context, "*0x" + address.toString(16), skipBreakpoints, rm); //$NON-NLS-1$
}
/* (non-Javadoc)

View file

@ -31,13 +31,13 @@ import org.eclipse.debug.core.model.ISuspendResume;
*/
public class SuspendResumeAdapterFactory implements IAdapterFactory {
static class GdbSuspendResume implements ISuspendResume, IAdaptable {
static class SuspendResume implements ISuspendResume, IAdaptable {
private final RunToLine fRunToLine;
private final MoveToLine fMoveToLine;
private final ResumeAtLine fResumeAtLine;
GdbSuspendResume(IExecutionDMContext execCtx) {
SuspendResume(IExecutionDMContext execCtx) {
fRunToLine = new RunToLine(execCtx);
fMoveToLine = new MoveToLine(execCtx);
fResumeAtLine = new ResumeAtLine(execCtx);
@ -77,7 +77,7 @@ public class SuspendResumeAdapterFactory implements IAdapterFactory {
// It only makes sense to RunToLine, MoveToLine or
// ResumeAtLine if we are dealing with a thread, not a container
if (execDmc != null && !(execDmc instanceof IContainerDMContext)) {
return new GdbSuspendResume(execDmc);
return new SuspendResume(execDmc);
}
}
}

View file

@ -18,7 +18,6 @@ import org.eclipse.cdt.debug.core.model.IMoveToAddress;
import org.eclipse.cdt.debug.core.model.IMoveToLine;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
import org.eclipse.cdt.dsf.concurrent.Query;
import org.eclipse.cdt.dsf.debug.service.IRunControl2;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
@ -86,8 +85,7 @@ public class MoveToLine implements IMoveToLine, IMoveToAddress {
IRunControl2 runControl = tracker.getService(IRunControl2.class);
if (runControl != null) {
runControl.moveToLine(
fContext, fileName, lineNumber, false,
new DataRequestMonitor<Object>(ImmediateExecutor.getInstance(), rm));
fContext, fileName, lineNumber, false, rm);
} else {
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$
rm.done();
@ -105,7 +103,7 @@ public class MoveToLine implements IMoveToLine, IMoveToAddress {
exception = e;
}
if (exception != null) {
throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$
throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Failed executing move to line", exception)); //$NON-NLS-1$
}
} else {
throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$
@ -156,8 +154,7 @@ public class MoveToLine implements IMoveToLine, IMoveToAddress {
IRunControl2 runControl = tracker.getService(IRunControl2.class);
if (runControl != null) {
runControl.moveToAddress(
fContext, address, false,
new DataRequestMonitor<Object>(ImmediateExecutor.getInstance(), rm));
fContext, address, false, rm);
} else {
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "IRunControl2 service not available", null)); //$NON-NLS-1$
rm.done();
@ -175,7 +172,7 @@ public class MoveToLine implements IMoveToLine, IMoveToAddress {
exception = e;
}
if (exception != null) {
throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Faild executing move to line", exception)); //$NON-NLS-1$
throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Failed executing move to line", exception)); //$NON-NLS-1$
}
} else {
throw new DebugException(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, DebugException.REQUEST_FAILED, "Debug session is not active", null)); //$NON-NLS-1$

View file

@ -36,7 +36,7 @@ import org.eclipse.debug.ui.actions.IRunToLineTarget;
* Implements the CDT's run to line interface. This interface is called by CDT's
* {@link IRunToLineTarget} implementation.
*
* @since 2.0
* @since 2.1
*/
public class RunToLine implements IRunToLine, IRunToAddress {
@ -124,7 +124,6 @@ public class RunToLine implements IRunToLine, IRunToAddress {
}
}
/** @since 2.1 */
public boolean canRunToAddress(final IAddress address) {
DsfSession session = DsfSession.getSession(fContext.getSessionId());
if (session != null && session.isActive()) {
@ -155,7 +154,6 @@ public class RunToLine implements IRunToLine, IRunToAddress {
return false;
}
/** @since 2.1 */
public void runToAddress(final IAddress address, final boolean skipBreakpoints) throws DebugException {
DsfSession session = DsfSession.getSession(fContext.getSessionId());
if (session != null && session.isActive()) {

View file

@ -16,7 +16,7 @@ public interface IRunControl2 extends IRunControl {
* a source file and line number.
*
* @param context the execution DM context
* @param sourceFile the source file, full path if possible
* @param sourceFile the source file path, mapped to a debugger path if possible.
* @param lineNumber the line number offset (one-based) into the source file
* @param rm the DataRequestMonitor that will return the result
*/
@ -29,7 +29,7 @@ public interface IRunControl2 extends IRunControl {
* other breakpoints and continue until the specified location.
*
* @param context the execution DM context
* @param sourceFile the source file, full path if possible
* @param sourceFile the source file path, mapped to a debugger path if possible.
* @param lineNumber the line number offset into (one-based) the source file
* @param skipBreakpoints skip breakpoints while performing this operation
* @param rm the Request Monitor
@ -64,7 +64,7 @@ public interface IRunControl2 extends IRunControl {
* source location.
*
* @param context the execution DM context
* @param sourceFile the source file, full path if possible
* @param sourceFile the source file path, mapped to a debugger path if possible.
* @param lineNumber the line number offset (one-based) into the source file
* @param resume resume execution after moving the PC
* @param rm the DataRequestMonitor that will return the result
@ -76,7 +76,7 @@ public interface IRunControl2 extends IRunControl {
* source location.
*
* @param context the execution DM context
* @param sourceFile the source file, full path if possible
* @param sourceFile the source file path, mapped to a debugger path if possible.
* @param lineNumber the line number offset (one-based) into the source file
* @param resume resume execution after moving the PC
* @param rm the Request Monitor