|
Added
Link Here
|
| 1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2010 Ericsson and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
| 6 |
* http://www.eclipse.org/legal/epl-v10.html |
| 7 |
* |
| 8 |
* Contributors: |
| 9 |
* Ericsson - initial API and implementation |
| 10 |
*******************************************************************************/ |
| 11 |
package org.eclipse.cdt.dsf.gdb.service; |
| 12 |
|
| 13 |
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; |
| 14 |
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; |
| 15 |
import org.eclipse.cdt.dsf.datamodel.DMContexts; |
| 16 |
import org.eclipse.cdt.dsf.datamodel.IDMContext; |
| 17 |
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlDMContext; |
| 18 |
import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; |
| 19 |
import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; |
| 20 |
import org.eclipse.cdt.dsf.mi.service.IMICommandControl; |
| 21 |
import org.eclipse.cdt.dsf.mi.service.IMIContainerDMContext; |
| 22 |
import org.eclipse.cdt.dsf.mi.service.IMIProcessDMContext; |
| 23 |
import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; |
| 24 |
import org.eclipse.cdt.dsf.mi.service.command.output.MIAddInferiorInfo; |
| 25 |
import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo; |
| 26 |
import org.eclipse.cdt.dsf.service.DsfSession; |
| 27 |
import org.eclipse.core.runtime.IStatus; |
| 28 |
import org.eclipse.core.runtime.Status; |
| 29 |
|
| 30 |
public class GDBProcesses_7_2 extends GDBProcesses_7_1 { |
| 31 |
|
| 32 |
private CommandFactory fCommandFactory; |
| 33 |
private IGDBControl fCommandControl; |
| 34 |
|
| 35 |
public GDBProcesses_7_2(DsfSession session) { |
| 36 |
super(session); |
| 37 |
} |
| 38 |
|
| 39 |
@Override |
| 40 |
public void initialize(final RequestMonitor requestMonitor) { |
| 41 |
super.initialize(new RequestMonitor(getExecutor(), requestMonitor) { |
| 42 |
@Override |
| 43 |
protected void handleSuccess() { |
| 44 |
doInitialize(requestMonitor); |
| 45 |
} |
| 46 |
}); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* This method initializes this service after our superclass's initialize() |
| 51 |
* method succeeds. |
| 52 |
* |
| 53 |
* @param requestMonitor |
| 54 |
* The call-back object to notify when this service's |
| 55 |
* initialization is done. |
| 56 |
*/ |
| 57 |
private void doInitialize(RequestMonitor requestMonitor) { |
| 58 |
fCommandControl = getServicesTracker().getService(IGDBControl.class); |
| 59 |
fCommandFactory = getServicesTracker().getService(IMICommandControl.class).getCommandFactory(); |
| 60 |
requestMonitor.done(); |
| 61 |
} |
| 62 |
|
| 63 |
@Override |
| 64 |
public void shutdown(RequestMonitor requestMonitor) { |
| 65 |
super.shutdown(requestMonitor); |
| 66 |
} |
| 67 |
|
| 68 |
@Override |
| 69 |
public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor<IDMContext> rm) { |
| 70 |
if (procCtx instanceof IMIProcessDMContext) { |
| 71 |
if (!doIsDebuggerAttachSupported()) { |
| 72 |
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Attach not supported.", null)); //$NON-NLS-1$ |
| 73 |
rm.done(); |
| 74 |
return; |
| 75 |
} |
| 76 |
|
| 77 |
ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(procCtx, ICommandControlDMContext.class); |
| 78 |
fCommandControl.queueCommand( |
| 79 |
fCommandFactory.createMIAddInferior(controlDmc), |
| 80 |
new DataRequestMonitor<MIAddInferiorInfo>(getExecutor(), rm) { |
| 81 |
@Override |
| 82 |
protected void handleSuccess() { |
| 83 |
final String groupId = getData().getGroupId(); |
| 84 |
if (groupId == null || groupId.trim().length() == 0) { |
| 85 |
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid gdb group id.", null)); //$NON-NLS-1$ |
| 86 |
rm.done(); |
| 87 |
return; |
| 88 |
} |
| 89 |
|
| 90 |
final IMIContainerDMContext containerDmc = createContainerContext(procCtx, groupId); |
| 91 |
fCommandControl.queueCommand( |
| 92 |
fCommandFactory.createMITargetAttach(containerDmc, ((IMIProcessDMContext)procCtx).getProcId()), |
| 93 |
new DataRequestMonitor<MIInfo>(getExecutor(), rm) { |
| 94 |
@Override |
| 95 |
protected void handleSuccess() { |
| 96 |
rm.setData(containerDmc); |
| 97 |
rm.done(); |
| 98 |
} |
| 99 |
}); |
| 100 |
} |
| 101 |
}); |
| 102 |
} else { |
| 103 |
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INTERNAL_ERROR, "Invalid process context.", null)); //$NON-NLS-1$ |
| 104 |
rm.done(); |
| 105 |
} |
| 106 |
} |
| 107 |
} |
| 108 |
|