mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
[302324] Make RunToLine work for DSF Disassembly view
This commit is contained in:
parent
eec11c475f
commit
a381ee1d47
10 changed files with 288 additions and 68 deletions
|
@ -167,6 +167,13 @@
|
||||||
adaptableType="org.eclipse.cdt.dsf.ui.viewmodel.IVMContext">
|
adaptableType="org.eclipse.cdt.dsf.ui.viewmodel.IVMContext">
|
||||||
<adapter type="org.eclipse.debug.core.model.ISuspendResume"/>
|
<adapter type="org.eclipse.debug.core.model.ISuspendResume"/>
|
||||||
</factory>
|
</factory>
|
||||||
|
<factory
|
||||||
|
class="org.eclipse.cdt.dsf.gdb.internal.ui.actions.RetargettableActionAdapterFactory"
|
||||||
|
adaptableType="org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyView">
|
||||||
|
<adapter type="org.eclipse.debug.ui.actions.IRunToLineTarget"/>
|
||||||
|
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget"/>
|
||||||
|
<adapter type="org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget"/>
|
||||||
|
</factory>
|
||||||
</extension>
|
</extension>
|
||||||
|
|
||||||
<extension point="org.eclipse.debug.ui.memoryRenderings">
|
<extension point="org.eclipse.debug.ui.memoryRenderings">
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010 Ericsson and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Ericsson - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.IAddress;
|
||||||
|
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
|
import org.eclipse.cdt.debug.core.model.IRunToAddress;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||||
|
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection;
|
||||||
|
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
|
||||||
|
import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
|
||||||
|
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||||
|
import org.eclipse.cdt.utils.Addr64;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
import org.eclipse.debug.core.model.ISuspendResume;
|
||||||
|
import org.eclipse.debug.ui.DebugUITools;
|
||||||
|
import org.eclipse.debug.ui.IDebugUIConstants;
|
||||||
|
import org.eclipse.debug.ui.actions.IRunToLineTarget;
|
||||||
|
import org.eclipse.jface.text.ITextSelection;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.ui.IWorkbenchPart;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Run to line target adapter for the DSF Disassembly view
|
||||||
|
*
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class DisassemblyRunToLineAdapter implements IRunToLineTarget {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.ui.actions.IRunToLineTarget#runToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
|
||||||
|
*/
|
||||||
|
public void runToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) throws CoreException {
|
||||||
|
if (part instanceof IDisassemblyPart && selection instanceof ITextSelection) {
|
||||||
|
if (!(selection instanceof IDisassemblySelection)) {
|
||||||
|
selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
|
||||||
|
}
|
||||||
|
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
|
||||||
|
BigInteger rawAddress = disassemblySelection.getStartAddress();
|
||||||
|
if (rawAddress == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final IAddress address = new Addr64(rawAddress);
|
||||||
|
if (address != null && target instanceof IAdaptable) {
|
||||||
|
final IRunToAddress runToAddress = (IRunToAddress)((IAdaptable)target).getAdapter(IRunToAddress.class);
|
||||||
|
if (runToAddress != null && runToAddress.canRunToAddress(address)) {
|
||||||
|
// Runnable r = new Runnable() {
|
||||||
|
// public void run() {
|
||||||
|
try {
|
||||||
|
boolean skipBreakpoints = DebugUITools.getPreferenceStore().getBoolean(IDebugUIConstants.PREF_SKIP_BREAKPOINTS_DURING_RUN_TO_LINE);
|
||||||
|
runToAddress.runToAddress(address, skipBreakpoints);
|
||||||
|
}
|
||||||
|
catch( DebugException e ) {
|
||||||
|
failed( e );
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// DebugPlugin.getDefault().asyncExec(r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.debug.ui.actions.IRunToLineTarget#canRunToLine(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection, org.eclipse.debug.core.model.ISuspendResume)
|
||||||
|
*/
|
||||||
|
public boolean canRunToLine(IWorkbenchPart part, ISelection selection, ISuspendResume target) {
|
||||||
|
if (target instanceof IAdaptable && part instanceof IDisassemblyPart && selection instanceof ITextSelection) {
|
||||||
|
IRunToAddress runToAddress = (IRunToAddress)((IAdaptable)target).getAdapter(IRunToAddress.class);
|
||||||
|
if (runToAddress == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(selection instanceof IDisassemblySelection)) {
|
||||||
|
selection = new DisassemblySelection((ITextSelection)selection, (IDisassemblyPart)part);
|
||||||
|
}
|
||||||
|
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
|
||||||
|
BigInteger rawAddress = disassemblySelection.getStartAddress();
|
||||||
|
if (rawAddress == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final IAddress address = new Addr64(rawAddress);
|
||||||
|
return runToAddress.canRunToAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void failed( Throwable e ) {
|
||||||
|
MultiStatus ms = new MultiStatus( CDIDebugModel.getPluginIdentifier(), IDsfStatusConstants.REQUEST_FAILED, "RunToLine failed", null ); //$NON-NLS-1$
|
||||||
|
ms.add( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), IDsfStatusConstants.REQUEST_FAILED, e.getMessage(), e ) );
|
||||||
|
GdbUIPlugin.log(ms);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009 Wind River Systems and others.
|
* Copyright (c) 2009, 2010 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,12 +7,15 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Wind River Systems - initial API and implementation
|
* Wind River Systems - initial API and implementation
|
||||||
|
* Ericsson - Added support for IRunToAddress for DSF DisassemblyView (302324)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.RejectedExecutionException;
|
import java.util.concurrent.RejectedExecutionException;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.IAddress;
|
||||||
|
import org.eclipse.cdt.debug.core.model.IRunToAddress;
|
||||||
import org.eclipse.cdt.debug.core.model.IRunToLine;
|
import org.eclipse.cdt.debug.core.model.IRunToLine;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
|
||||||
|
@ -37,7 +40,7 @@ import org.eclipse.debug.ui.actions.IRunToLineTarget;
|
||||||
*
|
*
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public class GdbRunToLine implements IRunToLine {
|
public class GdbRunToLine implements IRunToLine, IRunToAddress {
|
||||||
|
|
||||||
private final IExecutionDMContext fContext;
|
private final IExecutionDMContext fContext;
|
||||||
|
|
||||||
|
@ -46,14 +49,32 @@ public class GdbRunToLine implements IRunToLine {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRunToLine(IFile file, int lineNumber) {
|
public boolean canRunToLine(IFile file, int lineNumber) {
|
||||||
return canRunToLine();
|
return canRunToLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canRunToLine(String fileName, int lineNumber) {
|
public boolean canRunToLine(String fileName, int lineNumber) {
|
||||||
return canRunToLine();
|
return canRunToLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canRunToLine() {
|
public void runToLine(IFile file, int lineNumber, boolean skipBreakpoints) throws DebugException {
|
||||||
|
runToLine(file.getLocation().makeAbsolute().toOSString(), lineNumber, skipBreakpoints);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runToLine(String fileName, int lineNumber, boolean skipBreakpoints) throws DebugException {
|
||||||
|
runToLocation(fileName + ":" + lineNumber, skipBreakpoints); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @since 2.1 */
|
||||||
|
public boolean canRunToAddress(IAddress address) {
|
||||||
|
return canRunToLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @since 2.1 */
|
||||||
|
public void runToAddress(IAddress address, boolean skipBreakpoints) throws DebugException {
|
||||||
|
runToLocation("*0x" + address.toString(16), skipBreakpoints); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean canRunToLocation() {
|
||||||
DsfSession session = DsfSession.getSession(fContext.getSessionId());
|
DsfSession session = DsfSession.getSession(fContext.getSessionId());
|
||||||
if (session != null && session.isActive()) {
|
if (session != null && session.isActive()) {
|
||||||
try {
|
try {
|
||||||
|
@ -83,11 +104,7 @@ public class GdbRunToLine implements IRunToLine {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runToLine(IFile file, int lineNumber, boolean skipBreakpoints) throws DebugException {
|
private void runToLocation(final String location, final boolean skipBreakpoints) throws DebugException {
|
||||||
runToLine(file.getLocation().makeAbsolute().toOSString(), lineNumber, skipBreakpoints);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runToLine(final String fileName, final int lineNumber, final boolean skipBreakpoints) throws DebugException {
|
|
||||||
DsfSession session = DsfSession.getSession(fContext.getSessionId());
|
DsfSession session = DsfSession.getSession(fContext.getSessionId());
|
||||||
if (session != null && session.isActive()) {
|
if (session != null && session.isActive()) {
|
||||||
Throwable exception = null;
|
Throwable exception = null;
|
||||||
|
@ -100,15 +117,9 @@ public class GdbRunToLine implements IRunToLine {
|
||||||
|
|
||||||
IMIRunControl miRunControl = tracker.getService(IMIRunControl.class);
|
IMIRunControl miRunControl = tracker.getService(IMIRunControl.class);
|
||||||
if (miRunControl != null) {
|
if (miRunControl != null) {
|
||||||
miRunControl.runToLine(
|
miRunControl.runToLocation(
|
||||||
fContext, fileName, Integer.toString(lineNumber), skipBreakpoints,
|
fContext, location, skipBreakpoints,
|
||||||
new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm) {
|
new DataRequestMonitor<MIInfo>(ImmediateExecutor.getInstance(), rm));
|
||||||
@Override
|
|
||||||
protected void handleSuccess() {
|
|
||||||
rm.setData(new Object());
|
|
||||||
rm.done();
|
|
||||||
};
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "MIRunControl service not available", null)); //$NON-NLS-1$
|
rm.setStatus(new Status(IStatus.ERROR, GdbUIPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "MIRunControl service not available", null)); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2010 Ericsson and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Ericsson - Initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.dsf.gdb.internal.ui.actions;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.actions.IMoveToLineTarget;
|
||||||
|
import org.eclipse.cdt.debug.internal.ui.actions.IResumeAtLineTarget;
|
||||||
|
import org.eclipse.core.runtime.IAdapterFactory;
|
||||||
|
import org.eclipse.debug.ui.actions.IRunToLineTarget;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retargettable Action Adapter Factory for the DSF Disassembly view
|
||||||
|
*
|
||||||
|
* @since 2.1
|
||||||
|
*/
|
||||||
|
public class RetargettableActionAdapterFactory implements IAdapterFactory {
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
|
||||||
|
*/
|
||||||
|
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||||
|
if (adapterType == IRunToLineTarget.class) {
|
||||||
|
return new DisassemblyRunToLineAdapter();
|
||||||
|
}
|
||||||
|
// if (adapterType == IResumeAtLineTarget.class) {
|
||||||
|
// return new DisassemblyResumeAtLineAdapter();
|
||||||
|
// }
|
||||||
|
// if (adapterType == IMoveToLineTarget.class) {
|
||||||
|
// return new DisassemblyMoveToLineAdapter();
|
||||||
|
// }
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
|
||||||
|
*/
|
||||||
|
public Class[] getAdapterList() {
|
||||||
|
return new Class[]{ IRunToLineTarget.class, IResumeAtLineTarget.class, IMoveToLineTarget.class };
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems and others.
|
* Copyright (c) 2006, 2010 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -257,11 +257,9 @@ public class GDBRunControl extends MIRunControl {
|
||||||
canResume(context, rm);
|
canResume(context, rm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 2.0 */
|
/** @since 3.0 */
|
||||||
@Override
|
@Override
|
||||||
public void runToLine(final IExecutionDMContext context, String fileName, String lineNo, final boolean skipBreakpoints, final DataRequestMonitor<MIInfo> rm){
|
public void runToLocation(IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){
|
||||||
// Later add support for Address and function.
|
|
||||||
|
|
||||||
assert context != null;
|
assert context != null;
|
||||||
|
|
||||||
final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
|
final IMIExecutionDMContext dmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class);
|
||||||
|
@ -271,12 +269,11 @@ public class GDBRunControl extends MIRunControl {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doCanResume(context)) {
|
if (doCanResume(dmc)) {
|
||||||
final String fileLocation = fileName + ":" + lineNo; //$NON-NLS-1$
|
|
||||||
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class);
|
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class);
|
||||||
getConnection().queueCommand(
|
getConnection().queueCommand(
|
||||||
new MIBreakInsert(bpDmc, true, false, null, 0,
|
new MIBreakInsert(bpDmc, true, false, null, 0,
|
||||||
fileLocation, dmc.getThreadId()),
|
location, dmc.getThreadId()),
|
||||||
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) {
|
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
public void handleSuccess() {
|
public void handleSuccess() {
|
||||||
|
@ -284,9 +281,9 @@ public class GDBRunControl extends MIRunControl {
|
||||||
// or else we may get the stopped event, before we have set this variable.
|
// or else we may get the stopped event, before we have set this variable.
|
||||||
int bpId = getData().getMIBreakpoints()[0].getNumber();
|
int bpId = getData().getMIBreakpoints()[0].getNumber();
|
||||||
String addr = getData().getMIBreakpoints()[0].getAddress();
|
String addr = getData().getMIBreakpoints()[0].getAddress();
|
||||||
fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, fileLocation, addr, skipBreakpoints);
|
fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, location, addr, skipBreakpoints);
|
||||||
|
|
||||||
resume(context, new RequestMonitor(getExecutor(), rm) {
|
resume(dmc, new RequestMonitor(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
public void handleFailure() {
|
public void handleFailure() {
|
||||||
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fRunToLineActiveOperation.getThreadContext(),
|
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fRunToLineActiveOperation.getThreadContext(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Wind River Systems and others.
|
* Copyright (c) 2008, 2010 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -435,10 +435,9 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 2.0 */
|
/** @since 3.0 */
|
||||||
@Override
|
@Override
|
||||||
public void runToLine(final IExecutionDMContext context, String fileName, String lineNo, final boolean skipBreakpoints, final DataRequestMonitor<MIInfo> rm){
|
public void runToLocation(final IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){
|
||||||
// Later add support for Address and function.
|
|
||||||
|
|
||||||
assert context != null;
|
assert context != null;
|
||||||
|
|
||||||
|
@ -449,12 +448,11 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doCanResume(context)) {
|
if (doCanResume(dmc)) {
|
||||||
final String fileLocation = fileName + ":" + lineNo; //$NON-NLS-1$
|
|
||||||
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class);
|
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class);
|
||||||
getConnection().queueCommand(
|
getConnection().queueCommand(
|
||||||
new MIBreakInsert(bpDmc, true, false, null, 0,
|
new MIBreakInsert(bpDmc, true, false, null, 0,
|
||||||
fileLocation, dmc.getThreadId()),
|
location, dmc.getThreadId()),
|
||||||
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) {
|
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
public void handleSuccess() {
|
public void handleSuccess() {
|
||||||
|
@ -462,9 +460,9 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
|
||||||
// or else we may get the stopped event, before we have set this variable.
|
// or else we may get the stopped event, before we have set this variable.
|
||||||
int bpId = getData().getMIBreakpoints()[0].getNumber();
|
int bpId = getData().getMIBreakpoints()[0].getNumber();
|
||||||
String addr = getData().getMIBreakpoints()[0].getAddress();
|
String addr = getData().getMIBreakpoints()[0].getAddress();
|
||||||
fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, fileLocation, addr, skipBreakpoints);
|
fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, location, addr, skipBreakpoints);
|
||||||
|
|
||||||
resume(context, new RequestMonitor(getExecutor(), rm) {
|
resume(dmc, new RequestMonitor(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
public void handleFailure() {
|
public void handleFailure() {
|
||||||
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fRunToLineActiveOperation.getThreadContext(),
|
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(fRunToLineActiveOperation.getThreadContext(),
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems and others.
|
* Copyright (c) 2006, 2010 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -608,7 +608,8 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
|
||||||
// Run to line
|
// Run to line
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
public void runToLine(IExecutionDMContext context, String fileName, String lineNo, final boolean skipBreakpoints, final DataRequestMonitor<MIInfo> rm) {
|
/** @since 3.0 */
|
||||||
|
public void runToLocation(final IExecutionDMContext context, final String location, final boolean skipBreakpoints, final RequestMonitor rm){
|
||||||
|
|
||||||
assert context != null;
|
assert context != null;
|
||||||
|
|
||||||
|
@ -620,26 +621,25 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doCanResume(context)) {
|
if (!doCanResume(dmc)) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE,
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE,
|
||||||
"Cannot resume context", null)); //$NON-NLS-1$
|
"Cannot resume context", null)); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MIThreadRunState threadState = fThreadRunStates.get(context);
|
MIThreadRunState threadState = fThreadRunStates.get(dmc);
|
||||||
if (threadState == null) {
|
if (threadState == null) {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE,
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE,
|
||||||
"Given context: " + context + " is not an MI execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$
|
"Given context: " + dmc + " is not an MI execution context.", null)); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
rm.done();
|
rm.done();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String fileLocation = fileName + ":" + lineNo; //$NON-NLS-1$
|
|
||||||
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class);
|
IBreakpointsTargetDMContext bpDmc = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class);
|
||||||
fConnection.queueCommand(
|
fConnection.queueCommand(
|
||||||
new MIBreakInsert(bpDmc, true, false, null, 0,
|
new MIBreakInsert(bpDmc, true, false, null, 0,
|
||||||
fileLocation, dmc.getThreadId()),
|
location, dmc.getThreadId()),
|
||||||
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) {
|
new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
public void handleSuccess() {
|
public void handleSuccess() {
|
||||||
|
@ -647,7 +647,7 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
|
||||||
// or else we may get the stopped event, before we have set this variable.
|
// or else we may get the stopped event, before we have set this variable.
|
||||||
int bpId = getData().getMIBreakpoints()[0].getNumber();
|
int bpId = getData().getMIBreakpoints()[0].getNumber();
|
||||||
String addr = getData().getMIBreakpoints()[0].getAddress();
|
String addr = getData().getMIBreakpoints()[0].getAddress();
|
||||||
fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, fileLocation, addr, skipBreakpoints);
|
fRunToLineActiveOperation = new RunToLineActiveOperation(dmc, bpId, location, addr, skipBreakpoints);
|
||||||
|
|
||||||
resume(dmc, new RequestMonitor(getExecutor(), rm) {
|
resume(dmc, new RequestMonitor(getExecutor(), rm) {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2009 Ericsson and others.
|
* Copyright (c) 2009, 2010 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,9 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.mi.service;
|
package org.eclipse.cdt.dsf.mi.service;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface provides methods for RunControl that are not
|
* This interface provides methods for RunControl that are not
|
||||||
|
@ -27,8 +26,9 @@ public interface IMIRunControl extends IRunControl
|
||||||
* If skipBreakpoints is false, any other breakpoint will stop this
|
* If skipBreakpoints is false, any other breakpoint will stop this
|
||||||
* command; while if skipBreakpoints is true, the operation will ignore
|
* command; while if skipBreakpoints is true, the operation will ignore
|
||||||
* other breakpoints and continue until the specified location.
|
* other breakpoints and continue until the specified location.
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
void runToLine(IExecutionDMContext context, String fileName, String lineNo,
|
void runToLocation(IExecutionDMContext context, String location, boolean skipBreakpoints, RequestMonitor rm);
|
||||||
boolean skipBreakpoints, DataRequestMonitor<MIInfo> rm);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems and others.
|
* Copyright (c) 2006, 2010 Wind River Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -681,11 +681,8 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I
|
||||||
rm.done();
|
rm.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** @since 3.0 */
|
||||||
* Run selected execution thread to a given line number.
|
public void runToLocation(IExecutionDMContext context, String location, boolean skipBreakpoints, final RequestMonitor rm){
|
||||||
*/
|
|
||||||
public void runToLine(IExecutionDMContext context, String fileName, String lineNo, boolean skipBreakpoints, final DataRequestMonitor<MIInfo> rm){
|
|
||||||
// Later add support for Address and function.
|
|
||||||
// skipBreakpoints is not used at the moment. Implement later
|
// skipBreakpoints is not used at the moment. Implement later
|
||||||
|
|
||||||
assert context != null;
|
assert context != null;
|
||||||
|
@ -697,10 +694,10 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (doCanResume(context)) {
|
if (doCanResume(dmc)) {
|
||||||
fResumePending = true;
|
fResumePending = true;
|
||||||
fMICommandCache.setContextAvailable(context, false);
|
fMICommandCache.setContextAvailable(dmc, false);
|
||||||
fConnection.queueCommand(new MIExecUntil(dmc, fileName + ":" + lineNo), //$NON-NLS-1$
|
fConnection.queueCommand(new MIExecUntil(dmc, location),
|
||||||
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
|
new DataRequestMonitor<MIInfo>(getExecutor(), rm));
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED,
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Ericsson and others.
|
* Copyright (c) 2007, 2010 Ericsson and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -13,18 +13,22 @@ package org.eclipse.cdt.tests.dsf.gdb.tests;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
|
||||||
|
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMData;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IResumedDMEvent;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IResumedDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.IStartedDMEvent;
|
||||||
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
|
||||||
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
|
import org.eclipse.cdt.dsf.debug.service.IRunControl.StepType;
|
||||||
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
|
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
|
||||||
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
|
||||||
|
import org.eclipse.cdt.dsf.mi.service.IMIRunControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
|
import org.eclipse.cdt.dsf.mi.service.MIProcesses;
|
||||||
import org.eclipse.cdt.dsf.mi.service.MIRunControl;
|
import org.eclipse.cdt.dsf.mi.service.MIRunControl;
|
||||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
|
import org.eclipse.cdt.dsf.mi.service.command.events.MIStoppedEvent;
|
||||||
|
@ -55,10 +59,11 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
private DsfServicesTracker fServicesTracker;
|
private DsfServicesTracker fServicesTracker;
|
||||||
|
|
||||||
private IGDBControl fGDBCtrl;
|
private IGDBControl fGDBCtrl;
|
||||||
private MIRunControl fRunCtrl;
|
private IMIRunControl fRunCtrl;
|
||||||
private IMIProcesses fProcService;
|
private IMIProcesses fProcService;
|
||||||
|
|
||||||
private IContainerDMContext fContainerDmc;
|
private IContainerDMContext fContainerDmc;
|
||||||
|
private IExecutionDMContext fThreadExecDmc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Path to executable
|
* Path to executable
|
||||||
|
@ -80,8 +85,10 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
|
IMIProcesses procService = fServicesTracker.getService(IMIProcesses.class);
|
||||||
IProcessDMContext procDmc = procService.createProcessContext(fGDBCtrl.getContext(), MIProcesses.UNIQUE_GROUP_ID);
|
IProcessDMContext procDmc = procService.createProcessContext(fGDBCtrl.getContext(), MIProcesses.UNIQUE_GROUP_ID);
|
||||||
fContainerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
fContainerDmc = procService.createContainerContext(procDmc, MIProcesses.UNIQUE_GROUP_ID);
|
||||||
|
IThreadDMContext threadDmc = procService.createThreadContext(procDmc, "1");
|
||||||
|
fThreadExecDmc = procService.createExecutionContext(fContainerDmc, threadDmc, "1");
|
||||||
|
|
||||||
fRunCtrl = fServicesTracker.getService(MIRunControl.class);
|
fRunCtrl = fServicesTracker.getService(IMIRunControl.class);
|
||||||
fProcService = fServicesTracker.getService(IMIProcesses.class);
|
fProcService = fServicesTracker.getService(IMIProcesses.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +270,7 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
String pid = MIProcesses.UNIQUE_GROUP_ID;
|
String pid = MIProcesses.UNIQUE_GROUP_ID;
|
||||||
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
|
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
|
||||||
IContainerDMContext containerDmc = fProcService.createContainerContext(procDmc, pid);
|
IContainerDMContext containerDmc = fProcService.createContainerContext(procDmc, pid);
|
||||||
fRunCtrl.getExecutionData(fRunCtrl.createMIExecutionContext(containerDmc, 1), rm);
|
fRunCtrl.getExecutionData(((MIRunControl)fRunCtrl).createMIExecutionContext(containerDmc, 1), rm);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
|
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
|
||||||
|
@ -519,9 +526,6 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
wait.waitReset();
|
wait.waitReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void resumeContainerContext() throws InterruptedException{
|
public void resumeContainerContext() throws InterruptedException{
|
||||||
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
@ -573,4 +577,51 @@ public class MIRunControlTest extends BaseTestCase {
|
||||||
|
|
||||||
wait.waitReset();
|
wait.waitReset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void runToLine() throws InterruptedException{
|
||||||
|
final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
|
||||||
|
|
||||||
|
|
||||||
|
fRunCtrl.getExecutor().submit(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
fRunCtrl.runToLocation(fThreadExecDmc, SOURCE_NAME + ":27", true,
|
||||||
|
new RequestMonitor(fRunCtrl.getExecutor(), null) {
|
||||||
|
@Override
|
||||||
|
protected void handleCompleted() {
|
||||||
|
wait.waitFinished(getStatus());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
|
||||||
|
Assert.assertTrue(wait.getMessage(), wait.isOK());
|
||||||
|
wait.waitReset();
|
||||||
|
|
||||||
|
try {
|
||||||
|
new ServiceEventWaitor<ISuspendedDMEvent>(
|
||||||
|
getGDBLaunch().getSession(),
|
||||||
|
ISuspendedDMEvent.class).waitForEvent(ServiceEventWaitor.WAIT_FOREVER);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Assert.fail("Exception raised:: " + e.getMessage());
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fRunCtrl.getExecutor().submit(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
String pid = MIProcesses.UNIQUE_GROUP_ID;
|
||||||
|
IProcessDMContext procDmc = fProcService.createProcessContext(fGDBCtrl.getContext(), pid);
|
||||||
|
IContainerDMContext containerDmc = fProcService.createContainerContext(procDmc, pid);
|
||||||
|
|
||||||
|
wait.setReturnInfo(fRunCtrl.isSuspended(containerDmc));
|
||||||
|
wait.waitFinished();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
|
||||||
|
Assert.assertTrue("Target is running. It should have been suspended", (Boolean)wait.getReturnInfo());
|
||||||
|
|
||||||
|
wait.waitReset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue